-
Notifications
You must be signed in to change notification settings - Fork 27
/
setup.py
89 lines (75 loc) · 2.59 KB
/
setup.py
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
import os
import re
import sys
import numpy
from setuptools import find_packages, setup
from setuptools.extension import Extension
try:
from pip._internal.req import parse_requirements
except ImportError:
from pip.req import parse_requirements
from Cython.Build import cythonize
# Giant hack to enable legacy code for CI
_build_legacy_extension = os.environ.get("BUILD_LEGACY_IPIE", False)
if _build_legacy_extension:
extensions = [
Extension(
"ipie.legacy.estimators.ueg_kernels",
["ipie/legacy/estimators/ueg_kernels.pyx"],
extra_compile_args=["-O3"],
include_dirs=[numpy.get_include()],
),
]
cythonized_extension = cythonize(
extensions,
include_path=[numpy.get_include()],
compiler_directives={"language_level": sys.version_info[0]},
)
else:
extensions = []
cythonized_extension = []
def load_requirements(fname):
reqs = parse_requirements(fname, session="test")
try:
return [str(ir.req) for ir in reqs]
except AttributeError:
return [str(ir.requirement) for ir in reqs]
def version_number(path: str) -> str:
"""Get the version number from the src directory"""
exp = r'__version__[ ]*=[ ]*["|\']([\d]+\.[\d]+\.[\d]+[\.dev[\d]*]?)["|\']'
version_re = re.compile(exp)
with open(path, "r") as f:
version = version_re.search(f.read()).group(1)
return version
def main() -> None:
version_path = "ipie/_version.py"
__version__ = version_number(version_path)
if __version__ is None:
raise ValueError("Version information not found in " + version_path)
setup(
name="ipie",
version=__version__,
author="ipie developers",
url="http://github.com/linusjoonho/ipie",
packages=find_packages(exclude=["examples", "docs", "tests", "tools", "setup.py"]),
license="Apache 2.0",
description="Python implementations of Imaginary-time Evolution algorithms",
python_requires=">=3.8.0",
scripts=[
"bin/ipie",
"tools/extract_dice.py",
"tools/reblock.py",
"tools/fcidump_to_afqmc.py",
"tools/pyscf/pyscf_to_ipie.py",
],
ext_modules=cythonized_extension,
install_requires=load_requirements("requirements.txt"),
extras_require={
"mpi": load_requirements("dev/mpi.txt"),
"dev": load_requirements("dev/dev.txt"),
"torch": load_requirements("dev/torch.txt"),
},
long_description=open("README.rst").read(),
)
if __name__ == "__main__":
main()