Commit 9cda1259 authored by payno's avatar payno
Browse files

clean setup.py file

parent 9800d1a7
......@@ -215,33 +215,6 @@ def configuration(parent_package='', top_path=None):
class Build(_build):
"""Command to support more user options for the build."""
user_options = [
('no-openmp', None,
"do not use OpenMP for compiled extension modules"),
('openmp', None,
"use OpenMP for the compiled extension modules"),
('no-cython', None,
"do not compile Cython extension modules (use default compiled c-files)"),
('force-cython', None,
"recompile all Cython extension modules"),
]
user_options.extend(_build.user_options)
boolean_options = ['no-openmp', 'openmp', 'no-cython', 'force-cython']
boolean_options.extend(_build.boolean_options)
def initialize_options(self):
_build.initialize_options(self)
self.no_openmp = None
self.openmp = None
self.no_cython = None
self.force_cython = None
def finalize_options(self):
_build.finalize_options(self)
self.finalize_cython_options(min_version='0.21.1')
self.finalize_openmp_options()
def _parse_env_as_bool(self, key):
content = os.environ.get(key, "")
value = content.lower()
......@@ -256,81 +229,6 @@ class Build(_build):
logger.warning(msg, key, content)
return None
def finalize_openmp_options(self):
"""Check if extensions must be compiled with OpenMP.
The result is stored into the object.
"""
if self.openmp:
use_openmp = True
elif self.no_openmp:
use_openmp = False
else:
env_force_cython = self._parse_env_as_bool("WITH_OPENMP")
if env_force_cython is not None:
use_openmp = env_force_cython
else:
# Use it by default
use_openmp = True
if use_openmp:
if platform.system() == "Darwin":
# By default Xcode5 & XCode6 do not support OpenMP, Xcode4 is OK.
osx = tuple([int(i) for i in platform.mac_ver()[0].split(".")])
if osx >= (10, 8):
logger.warning("OpenMP support ignored. Your platform does not support it.")
use_openmp = False
# Remove attributes used by distutils parsing
# use 'use_openmp' instead
del self.no_openmp
del self.openmp
self.use_openmp = use_openmp
def finalize_cython_options(self, min_version=None):
"""
Check if cythonization must be used for the extensions.
The result is stored into the object.
"""
if self.force_cython:
use_cython = "force"
elif self.no_cython:
use_cython = "no"
else:
env_force_cython = self._parse_env_as_bool("FORCE_CYTHON")
env_with_cython = self._parse_env_as_bool("WITH_CYTHON")
if env_force_cython is True:
use_cython = "force"
elif env_with_cython is True:
use_cython = "yes"
elif env_with_cython is False:
use_cython = "no"
else:
# Use it by default
use_cython = "yes"
if use_cython in ["force", "yes"]:
try:
import Cython.Compiler.Version
if min_version and Cython.Compiler.Version.version < min_version:
msg = "Cython version is too old. At least version is %s \
expected. Cythonization is skipped."
logger.warning(msg, str(min_version))
use_cython = "no"
except ImportError:
msg = "Cython is not available. Cythonization is skipped."
logger.warning(msg)
use_cython = "no"
# Remove attribute used by distutils parsing
# use 'use_cython' and 'force_cython' instead
del self.no_cython
self.force_cython = use_cython == "force"
self.use_cython = use_cython in ["force", "yes"]
################################################################################
# Debian source tree
################################################################################
......@@ -350,14 +248,13 @@ class sdist_debian(sdist):
@staticmethod
def get_debian_name():
import version
name = "%s_%s" % (PROJECT, version.debianversion)
import tomoscan.version
name = "%s_%s" % (PROJECT, tomoscan.version.debianversion)
return name
def prune_file_list(self):
sdist.prune_file_list(self)
to_remove = ["doc/build", "doc/pdf", "doc/html", "pylint", "epydoc"]
print("Removing files for debian")
for rm in to_remove:
self.filelist.exclude_pattern(pattern="*", anchor=False, prefix=rm)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment