-
Notifications
You must be signed in to change notification settings - Fork 220
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
Rebuild Python with conda build on OS X #498
Comments
Letting @msarahan know about this one. We'll try to migrate all recipes to be conda-build ones after we release Anaconda 2.4. |
@groutr, I want to track this issue as well. |
Just adding a +1 to the desirability of this fix. I work on the software development team for the Large Synoptic Survey Telescope. We have been having trouble making our build system work with anaconda because of the lack of @rpath in the loading address for libpython*.dylib in Anaconda. |
@msarahan et al -- would a short-term fix be possible, in the form of adding a line such as:
to your existing Python build script? That seems to fix some of our build issues. |
Ping @ilanschnell on this. He needs to make the call on this issue. |
@mjuric that page can't be viewed without a login. Just changing the id isn't enough. You also need to set the LC_RPATH on the dylib. It may work anyway for some cases if it can find the LC_RPATH from another dylib in the load chain, but in general it is needed. conda build does this all automatically (and also changes about a dozen other object files that are part of the python package). As a workaround, I built python with conda build, as noted in the OP (Python 3.5 only). You can use that with
and use the I HIGHLY recommend doing whatever workarounds you do in a separate conda environment. Don't mess with the Python in the root environment. |
@asmeurer Oops, sorry, I didn't realize that part of our Jira is closed (shouldn't be... argh...) -- here's the PDF dump of the link. Regarding whether changing the id is enough; while I 100% agree with what you're saying (and that a comprehensive fix is desirable), even just setting the id would fix the particular problem we've been fighting for a while now. So far, we've been able to circumvent the lack of id with DYLD_FALLBACK_LIBRARY_PATH hacks, but now SIP on El Capitan is thwarting those. I suspect it may help other packages encountering similar problems. PS: If the switch to A bird in the hand, etc, etc :). |
I have recently done some changes to our internal Anaconda build system, to |
Brilliant, thanks! So we should expect a rebuild no later than Anaconda 2.5 (some ~3 months or so)? |
I would just like to draw attention back to this issue. I just installed anaconda 2.5 on my OSX machine
the lack of |
+1 for requesting a resolution to this sooner rather than later. For GalSim users who are using Anaconda python, we currently recommend a complicated procedure using |
This is affecting me too, I have a CMake Python extension that I manually have to patch to get around the missing rpath (all the other conda libs seem to have it, besides lib python 3.5). I'd like to make it easier to install than that! |
Detect if the libpython*.dylib library's install_name is incorrect (relative), and: * pass DYLD_FALLBACK_LIBRARY_PATH to GalSim's scons, to enable the build to proceed * fix the install_name in _galsim.so after the build succeeds. This enables us to work around Anaconda Python's bug described in: ContinuumIO/anaconda-issues#498 and successfully build+run GalSim.
This makes it easier to build GalSim against buggy Python builds (such as the one shipping with Anaconda; see ContinuumIO/anaconda-issues#498).
It would be really great to get this patched. I'm working with a library (fenics, dolfin, ffc) that does its own compilation of Python modules at runtime, and they can't load libpython.dylib correctly because of this. That means I have to tell users to set DYLD_FALLBACK_LIBRARY_PATH whenever they activate an env with this package, which isn't tenable. I don't see a workaround that can be applied in my conda package. The only other library I've noticed with the same problem is mkl, which also lacks the rpath, so that should get rebuilt as well. |
@msarahan, is there something we can do about this one? |
It is up to @ilanschnell when he wants to do this. I am trying to help the conda-forge effort (conda-forge/staged-recipes#370), so that people will have another choice in this matter. Hopefully that work might also make any transition that Ilan makes easier. |
@minrk a workaround in your conda package could be a post-link script that rewrites the rpath on libpython2.7.dylib/libpython3.5m.dylib. |
I would just like to say that, for the purposes of the LSST group, @asmeurer 's workaround has been deemed unhelpful, as we want to be able to deploy to shared systems where the users installing our package may not have write-access to libpython2.7.dylib. Fixing this in the conda install itself is really the only option. |
No, you can rewrite the path in your binary with a script/command line. Rewriting the path in the lib python binary is great (that’s how I do it, on EVERY anaconda install on mac :’( ), but it requires write access and manipulation of the base anaconda install. The link command inside your executable can be rewritten instead.
|
Do they have write access to the environment? I should point out that to do the workaround I suggested properly, you should break the hardlink for libpython2.7.dylib in the environment first. You should always break hardlinks before editing installed files in-place in conda packages, so that you don't inadvertently break other environments. |
@asmeurer cool, thanks, I'll look into the post-link script. I made patch-conda-rpaths as a quick-and-dirty reusable script for doing this. It might even work! |
+1 just ran into this. The patch from @minrk worked for me. |
I have the same issue with libgfortran.3.dylib and self written Fortran code but also with scikits.bvp1lg (a BVP solver bases on Fortran). I tried @minrk's patch using
however, this gives me a fatal error:
Am I using the patch correctly? Or will there be a solution for OS X soon? Thanks! |
@lkiewidt, @minrk needs to make his script ignore stub files (conda-build does this). |
Thanks, @asmeurer! I didn't know about stub files (still don't, really), but I've pushed a new release of patch-conda-rpaths with the same check as conda-build, so maybe it'll work now. |
Yeah I don't know anything about them either, but as far as I can tell, ignoring them is the right thing to do. |
@asmeurer: I ran into a problem today that made me think whether (some?) libraries in conda's I tried to build OpenOrb with conda-supplied
This is not surprising -- running The usual remedy for this is to set But this made me thinking... I think having the compiler runtimes ( I therefore worry whether the strategy to have all libraries have |
The rpath trick may require you to add an Using absolute install names is problematic, because it adds complexity to conda install (or to the package, via pre-link script, which has its own issues). By using relative rpaths, the complexity is offloaded to conda build, and the install is simple (just linking the files into place). |
CC @mingwandroid - you're also interested in this terrible game on Mac. |
@asmeurer Right, but the way the
This is unexpected/conuterintuitive. The same thing would actually happen if you built a C++ program, except that While I understand the simplicity that |
+1 for absolute library paths on Macs. Anaconda python is by far the hardest python for us to support for GalSim. 90+% of our user installation problems come from Anaconda users on Macs (and they don't make up nearly 90% of our user base). It's almost always a combination of the @rpath stuff, the fact that libpython2.7.dylib doesn't even have that (i.e. this issue), and now the new SIP on El Capitan removing the DYLD_LIBRARY_PATH solution that used to make this doable. I think RPATH is a great solution on linux (where Anaconda shines, imho), but the Mac OS developers really seem to be steering people toward absolute paths in library files, and bucking that often just leads to problems. |
Came by this thread while trying to sort out my solve my
And then after building the shared library,
where
These code blocks (taken from https://github.com/manodeep/Corrfunc/) should solve the build/run problems with conda python on OSX. There can be some additional issues involving links with |
How to uninstall anaconda from my MacBook? i want to install Tensorflow to work from R, but pip automaticly put it in anaconda directory and its not tensorFlow not working in R. |
This is probably not the very best place for that question, but I do happen to know the answer :-) You don't need to uninstall anaconda, all you need to do is remove it from your path environment variable. I believe, on my Mac it set in the |
I was kind of hoping this would have happened by now. Conda build on OS X adds @rpath to the install name on OS X and adds an LC_RPATH. This makes it possible to build things that link against libraries and have them work without having to call install_name_tool (or build them with conda build, which calls it for you).
An example of this:
sympy.utilities.autowrap
generates a Fortran extension module on the fly using f2py (part of NumPy). Create a conda environment on OS X withpython sympy numpy gcc
and runThis will attempt to use f2py to generate an extension module in the current directory using fortran (with gfortran from the gcc package) and import it. On OS X, you get an error like
What this means is that the extension module linked against libgfortran from the gcc package which has
@rpath/./libgfortran.3.dylib
as its install name. The@rpath
should reference theLC_RPATH
of some loaded library, which would point to thelib/
directory of the environment, but nothing already loaded has anLC_RPATH
, in particular, Python itself does not. Effectively, it's impossible to import this extension module without "fixing" it with install_name_tool, which is undesirable for an automated tool like autowrap.To fix this, Python should be rebuilt with conda-build. This will add the
LC_RPATH
to libpython3.5m.dylib and the dyld loader will be able to find the extension module.I tested this myself, by building the python-3.5 recipe in conda-recipe (I added the build string
conda_build_0
so you can tell the difference).You can test with
and run the above code. It will work. (note that if you don't pin that Python build in the
test
environment further conda commands will "update" it to the standard one, since that has a newer build string)You can see the difference with
conda inspect objects python
(or just usingotool -L
andotool -l
).The text was updated successfully, but these errors were encountered: