Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix python dest #160

Merged
merged 18 commits into from
May 3, 2018
Merged

Fix python dest #160

merged 18 commits into from
May 3, 2018

Conversation

paskino
Copy link
Contributor

@paskino paskino commented Apr 11, 2018

The PYTHON_DEST variable was always overwritten to `${CMAKE_INSTALL_PREFIX}/python'

CMakeLists.txt Outdated
@@ -75,7 +75,10 @@ find_package(PythonInterp)
find_package(PythonLibs)
set (BUILD_PYTHON ${PYTHONLIBS_FOUND})
if (BUILD_PYTHON)
set(PYTHON_DEST "${CMAKE_INSTALL_PREFIX}/python")
if (PYTHON_DEST)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

clearer to say

if (NOT PYTHON_DEST)
  set(...)
endif()

Copy link
Contributor Author

@paskino paskino Apr 17, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does that work? from the docs I understood it wouldn't with a variable

@KrisThielemans
Copy link
Member

I understand that this will do the following: if PYTHON_DEST not set by the user, it will use the current CMAKE_INSTALL_PREFIX to construct the path, else it will use the user's value. Neat.

This circumvents the original problem creating it as a cached variable which we fixed in #77. Does it also work when the user creates PYTHON_DEST only at the 2nd run of CMake? (I think so).

It is of course somewhat non-CMake-like as the unsuspecting user will never see the possibility of using this variable (as it won't appear in the GUI for instance). I guess we could/should document it. A possibly better alternative would be to do this trick with another cached variable, e.g. PYTHON_INSTALL_DIR. Something like this maybe?

if (BUILD_PYTHON)
  set(PYTHON_INSTALL_DIR "" CACHE ....)
  if (PYTHON_INSTALL_DIR)
   set(PYTHON_DEST "${PYTHON_INSTALL_DIR }")
  else() 
    set(PYTHON_DEST "${CMAKE_INSTALL_PREFIX}/python")
endif()

This should work due to the rules for if(). It is somewhat confusing for the user though.

Opinions?

Clearly, we'd have to do the same for MATLAB_DEST

CMakeLists.txt Outdated
if (PYTHON_DEST)
else()
set(PYTHON_DEST "${CMAKE_INSTALL_PREFIX}/python")
endif()
message(STATUS "Python libraries found")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's add the install location to the message

casperdcl added a commit to SyneRBI/SIRF-SuperBuild that referenced this pull request Apr 17, 2018
Copy link
Member

@casperdcl casperdcl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM; no-brainer

@KrisThielemans
Copy link
Member

If we're (re)allowing setting the destination, I'd rather get this right now (especially as we'll do this for SIRF, SIRF-SuperBuild and STIR). I'm therefore leaning towards the cached variable. We could call that PYTHON_DEST of course, but it'd need more code changes and possibly PYTHON_INSTALL_DIR is more standard?

PS: I checked that Gadgetron doesn't allow to set this. They have an internal variable for it and install in ${CMAKE_INSTALL_PREFIX}/share/gadgetron/python , see here. However, this isn't a major problem for us as we don't build/use the python gadgets.

@casperdcl
Copy link
Member

Even if we did use the gadgetron python things, we'd use their framework to install it - not ours.

@paskino
Copy link
Contributor Author

paskino commented Apr 18, 2018

@KrisThielemans do you intend to have a cached variable only in the SuperBuild, or also in SIRF/STIR?

To me it makes sense to have a cached variable only in the SuperBuild. Possibly in STIR, which is independent on SIRF.

Who is going to install SIRF without the SuperBuild?

@KrisThielemans
Copy link
Member

Who is going to install SIRF without the SuperBuild?
most SIRF developers I think. It's not so easy to set up the SuperBuild such that it picks up your local copy where you're editing (and not occasionally override things).

Let's therefore put it in SIRF and SIRF-SuperBuild and STIR.

Before going ahead, can you just do a check that with your current set-up, changing the CMAKE_INSTALL_PREFIX (while not having set PYTHON_DEST) does indeed do what we want?

Clearly, we'd want it for matlab as well.

Just had a conversation about naming of the cached variables with @bathomas. It's not so easy to choose a name that is immediately clear to people (Matlab_INSTALL_DIR could just as well be understood as "where is your Matlab", which is actually a variable Matlab_ROOT_DIR). Feel free to put some suggestions here and let's vote on Friday.

@casperdcl
Copy link
Member

casperdcl commented Apr 18, 2018

I think *_(BINARY|LIBRARY_INCLUDE)_DIR are all for where to put obtain already present files from findPackage() etc, while *_(INSTALL|DEST|SITE|PACKAGE|PREFIX)_DIR should be for new things to install. Personally I'd vote for prefix because that matches configure logic

@casperdcl
Copy link
Member

Shouldn't SIRF devs be using a superbuild script cmake.sh with all the flags they need (including -DSIRF_TAG=myLocalFeatureBranch)?

@paskino
Copy link
Contributor Author

paskino commented Apr 18, 2018

@casperdcl I'm actually thinking that that would be the preferred way. However, the SuperBuild will always overwrite the sources directory, so you'll always loose your changes.

A good enhancement would be to select whether to download SIRF or not during a SuperBuild.

@casperdcl
Copy link
Member

I've only ever used the SuperBuild for all my dev work and never had a problem with overwriting. Maybe I've been doing things a bit differently from everyone else? May want to add this to the discussion on Fri.

@casperdcl
Copy link
Member

Incidentally for those of you who have VMs and don't (can't) use docker directly, you can always use docker in your VM. This is what many windows devs in industry do https://blog.docker.com/2016/04/containers-and-vms-together/

Perhaps we could consider shipping a docker image(s) and a VM with the image, and drop the current VM? related: SyneRBI/SIRF-SuperBuild#91

@KrisThielemans
Copy link
Member

@casperdcl, the potential problem is when using the SuperBuild, it will normally extract a revision of SIRF, so if you edit, the next run of the superbuild might get the revision again, silently removing your edits (git can be crazy). So you do have to use a SIRF_TAG, but that cannot be local, unless you sit the SIRF_URL to your local copy. etc. etc. (Would be good to document this).

Regarding shipping with docker. I have no clue if you can run interactive scripts then on the VM (without a bunch of trickery). It'd be a somewhat bad user-experience if they have to write docker run python ... and can only use the scripts. I know you can seth the DISPLAY etc and presumably run spyder from docker, but it starts to give me headache. (You can see I haven't used docker yet). If it turns out to be easy, well, that'd be an option. (although I am warry of creating another layer where things can go wrong).

casperdcl added a commit to SyneRBI/SIRF-SuperBuild that referenced this pull request Apr 19, 2018
@casperdcl
Copy link
Member

can we rebase this (removing non-surviving commits) and merge?

@KrisThielemans
Copy link
Member

things to fix first:

  • use the cached variable strategy shown above
  • rename variable (let's discuss this Friday)
  • duplicate for matlab (or can be separate PR)

@KrisThielemans
Copy link
Member

name for cached variable: PYTHON_DEST_DIR, MATLAB_DEST_DIR

@paskino paskino self-assigned this Apr 27, 2018
casperdcl added a commit that referenced this pull request Apr 27, 2018
@casperdcl casperdcl mentioned this pull request Apr 27, 2018
12 tasks
casperdcl added a commit to SyneRBI/SIRF-SuperBuild that referenced this pull request Apr 27, 2018
@paskino
Copy link
Contributor Author

paskino commented Apr 30, 2018

@casperdcl I guess so, and that might be the reason that travis fails?

@paskino
Copy link
Contributor Author

paskino commented May 1, 2018

No, the reason travis failed is that the CMakeLists.txt had syntax error. Should be fixed now.

casperdcl added a commit that referenced this pull request May 1, 2018
Copy link
Member

@KrisThielemans KrisThielemans left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please also add this in CHANGES.md. I guess also in installation instructions (if they're on the wiki, we'd have to wait until the release I guess).

.travis.yml Outdated
@@ -63,7 +63,7 @@ env:
global:
- BUILD_FLAGS="-DCMAKE_BUILD_TYPE=Release"
# don't use too many threads - may crash
- MAKEFLAGS="-j 2"
- MAKEFLAGS="-j 1"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't mind, but is this intentional?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, I use 1 thread when I debug, otherwise I don't understand what's gone wrong. will put it back to 2

CMakeLists.txt Outdated
@@ -75,18 +75,31 @@ find_package(PythonInterp)
find_package(PythonLibs)
set (BUILD_PYTHON ${PYTHONLIBS_FOUND})
if (BUILD_PYTHON)
set(PYTHON_DEST "${CMAKE_INSTALL_PREFIX}/python")
set(PYTHON_INSTALL_DIR "" CACHE PATH "Directory of the SIRF Python modules")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I seem to recall we chose PYTHON_DEST_DIR to avoid confusion with "my files" vs "system files"?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

damn you're right! #160 (comment)

@@ -75,18 +75,31 @@ find_package(PythonInterp)
find_package(PythonLibs)
set (BUILD_PYTHON ${PYTHONLIBS_FOUND})
if (BUILD_PYTHON)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add a comment saying why we do this

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks. I'd add something like "If PYTHON_DEST_DIR is not set, we will install in ${CMAKE_INSTALL_PREFIX}/python". I know, obvious maybe...

CMakeLists.txt Outdated
message(STATUS "Python libraries found")
message(STATUS "Location of Python modules: " ${PYTHON_DEST})
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

confusing text. maybe "SIRF Python modules will be installed in..."

CMakeLists.txt Outdated
set(MATLAB_DEST "${CMAKE_INSTALL_PREFIX}/matlab")
endif()
message(STATUS "Matlab libraries found")
message(STATUS "Location of Matlab libraries: " ${MATLAB_DEST})
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here obviously

@casperdcl casperdcl merged commit 241b4e2 into master May 3, 2018
@casperdcl casperdcl deleted the fix_python_dest branch May 3, 2018 13:36
casperdcl added a commit that referenced this pull request May 3, 2018
@casperdcl casperdcl restored the fix_python_dest branch May 3, 2018 13:44
casperdcl added a commit to SyneRBI/SIRF-SuperBuild that referenced this pull request May 3, 2018
@casperdcl casperdcl deleted the fix_python_dest branch May 3, 2018 15:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants