File: setup.py

package info (click to toggle)
python-pot 0.9.5%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 3,884 kB
  • sloc: python: 56,498; cpp: 2,310; makefile: 265; sh: 19
file content (137 lines) | stat: -rw-r--r-- 4,687 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
#!/usr/bin/env python

# Author: Remi Flamary <remi.flamary@polytechnique.edu>
#
# License: MIT License

import os
import re
import subprocess
import sys

from setuptools import find_packages, setup
from setuptools.extension import Extension

import numpy
from Cython.Build import cythonize

sys.path.append(os.path.join("ot", "helpers"))
from openmp_helpers import check_openmp_support

# dirty but working
__version__ = re.search(
    r'__version__\s*=\s*[\'"]([^\'"]*)[\'"]',  # It excludes inline comment too
    open("ot/__init__.py").read(),
).group(1)
# The beautiful part is, I don't even need to check exceptions here.
# If something messes up, let the build process fail noisy, BEFORE my release!

# thanks PyPI for handling markdown now
ROOT = os.path.abspath(os.path.dirname(__file__))
with open(os.path.join(ROOT, "README.md"), encoding="utf-8") as f:
    README = f.read()

# clean cython output is clean is called
if "clean" in sys.argv[1:]:
    if os.path.isfile("ot/lp/emd_wrap.cpp"):
        os.remove("ot/lp/emd_wrap.cpp")

# add platform dependant optional compilation argument
openmp_supported, flags = check_openmp_support()
compile_args = ["/O2" if sys.platform == "win32" else "-O3"]
link_args = []

if openmp_supported:
    compile_args += flags
    link_args += flags

if sys.platform.startswith("darwin"):
    compile_args.append("-stdlib=libc++")
    sdk_path = subprocess.check_output(["xcrun", "--show-sdk-path"])
    os.environ["CFLAGS"] = '-isysroot "{}"'.format(sdk_path.rstrip().decode("utf-8"))


setup(
    name="POT",
    version=__version__,
    description="Python Optimal Transport Library",
    long_description=README,
    long_description_content_type="text/markdown",
    author="Remi Flamary, Nicolas Courty, Cédric Vincent-Cuaz, POT Contributors",
    author_email="remi.flamary@gmail.com, ncourty@gmail.com, cedvincentcuaz@gmail.com",
    url="https://github.com/PythonOT/POT",
    packages=find_packages(exclude=["benchmarks"]),
    ext_modules=cythonize(
        Extension(
            name="ot.lp.emd_wrap",
            sources=[
                "ot/lp/emd_wrap.pyx",
                "ot/lp/EMD_wrapper.cpp",
            ],  # cython/c++ src files
            language="c++",
            include_dirs=[numpy.get_include(), os.path.join(ROOT, "ot/lp")],
            extra_compile_args=compile_args,
            extra_link_args=link_args,
        )
    ),
    platforms=["linux", "macosx", "windows"],
    download_url="https://github.com/PythonOT/POT/archive/{}.tar.gz".format(
        __version__
    ),
    license="MIT",
    scripts=[],
    data_files=[],
    install_requires=["numpy>=1.16", "scipy>=1.6"],
    extras_require={
        "backend-numpy": [],  # in requirements.
        "backend-jax": ["jax", "jaxlib"],
        "backend-cupy": [],  # should be installed with conda, not pip
        "backend-tf": ["tensorflow"],
        "backend-torch": ["torch"],
        "cvxopt": ["cvxopt"],  # on it's own to prevent accidental GPL violations
        "dr": ["scikit-learn", "pymanopt", "autograd"],
        "gnn": ["torch", "torch_geometric"],
        "plot": ["matplotlib"],
        "all": [
            "jax",
            "jaxlib",
            "tensorflow",
            "torch",
            "cvxopt",
            "scikit-learn",
            "pymanopt",
            "autograd",
            "torch_geometric",
            "matplotlib",
        ],
    },
    python_requires=">=3.7",
    classifiers=[
        "Development Status :: 5 - Production/Stable",
        "Intended Audience :: Developers",
        "Intended Audience :: Education",
        "Intended Audience :: Science/Research",
        "License :: OSI Approved :: MIT License",
        "Environment :: Console",
        "Operating System :: OS Independent",
        "Operating System :: POSIX :: Linux",
        "Operating System :: MacOS",
        "Operating System :: POSIX",
        "Operating System :: Microsoft :: Windows",
        "Programming Language :: Python",
        "Programming Language :: C++",
        "Programming Language :: C",
        "Programming Language :: Cython",
        "Topic :: Utilities",
        "Topic :: Scientific/Engineering :: Artificial Intelligence",
        "Topic :: Scientific/Engineering :: Mathematics",
        "Topic :: Scientific/Engineering :: Information Analysis",
        "Programming Language :: Python :: 3",
        "Programming Language :: Python :: 3.7",
        "Programming Language :: Python :: 3.8",
        "Programming Language :: Python :: 3.9",
        "Programming Language :: Python :: 3.10",
        "Programming Language :: Python :: 3.11",
        "Programming Language :: Python :: 3.12",
    ],
)