<reponame>erisyon/plaster
# python setup.py build_ext --inplace

import importlib
import os
import pathlib

from setuptools import Extension, setup
from setuptools.command.build_ext import build_ext as build_ext_orig

# The directory containing this file
HERE = pathlib.Path(__file__).parent

# The text of the README file
README = (HERE / "README.md").read_text()

exec(open("plaster/version.py").read())

# Custom extension logic copied from https://stackoverflow.com/a/48015772
class PlasterCExtension(Extension):
    def __init__(self, module):
        self.module = module
        # don't invoke the original build_ext for this special extension
        super().__init__("plaster", sources=[])


class build_ext(build_ext_orig):
    def run(self):
        for ext in self.extensions:
            self.build_plaster_c(ext)
        super().run()

    def build_plaster_c(self, ext):
        if isinstance(ext, PlasterCExtension):
            cwd = pathlib.Path().absolute()

            ext_file = pathlib.Path(self.get_ext_fullpath(ext.name))
            # This is necessary to trick build_ext into doing the right thing
            ext_file.mkdir(parents=True, exist_ok=True)
            extdir = ext_file.parent
            extdir.mkdir(parents=True, exist_ok=True)

            # The directory where all output files need to go appears to be:
            output_dir = extdir.absolute()

            # The source directory appears to be the cwd in this context
            source_dir = cwd

            build_mod = importlib.import_module(f"{ext.module}.build")
            build_mod.build(source_dir=source_dir, output_dir=output_dir, force=True)


setup(
    name="erisyonplaster",
    version=__version__,
    description="Erisyon's Fluoro-Sequencing Platform",
    long_description=README,
    long_description_content_type="text/markdown",
    url="https://github.com/erisyon/plaster",
    author="Erisyon",
    author_email="<EMAIL>",
    license="MIT",
    classifiers=[
        "Intended Audience :: Science/Research",
        "License :: OSI Approved :: MIT License",
        "Topic :: Scientific/Engineering :: Bio-Informatics",
        "Programming Language :: Python :: 3",
        "Programming Language :: Python :: 3.7",
    ],
    packages=["plaster"],
    include_package_data=True,
    install_requires=[
        "arrow",
        "bokeh",
        "ipython",
        "jupyter",
        "munch",
        "nbstripout",
        "nptyping",
        "numpy",
        "opencv-python",
        "pandas",
        "plumbum",
        # see the comment in plaster/plaster/run/sigproc_v2/synth.py for why this is commented out
        # "psf",
        "psutil",
        "pudb",
        "pyyaml",
        "requests",
        "retrying",
        "scikit-image",
        "scikit-learn",
        "twine",
        "wheel",
        "zbs.zest",
    ],
    python_requires=">=3.6",
    ext_modules=[
        PlasterCExtension("plaster.run.nn_v2.c"),
        PlasterCExtension("plaster.run.sigproc_v2.c_gauss2_fitter"),
        PlasterCExtension("plaster.run.sigproc_v2.c_radiometry"),
        PlasterCExtension("plaster.run.sigproc_v2.c_peak_find"),
        PlasterCExtension("plaster.run.survey_v2.c"),
        PlasterCExtension("plaster.run.sim_v2.c_dytsim"),
        PlasterCExtension("plaster.run.sim_v2.c_radsim"),
        PlasterCExtension("plaster.run.prep.c"),
    ],
    cmdclass={"build_ext": build_ext,},
)

# python setup.py build_ext --inplace

import importlib
import os
import pathlib

from setuptools import Extension, setup
from setuptools.command.build_ext import build_ext as build_ext_orig

# The directory containing this file
HERE = pathlib.Path(__file__).parent

# The text of the README file
README = (HERE / "README.md").read_text()

exec(open("plaster/version.py").read())

# Custom extension logic copied from https://stackoverflow.com/a/48015772
class PlasterCExtension(Extension):
    def __init__(self, module):
        self.module = module
        # don't invoke the original build_ext for this special extension
        super().__init__("plaster", sources=[])


class build_ext(build_ext_orig):
    def run(self):
        for ext in self.extensions:
            self.build_plaster_c(ext)
        super().run()

    def build_plaster_c(self, ext):
        if isinstance(ext, PlasterCExtension):
            cwd = pathlib.Path().absolute()

            ext_file = pathlib.Path(self.get_ext_fullpath(ext.name))
            # This is necessary to trick build_ext into doing the right thing
            ext_file.mkdir(parents=True, exist_ok=True)
            extdir = ext_file.parent
            extdir.mkdir(parents=True, exist_ok=True)

            # The directory where all output files need to go appears to be:
            output_dir = extdir.absolute()

            # The source directory appears to be the cwd in this context
            source_dir = cwd

            build_mod = importlib.import_module(f"{ext.module}.build")
            build_mod.build(source_dir=source_dir, output_dir=output_dir, force=True)


setup(
    name="erisyonplaster",
    version=__version__,
    description="Erisyon's Fluoro-Sequencing Platform",
    long_description=README,
    long_description_content_type="text/markdown",
    url="https://github.com/erisyon/plaster",
    author="Erisyon",
    author_email="<EMAIL>",
    license="MIT",
    classifiers=[
        "Intended Audience :: Science/Research",
        "License :: OSI Approved :: MIT License",
        "Topic :: Scientific/Engineering :: Bio-Informatics",
        "Programming Language :: Python :: 3",
        "Programming Language :: Python :: 3.7",
    ],
    packages=["plaster"],
    include_package_data=True,
    install_requires=[
        "arrow",
        "bokeh",
        "ipython",
        "jupyter",
        "munch",
        "nbstripout",
        "nptyping",
        "numpy",
        "opencv-python",
        "pandas",
        "plumbum",
        # see the comment in plaster/plaster/run/sigproc_v2/synth.py for why this is commented out
        # "psf",
        "psutil",
        "pudb",
        "pyyaml",
        "requests",
        "retrying",
        "scikit-image",
        "scikit-learn",
        "twine",
        "wheel",
        "zbs.zest",
    ],
    python_requires=">=3.6",
    ext_modules=[
        PlasterCExtension("plaster.run.nn_v2.c"),
        PlasterCExtension("plaster.run.sigproc_v2.c_gauss2_fitter"),
        PlasterCExtension("plaster.run.sigproc_v2.c_radiometry"),
        PlasterCExtension("plaster.run.sigproc_v2.c_peak_find"),
        PlasterCExtension("plaster.run.survey_v2.c"),
        PlasterCExtension("plaster.run.sim_v2.c_dytsim"),
        PlasterCExtension("plaster.run.sim_v2.c_radsim"),
        PlasterCExtension("plaster.run.prep.c"),
    ],
    cmdclass={"build_ext": build_ext,},
)
# python setup.py build_ext --inplace # The directory containing this file # The text of the README file # Custom extension logic copied from https://stackoverflow.com/a/48015772 # don't invoke the original build_ext for this special extension # This is necessary to trick build_ext into doing the right thing # The directory where all output files need to go appears to be: # The source directory appears to be the cwd in this context # see the comment in plaster/plaster/run/sigproc_v2/synth.py for why this is commented out # "psf",