-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* first attempt to fix building; sdist works; wheel misses the compiled objects * bumps Cython version to 3.0.0; adds explicit Cython language levels and removes numpy deprecations warnings * build.py might need to be changed in the future, but this should make the package installable as a hot fix
- Loading branch information
Showing
7 changed files
with
70 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,43 +1,46 @@ | ||
from setuptools import Extension | ||
from setuptools.command.build_ext import build_ext as _build_ext | ||
import os | ||
import shutil | ||
import sys | ||
from distutils.core import Distribution, Extension | ||
|
||
from Cython.Build import build_ext, cythonize | ||
import numpy | ||
|
||
# bootstrap numpy | ||
# https://stackoverflow.com/questions/19919905/how-to-bootstrap-numpy-installation-in-setup-py | ||
class build_ext(_build_ext): | ||
def finalize_options(self): | ||
_build_ext.finalize_options(self) | ||
# Prevent numpy from thinking it is still in its setup process: | ||
#__builtins__.__NUMPY_SETUP__ = False | ||
import numpy | ||
self.include_dirs.append(numpy.get_include()) | ||
cython_dir = "pyndl" | ||
|
||
ndl_parallel = Extension("pyndl.ndl_parallel", | ||
["pyndl/ndl_parallel.pyx"], | ||
include_dirs=[numpy.get_include()]) | ||
ndl_openmp = Extension("pyndl.ndl_openmp", | ||
["pyndl/ndl_openmp.pyx"], | ||
extra_compile_args=['-fopenmp'], | ||
extra_link_args=['-fopenmp'], | ||
include_dirs=[numpy.get_include()]) | ||
corr_parallel = Extension("pyndl.correlation_openmp", | ||
["pyndl/correlation_openmp.pyx"], | ||
extra_compile_args=['-fopenmp'], | ||
extra_link_args=['-fopenmp'], | ||
include_dirs=[numpy.get_include()]) | ||
|
||
ndl_parallel = Extension("pyndl.ndl_parallel", ["pyndl/ndl_parallel.pyx"]) | ||
ndl_openmp = Extension("pyndl.ndl_openmp", ["pyndl/ndl_openmp.pyx"], | ||
extra_compile_args=['-fopenmp'], extra_link_args=['-fopenmp']) | ||
corr_parallel = Extension("pyndl.correlation_openmp", ["pyndl/correlation_openmp.pyx"], | ||
extra_compile_args=['-fopenmp'], extra_link_args=['-fopenmp']) | ||
# by giving ``cython`` as ``install_requires`` this will be ``cythonized`` | ||
# automagically | ||
|
||
ext_modules = [] | ||
extensions = [] | ||
include_paths = [] | ||
if sys.platform.startswith('linux'): | ||
ext_modules = [ndl_parallel, ndl_openmp, corr_parallel] | ||
extensions = [ndl_parallel, ndl_openmp, corr_parallel] | ||
include_paths = [cython_dir, cython_dir, cython_dir] | ||
elif sys.platform.startswith('win32'): | ||
ext_modules = [ndl_parallel] # skip openmp installation on windows for now | ||
extensions = [ndl_parallel] # skip openmp installation on windows for now | ||
include_paths = [cython_dir] | ||
elif sys.platform.startswith('darwin'): | ||
ext_modules = [ndl_parallel] # skip openmp installation on macos for now | ||
extensions = [ndl_parallel] # skip openmp installation on macos for now | ||
include_paths = [cython_dir] | ||
|
||
ext_modules = cythonize(extensions, include_path=include_paths) | ||
dist = Distribution({"ext_modules": ext_modules}) | ||
cmd = build_ext(dist) | ||
cmd.ensure_finalized() | ||
cmd.run() | ||
|
||
for output in cmd.get_outputs(): | ||
relative_extension = os.path.relpath(output, cmd.build_lib) | ||
shutil.copyfile(output, relative_extension) | ||
|
||
def build(setup_kwargs): | ||
""" | ||
This function is mandatory in order to build the extensions. | ||
""" | ||
setup_kwargs.update({ | ||
'ext_modules': ext_modules, | ||
'cmdclass': { | ||
'build_ext': build_ext | ||
} | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
# cython: language_level=3 | ||
|
||
cdef enum ErrorCode: | ||
NO_ERROR = 0 | ||
MAGIC_NUMBER_DOES_NOT_MATCH = 1 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters