diff --git a/.travis.yml b/.travis.yml index 78c5b9c..ded338a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -9,6 +9,8 @@ _install: &_install - pip install numpy auditwheel==1.4 setuptools twine - python3 setup.py bdist_wheel - auditwheel repair -w dist dist/* + - unzip dist/*manylinux* + - ldd libMHCUDA-*.data/purelib/libMHCUDA.so _deploy: &_deploy provider: script diff --git a/setup.py b/setup.py index 1c932b2..2023a7e 100644 --- a/setup.py +++ b/setup.py @@ -5,11 +5,29 @@ from setuptools.dist import Distribution from shutil import copyfile from subprocess import check_call -from sys import platform +import sys +import sysconfig + + +def get_python_library(): + """Get path to the python library associated with the current python + interpreter.""" + cfgvar = sysconfig.get_config_var + libname = cfgvar("LDLIBRARY") + python_library = os.path.join( + cfgvar("LIBDIR") + (cfgvar("multiarchsubdir") or ""), + libname) + if os.path.exists(python_library): + return python_library + for root, dirnames, filenames in os.walk(cfgvar("base")): + for filename in filenames: + if filename == libname: + return os.path.join(root, filename) + raise FileNotFoundError(libname) class CMakeBuild(build_py): - SHLIBEXT = "dylib" if platform == "darwin" else "so" + SHLIBEXT = "dylib" if sys.platform == "darwin" else "so" def run(self): if not self.dry_run: @@ -22,10 +40,15 @@ def get_outputs(self, *args, **kwargs): return outputs def _build(self, builddir=None): + syspaths = sysconfig.get_paths() check_call(("cmake", "-DCMAKE_BUILD_TYPE=Release", "-DCUDA_TOOLKIT_ROOT_DIR=%s" % os.getenv( "CUDA_TOOLKIT_ROOT_DIR", "must_export_CUDA_TOOLKIT_ROOT_DIR"), + "-DPYTHON_DEFAULT_EXECUTABLE=python3", + "-DPYTHON_INCLUDE_DIRS=" + syspaths["include"], + "-DPYTHON_EXECUTABLE=" + sys.executable, + "-DPYTHON_LIBRARY=" + get_python_library(), ".")) check_call(("make", "-j%d" % cpu_count())) self.mkpath(self.build_lib) @@ -55,7 +78,7 @@ def is_pure(self): py_modules=["libMHCUDA"], install_requires=["numpy"], distclass=BinaryDistribution, - cmdclass={'build_py': CMakeBuild}, + cmdclass={"build_py": CMakeBuild}, classifiers=[ "Development Status :: 5 - Production/Stable", "Intended Audience :: Developers",