|
@@ -1,55 +1,60 @@
|
|
|
# -*- coding: utf-8 -*-
|
|
|
import numpy
|
|
|
-from os.path import join, dirname
|
|
|
+import os
|
|
|
+from os.path import dirname, join, splitext
|
|
|
from setuptools import Extension, setup
|
|
|
-from Cython.Build import cythonize #must be after setuptools
|
|
|
|
|
|
-#------------------------------------------------------------------------------
|
|
|
-EXT_NAME = 'yaflpy'
|
|
|
+try:
|
|
|
+ from Cython.Build import cythonize
|
|
|
+except ImportError:
|
|
|
+ cythonize = None
|
|
|
|
|
|
-setup_dir = dirname(__file__)
|
|
|
-src_dir = join(setup_dir, 'src')
|
|
|
-ext_dir = join(src_dir, EXT_NAME)
|
|
|
+# https://cython.readthedocs.io/en/latest/src/userguide/source_files_and_compilation.html#distributing-cython-modules
|
|
|
+def no_cythonize(extensions, **_ignore):
|
|
|
+ for extension in extensions:
|
|
|
+ sources = []
|
|
|
+ for sfile in extension.sources:
|
|
|
+ path, ext = splitext(sfile)
|
|
|
+ if ext in (".pyx", ".py"):
|
|
|
+ if extension.language == "c++":
|
|
|
+ ext = ".cpp"
|
|
|
+ else:
|
|
|
+ ext = ".c"
|
|
|
+ sfile = path + ext
|
|
|
+ sources.append(sfile)
|
|
|
+ extension.sources[:] = sources
|
|
|
+ return extensions
|
|
|
+
|
|
|
+EXT_NAME = "yaflpy"
|
|
|
+SETUP_DIR = dirname(__file__)
|
|
|
+SRC_DIR = join(SETUP_DIR, "src")
|
|
|
+EXT_DIR = join(SRC_DIR, EXT_NAME)
|
|
|
|
|
|
extensions = [
|
|
|
- Extension(EXT_NAME, [join(ext_dir, EXT_NAME + '.pyx')],
|
|
|
- include_dirs=[numpy.get_include(), src_dir, ext_dir],
|
|
|
+ Extension(EXT_NAME, [join(EXT_DIR, EXT_NAME + ".pyx")],
|
|
|
+ include_dirs=[numpy.get_include(), SRC_DIR, EXT_DIR],
|
|
|
define_macros=[("NPY_NO_DEPRECATED_API", "NPY_1_7_API_VERSION")])
|
|
|
]
|
|
|
|
|
|
-#------------------------------------------------------------------------------
|
|
|
-deps = ['Cython', 'numpy', 'scipy', 'setuptools']
|
|
|
+CYTHONIZE = bool(int(os.getenv("CYTHONIZE", 0))) and cythonize is not None
|
|
|
+
|
|
|
+if CYTHONIZE:
|
|
|
+ compiler_directives = {"language_level": 3, "embedsignature": True}
|
|
|
+ extensions = cythonize(extensions, compiler_directives=compiler_directives)
|
|
|
+else:
|
|
|
+ extensions = no_cythonize(extensions)
|
|
|
+
|
|
|
+with open("requirements.txt") as fp:
|
|
|
+ install_requires = fp.read().strip().split("\n")
|
|
|
+
|
|
|
+with open("requirements-dev.txt") as fp:
|
|
|
+ dev_requires = fp.read().strip().split("\n")
|
|
|
|
|
|
-#------------------------------------------------------------------------------
|
|
|
setup(
|
|
|
- name="yaflpy",
|
|
|
- version = '0.1.0',
|
|
|
- description = ['Yet Another Filtering Library'],
|
|
|
- long_description = open(join(setup_dir, 'Readme.md')).read(),
|
|
|
- long_description_content_type = 'text/markdown',
|
|
|
- license = 'Apache License, Version 2.0',
|
|
|
- license_file = join(setup_dir, 'LICENSE'),
|
|
|
- author = 'anonimous',
|
|
|
- author_email = 'shkolnick-kun@gmail.com',
|
|
|
- url = 'https://github.com/shkolnick-kun/yafl',
|
|
|
- classifiers = [
|
|
|
- 'Development Status :: 3 - Alpha',
|
|
|
- 'Topic :: Software Development :: Embedded Systems',
|
|
|
- 'Intended Audience :: Science/Research',
|
|
|
- 'License :: OSI Approved :: Apache Software License',
|
|
|
- 'Programming Language :: Python :: 3',
|
|
|
- 'Programming Language :: Python :: 3.3',
|
|
|
- 'Programming Language :: Python :: 3.4',
|
|
|
- 'Programming Language :: Python :: 3.5',
|
|
|
- 'Programming Language :: Python :: 3.6',
|
|
|
- 'Programming Language :: Python :: 3.7',
|
|
|
- 'Programming Language :: Python :: 3.8',
|
|
|
- 'Programming Language :: Python :: 3.9',
|
|
|
- ],
|
|
|
- setup_requires=deps,
|
|
|
- install_requires=deps,
|
|
|
- python_requires='>=3',
|
|
|
- platforms = ['any'],
|
|
|
- ext_modules = cythonize(extensions,
|
|
|
- compiler_directives={'language_level' : '3'})
|
|
|
+ ext_modules=extensions,
|
|
|
+ install_requires=install_requires,
|
|
|
+ extras_require={
|
|
|
+ "dev": dev_requires,
|
|
|
+ "docs": ["sphinx", "sphinx-rtd-theme"]
|
|
|
+ },
|
|
|
)
|