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

delocating wheels built with conda's clang #37

Closed
anntzer opened this issue Mar 7, 2018 · 0 comments · Fixed by #94
Closed

delocating wheels built with conda's clang #37

anntzer opened this issue Mar 7, 2018 · 0 comments · Fixed by #94

Comments

@anntzer
Copy link

anntzer commented Mar 7, 2018

Consider the following example:

foo.cpp (trivial module that links to libc++):

#include "Python.h"
#include <iostream>

static struct PyModuleDef moduledef = {
  PyModuleDef_HEAD_INIT,
  "foo", NULL, 0, NULL, NULL, NULL, NULL, NULL
};

PyMODINIT_FUNC PyInit_foo() {
  std::cout << "hello world\n";  // enforce that we'll link to libc++
  return PyModule_Create(&moduledef);
}

setup.py:

from setuptools import *
setup(name="foo",
      packages=["pkg"],
      ext_modules=[Extension("pkg.foo", ["foo.cpp"],
                             extra_compile_args=[
                                 "-mmacosx-version-min=10.9",
                                 "-stdlib=libc++"],
                             extra_link_args=["-lc++"])])

I explicitly link against libc++ because we want it to get packaged by delocate-wheel. The reason is that I actually rely on a very recent libc++ (for C++17 support in https://github.com/anntzer/mplcairo). The equivalent for a Linux build is to pass -static-libgcc -static-libstdc++ to gcc, but AFAICT libc++ cannot be statically linked.

Let's try to build this using conda's clang (I don't have the permission to use homebrew on that machine) in a clean environment:

conda create -yn tmp python=3.6 &&
    activate tmp &&
    conda install -yc anaconda clangxx_osx-64 &&
    pip install delocate

then python setup.py bdist_wheel and delocate-wheel dist/foo-*.whl.

This fails with

/Users/anntzer/miniconda3/envs/mplcairo-build/lib/python3.6/site-packages/delocate/libsana.py:101: UserWarning: Couldn't find @rpath/libc++abi.1.dylib on paths:
        /Users/anntzer/src/local/miniextension/@loader_path
  '\n\t'.join(realpath(path) for path in rpaths),
Copied to package .dylibs directory:
  /Users/anntzer/miniconda3/envs/tmp/lib/libc++.1.0.dylib

Note, interestingly, that if the extension module is at the toplevel (not placed in a pkg package), then delocate-wheel does not complain.

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 a pull request may close this issue.

1 participant