Skip to content
Snippets Groups Projects
setup.py 5.76 KiB
Newer Older
from distutils.command.build import build
from subprocess import check_output
Cyril Danilevski's avatar
Cyril Danilevski committed

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 = [
        "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", "")
Cyril Danilevski's avatar
Cyril Danilevski committed
        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", [])
Karim Ahmed's avatar
Karim Ahmed committed
        data_files += nb.get("pre_notebooks", [])
data_files = list(filter(None, data_files))  # Get rid of `None` entries

install_requires = [
        "Cython==3.0.8",
        "Jinja2==3.1.3",
        "astcheck==0.4.0",
        "calibration_client==11.3.0",
        "dill==0.3.8",
        "docutils==0.20.1",
        "dynaconf==3.2.4",
        "dynflatfield==1.0.0",
        "extra_data==1.16.0",
        "extra_geom==1.11.0",
        "gitpython==3.1.42",
        "h5py==3.10.0",
        "ipykernel==6.29.3",
        "ipyparallel==8.6.1",
        "ipython==8.22.1",
        "jupyter-core==5.7.1",
        "jupyter_client==8.6.0",
        "jupyter_console==6.6.3",
        "kafka-python==2.0.2",
        "lxml==5.1.0",
        "markupsafe==2.1.5",
        "matplotlib==3.8.3",
        "nbclient==0.9.0",
        "nbconvert==7.16.1",
        "nbformat==5.9.2",
        "nbparameterise==0.6",
Egor Sobolev's avatar
Egor Sobolev committed
        "pillow==10.3.0",
        "prettytable==3.10.0",
        "princess==0.6",
        "pymunge==0.1.3",
        "pypandoc==1.13",
        "python-dateutil==2.8.2",
        "pyyaml==6.0.1",
        "pyzmq==25.1.2",
        "requests==2.29.0",
        "scikit-learn==1.4.1.post1",
        "scipy==1.12.0",
        "sphinx==7.2.6",
        "tabulate==0.9.0",
        "traitlets==5.14.1",
        "xarray==2024.2.0",
        "EXtra-redu==0.0.8",
        "rich==13.7.0",
        "httpx==0.27.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.3",  # noqa
        "XFELDetectorAnalysis @ git+ssh://git@git.xfel.eu:10022/karaboDevices/pyDetLib.git@7f79b825cf0a881d4126f2aab4d248cc55da0298",  # noqa
Karim Ahmed's avatar
Karim Ahmed committed
        "CalParrot @ git+ssh://git@git.xfel.eu:10022/calibration/calparrot.git@0.3",  # noqa
        # iminuit 1.3.8 is compatible with Python 3.11, but there isn't a 3.11
        # wheel on PyPI, and building directly from source doesn't work.
        "iminuit @ https://git.xfel.eu/api/v4/projects/4538/packages/generic/iminuit/1.3.8/iminuit-1.3.8-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl",  # 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",
Karim Ahmed's avatar
Karim Ahmed committed
            "nbval",
            "pytest-asyncio",
            "pytest-cov",
            "pytest-subprocess",
            "pytest>=5.4.0",
            "testpath",
            "unittest-xml-reporting==3.2.0",
Karim Ahmed's avatar
Karim Ahmed committed
        ],
        "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",
    ],