-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.py
85 lines (70 loc) · 2.84 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
import os
import subprocess
import sys
from setuptools import Extension, find_packages, setup
from setuptools.command.build_ext import build_ext
class CMakeExtension(Extension):
def __init__(self, name, cmakelists_dir=".", **kwargs):
super().__init__(name, sources=[], **kwargs)
self.cmakelists_dir = os.path.abspath(cmakelists_dir)
class CmakeBuild(build_ext):
def build_extensions(self) -> None:
try:
subprocess.check_output(["cmake", "--version"])
except OSError:
raise RuntimeError("Cmake not found!")
for ext in self.extensions:
os.path.abspath(os.path.dirname(self.get_ext_fullpath(ext.name)))
build_type = "Debug" if os.environ.get("DEBUG", "OFF") == "ON" else "Release"
cmake_args = [
"-DCMAKE_BUILD_TYPE = %s" % build_type,
"-DCMAKE_EXPORT_COMPILE_COMMANDS=1",
"-DPYTHON_EXECUTABLE={}".format(sys.executable),
]
if not os.path.exists(self.build_temp):
os.makedirs(self.build_temp)
# Config
subprocess.check_call(["cmake", ext.cmakelists_dir] + cmake_args, cwd=self.build_temp)
# Build
subprocess.check_call(["cmake", "--build", ".", "--config", build_type], cwd=self.build_temp)
with open("VERSION", "r") as f:
version = f.read().strip()
with open("requirements.txt", "r") as f:
required = f.read().splitlines()
setup_info = {
"name": "lmptools",
"packages": find_packages(exclude=["tests"]),
"version": version,
"maintainer": "Venkat Bala",
"url": "https://github.com/venkatBala/lmptools",
"license": "MIT License",
"author": "Venkat Bala",
"author_email": "[email protected]",
"description": """lmptools is python module to facilitate post
processing of LAMMPS simulation output files""",
"long_description": open("README.md").read(),
"long_description_content_type": "text/markdown",
"include_package_data": True,
"zip_safe": False,
"install_requires": required,
"classifiers": [
"Development Status :: 4 - Beta",
"Environment :: Console",
"Intended Audience :: Developers",
"Intended Audience :: Education",
"Intended Audience :: Science/Research",
"Natural Language :: English",
"Operating System :: MacOS :: MacOS X",
"Operating System :: POSIX",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3 :: Only",
"Programming Language :: Python :: 3.9",
"Topic :: Adaptive Technologies",
"Topic :: Scientific/Engineering",
"Topic :: System :: Distributed Computing",
],
"ext_modules": [CMakeExtension(name="lmptools_")],
"cmdclass": {"build_ext": CmakeBuild},
}
if __name__ == "__main__":
setup(**setup_info)