import sys from distutils.command.build import build from subprocess import check_output import numpy from Cython.Build import cythonize from setuptools import find_packages, setup from setuptools.extension import Extension from src.xfel_calibrate.notebooks import notebooks ext_modules = [ Extension( "cal_tools.agipdalgs", ["src/cal_tools/agipdalgs.pyx"], include_dirs=[numpy.get_include()], extra_compile_args=["-fopenmp", "-march=native"], extra_link_args=["-fopenmp"], ), Extension( 'cal_tools.lpdalgs', ['src/cal_tools/lpdalgs.pyx'], extra_compile_args=['-O3', '-fopenmp', '-march=native', '-ftree-vectorize', '-frename-registers'], extra_link_args=['-fopenmp'], ), Extension( "cal_tools.gotthard2.gotthard2algs", ["src/cal_tools/gotthard2/gotthard2algs.pyx"], include_dirs=[numpy.get_include()], ), ] class PreInstallCommand(build): """Pre-installation for installation mode.""" def run(self): version = check_output(["git", "describe", "--tag"]).decode("utf8") version = version.replace("\n", "") with open("src/xfel_calibrate/VERSION.py", "w") as file: file.write('__version__="{}"'.format(version)) build.run(self) data_files = [] for ctypes in notebooks.values(): for nb in ctypes.values(): data_files.append(nb.get("notebook")) data_files += nb.get("dep_notebooks", []) data_files += nb.get("pre_notebooks", []) data_files = list(filter(None, data_files)) # Get rid of `None` entries install_requires = [ "Cython==0.29.21", "Jinja2==2.11.2", "markupsafe==2.0.1", "astcheck==0.3.0", "cfelpyutils==2.0.6", "calibration_client==11.2.0", "dill==0.3.0", "docutils==0.17.1", "dynaconf==3.1.4", "env_cache==0.1", "extra_data==1.15.1", "extra_geom==1.10.0", "gitpython==3.1.0", "h5py==3.5.0", "iminuit==1.3.8", "ipykernel==5.1.4", "ipyparallel==6.2.4", "ipython==7.12.0", "ipython_genutils==0.2.0", "jupyter-core==4.10.0", "jupyter_client==7.3.4", "jupyter_console==6.1.0", "kafka-python==2.0.2", "lxml==4.5.0", "markupsafe==2.0.1", "matplotlib==3.4.2", "metadata_client==3.0.8", "nbclient==0.5.1", "nbconvert==5.6.1", "nbformat==5.0.7", "nbparameterise==0.6", "notebook==6.1.5", "numpy==1.20.3", "pasha==0.1.1", "prettytable==0.7.2", "princess==0.5", "pypandoc==1.4", "python-dateutil==2.8.2", "pyyaml==5.3", "pyzmq==23.2.0", "requests==2.22.0", "scikit-learn==0.22.2.post1", "scipy==1.7.0", "sharedmem==0.3.8", "sphinx==1.8.5", "tabulate==0.8.6", "traitlets==4.3.3", "xarray==2022.3.0", "EXtra-redu==0.0.8", "rich==12.6.0", "httpx==0.23.0", ] if "readthedocs.org" not in sys.executable: install_requires += [ "iCalibrationDB @ git+ssh://git@git.xfel.eu:10022/detectors/cal_db_interactive.git@2.4.1", # noqa "XFELDetectorAnalysis @ git+ssh://git@git.xfel.eu:10022/karaboDevices/pyDetLib.git@2.7.0", # noqa "CalParrot @ git+ssh://git@git.xfel.eu:10022/calibration/calparrot.git@0.3", # noqa ] setup( name="European XFEL Offline Calibration", version="1.0", author="Steffen Hauf", author_email="steffen.hauf@xfel.eu", maintainer="EuXFEL Calibration Team", url="", description="", long_description="", long_description_content_type="text/markdown", # TODO: find licence, assuming this will be open sourced eventually license="(c) European XFEL GmbH 2018", packages=find_packages("src"), package_dir={"": "src"}, package_data={ "cal_tools": ["restful_config.yaml"], "xfel_calibrate": [ "bin/*.sh", "titlepage.tmpl", "xfel.pdf", ] + data_files }, entry_points={ "console_scripts": [ "xfel-calibrate = xfel_calibrate.calibrate:run", "xfel-calibrate-repeat = xfel_calibrate.repeat:main", ], }, cmdclass={ "build": PreInstallCommand, }, ext_modules=cythonize(ext_modules, language_level=3), install_requires=install_requires, extras_require={ "docs": [ "nbsphinx", ], "test": [ "coverage", "nbval", "pytest-asyncio", "pytest-cov", "pytest-subprocess", "pytest>=5.4.0", "testpath", "unittest-xml-reporting==3.0.2", ], "automated_test": [ "coverage", "nbval", "pytest-asyncio", "pytest-cov", "pytest-subprocess", "pytest>=5.4.0", "testpath", "unittest-xml-reporting==3.0.2", ], "dev": [ "nbqa[toolchain]", "pre-commit", ], }, python_requires=">=3.8", classifiers=[ "Development Status :: 5 - Production/Stable", "Environment :: Console", "Intended Audience :: Developers", "Intended Audience :: Science/Research", # "License :: OSI Approved :: BSD License", # TODO: put license here "Operating System :: POSIX :: Linux", "Programming Language :: Python :: 3", "Topic :: Scientific/Engineering :: Information Analysis", "Topic :: Scientific/Engineering :: Physics", ], )