summaryrefslogtreecommitdiff
path: root/setup.py
diff options
context:
space:
mode:
authorFrédéric-Emmanuel Picca <picca@debian.org>2018-08-08 14:09:02 +0200
committerFrédéric-Emmanuel Picca <picca@debian.org>2018-08-08 14:09:02 +0200
commit75271d5d9979b204baf8172b2a03da4330b14083 (patch)
tree22a2e31692654f1464c6fc8463cafe6598d9bdc4 /setup.py
parent989033673e36f8d9959dd2d3a8285e5339bfae0c (diff)
parent302d3bcf3ef555284ce1bcf5cd7cd371addfa608 (diff)
Merge tag 'debian/0.8.0+dfsg-1' into debian/stretch-backports
silx release 0.8.0+dfsg-1 for unstable (sid) (maintainer view tag generated by dgit --quilt=gbp)
Diffstat (limited to 'setup.py')
-rw-r--r--setup.py108
1 files changed, 95 insertions, 13 deletions
diff --git a/setup.py b/setup.py
index 08e4f90..69a6dca 100644
--- a/setup.py
+++ b/setup.py
@@ -2,7 +2,7 @@
# coding: utf8
# /*##########################################################################
#
-# Copyright (c) 2015-2017 European Synchrotron Radiation Facility
+# Copyright (c) 2015-2018 European Synchrotron Radiation Facility
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
@@ -25,7 +25,7 @@
# ###########################################################################*/
__authors__ = ["Jérôme Kieffer", "Thomas Vincent"]
-__date__ = "27/02/2018"
+__date__ = "23/04/2018"
__license__ = "MIT"
@@ -114,6 +114,7 @@ classifiers = ["Development Status :: 4 - Beta",
"Programming Language :: Python :: 3.4",
"Programming Language :: Python :: 3.5",
"Programming Language :: Python :: 3.6",
+ "Programming Language :: Python :: 3.7",
"Programming Language :: Python :: Implementation :: CPython",
"Topic :: Scientific/Engineering :: Physics",
"Topic :: Software Development :: Libraries :: Python Modules",
@@ -140,9 +141,11 @@ class build_py(_build_py):
########
class PyTest(Command):
- """Command to start tests running the script: run_tests.py -i"""
+ """Command to start tests running the script: run_tests.py"""
user_options = []
+ description = "Execute the unittests"
+
def initialize_options(self):
pass
@@ -179,6 +182,9 @@ if sphinx is None:
class BuildMan(Command):
"""Command to build man pages"""
+
+ description = "Build man pages of the provided entry points"
+
user_options = []
def initialize_options(self):
@@ -372,6 +378,7 @@ if sphinx is not None:
else:
TestDocCommand = SphinxExpectedCommand
+
# ############################# #
# numpy.distutils Configuration #
# ############################# #
@@ -582,8 +589,7 @@ class BuildExt(build_ext):
patched_exts = cythonize(
[ext],
compiler_directives={'embedsignature': True},
- force=self.force_cython,
- compile_time_env={"HAVE_OPENMP": self.use_openmp}
+ force=self.force_cython
)
ext.sources = patched_exts[0].sources
@@ -601,6 +607,15 @@ class BuildExt(build_ext):
ext.extra_link_args = [self.LINK_ARGS_CONVERTER.get(f, f)
for f in ext.extra_link_args]
+ elif self.compiler.compiler_type == 'unix':
+ # Avoids runtime symbol collision for manylinux1 platform
+ # See issue #1070
+ extern = 'extern "C" ' if ext.language == 'c++' else ''
+ return_type = 'void' if sys.version_info[0] <= 2 else 'PyObject*'
+
+ ext.extra_compile_args.append(
+ '''-fvisibility=hidden -D'PyMODINIT_FUNC=%s__attribute__((visibility("default"))) %s ' ''' % (extern, return_type))
+
def is_debug_interpreter(self):
"""
Returns true if the script is executed with a debug interpreter.
@@ -662,7 +677,6 @@ class BuildExt(build_ext):
self.patch_extension(ext)
build_ext.build_extensions(self)
-
################################################################################
# Clean command
################################################################################
@@ -687,12 +701,35 @@ class CleanCommand(Clean):
path_list2.append(path)
return path_list2
+ def find(self, path_list):
+ """Find a file pattern if directories.
+
+ Could be done using "**/*.c" but it is only supported in Python 3.5.
+
+ :param list[str] path_list: A list of path which may contains magic
+ :rtype: list[str]
+ :returns: A list of path without magic
+ """
+ import fnmatch
+ path_list2 = []
+ for pattern in path_list:
+ for root, _, filenames in os.walk('.'):
+ for filename in fnmatch.filter(filenames, pattern):
+ path_list2.append(os.path.join(root, filename))
+ return path_list2
+
def run(self):
Clean.run(self)
+
+ cython_files = self.find(["*.pyx"])
+ cythonized_files = [path.replace(".pyx", ".c") for path in cython_files]
+ cythonized_files += [path.replace(".pyx", ".cpp") for path in cython_files]
+
# really remove the directories
# and not only if they are empty
to_remove = [self.build_base]
to_remove = self.expand(to_remove)
+ to_remove += cythonized_files
if not self.dry_run:
for path in to_remove:
@@ -706,6 +743,37 @@ class CleanCommand(Clean):
pass
################################################################################
+# Source tree
+################################################################################
+
+class SourceDistWithCython(sdist):
+ """
+ Force cythonization of the extensions before generating the source
+ distribution.
+
+ To provide the widest compatibility the cythonized files are provided
+ without suppport of OpenMP.
+ """
+
+ description = "Create a source distribution including cythonozed files (tarball, zip file, etc.)"
+
+ def finalize_options(self):
+ sdist.finalize_options(self)
+ self.extensions = self.distribution.ext_modules
+
+ def run(self):
+ self.cythonize_extensions()
+ sdist.run(self)
+
+ def cythonize_extensions(self):
+ from Cython.Build import cythonize
+ cythonize(
+ self.extensions,
+ compiler_directives={'embedsignature': True},
+ force=True
+ )
+
+################################################################################
# Debian source tree
################################################################################
@@ -719,6 +787,9 @@ class sdist_debian(sdist):
* remove .bat files
* include .l man files
"""
+
+ description = "Create a source distribution for Debian (tarball, zip file, etc.)"
+
@staticmethod
def get_debian_name():
import version
@@ -753,10 +824,10 @@ class sdist_debian(sdist):
base, ext = os.path.splitext(basename)
while ext in [".zip", ".tar", ".bz2", ".gz", ".Z", ".lz", ".orig"]:
base, ext = os.path.splitext(base)
- if ext:
- dest = "".join((base, ext))
- else:
- dest = base
+ # if ext:
+ # dest = "".join((base, ext))
+ # else:
+ # dest = base
# sp = dest.split("-")
# base = sp[:-1]
# nr = sp[-1]
@@ -772,9 +843,18 @@ class sdist_debian(sdist):
def get_project_configuration(dry_run):
"""Returns project arguments for setup"""
+ # Use installed numpy version as minimal required version
+ # This is useful for wheels to advertise the numpy version they were built with
+ if dry_run:
+ numpy_requested_version = ""
+ else:
+ from numpy.version import version as numpy_version
+ numpy_requested_version = " >= %s" % numpy_version
+ logger.info("Install requires: numpy %s", numpy_requested_version)
+
install_requires = [
# for most of the computation
- "numpy",
+ "numpy %s" % numpy_requested_version,
# for the script launcher
"setuptools"]
@@ -811,6 +891,7 @@ def get_project_configuration(dry_run):
build_ext=BuildExt,
build_man=BuildMan,
clean=CleanCommand,
+ sdist=SourceDistWithCython,
debian_src=sdist_debian)
if dry_run:
@@ -856,7 +937,7 @@ def setup_package():
'clean', '--name')))
if dry_run:
- # DRY_RUN implies actions which do not require dependancies, like NumPy
+ # DRY_RUN implies actions which do not require dependencies, like NumPy
try:
from setuptools import setup
logger.info("Use setuptools.setup")
@@ -868,10 +949,11 @@ def setup_package():
from setuptools import setup
except ImportError:
from numpy.distutils.core import setup
- logger.info("Use numpydistutils.setup")
+ logger.info("Use numpy.distutils.setup")
setup_kwargs = get_project_configuration(dry_run)
setup(**setup_kwargs)
+
if __name__ == "__main__":
setup_package()