-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup.py
125 lines (110 loc) · 3.85 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
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
import os
import sys
import subprocess
import shutil
from setuptools import setup, find_packages
from setuptools.command.install import install
# This is an option for the future, BFT does not work in parallel for now.
# Parallel modes will be added soon...
PARALLEL = False
if "--parallel" in sys.argv:
PARALLEL = True
sys.argv.remove("--parallel")
BANNER = r"""
_______ _______ ___________
| _ "\ /" "| (" _ ")
(. |_) :) (: ______) )__/ \\__/
|: \/ \/ | \\_ /
(| _ \\ // ___) |. |
|: |_) :) (: ( \: |
(_______/ \__/ \__|
BFP Installation
"""
class CustomInstallCommand(install):
def run(self):
print(BANNER)
cwd = os.getcwd()
dependencies = [
"numpy>=1.20.0,<2.0.0",
"numba",
"numba-scipy",
"scipy",
"swig>=4.2.1",
"cmake",
"anywidget>=0.9.9",
"ipywidgets>=8.0.0",
"requests",
"h5py",
"seaborn",
"pandas"
]
print("Installing dependencies...")
for dep in dependencies:
subprocess.check_call([sys.executable, "-m", "pip", "install", dep])
# PyMFEM
pymfem_dir = os.path.join(cwd, "PyMFEM")
if os.path.exists(pymfem_dir):
print("PyMFEM directory already exists. Skipping clone...")
print("Cloning PyMFEM repository...")
subprocess.check_call(["git", "clone", "https://github.com/melekderman/PyMFEM.git", pymfem_dir])
os.chdir(pymfem_dir)
try:
if PARALLEL:
print("Installing PyMFEM (parallel mode)...")
subprocess.check_call([sys.executable, "setup.py", "install", "--with-parallel"])
else:
print("Installing PyMFEM (serial mode)...")
subprocess.check_call([sys.executable, "setup.py", "install"])
except subprocess.CalledProcessError as e:
print("PyMFEM installation failed:", e)
sys.exit(1)
finally:
os.chdir(cwd)
print("Cleaning up PyMFEM directory...")
shutil.rmtree(pymfem_dir)
# PyGLVis
pyglvis_dir = os.path.join(cwd, "PyGLVis")
if os.path.exists(pyglvis_dir):
print("PyGLVis directory already exists. Skipping clone...")
print("Cloning pyglvis repository...")
subprocess.check_call(["git", "clone", "https://github.com/melekderman/pyglvis.git", pyglvis_dir])
os.chdir(pyglvis_dir)
try:
print("Installing pyglvis...")
subprocess.check_call([sys.executable, "-m", "pip", "install", "."])
except subprocess.CalledProcessError as e:
print("pyglvis installation failed:", e)
sys.exit(1)
finally:
os.chdir(cwd)
print("Cleaning up pyglvis directory...")
shutil.rmtree(pyglvis_dir)
# Finally, install the main package
install.run(self)
setup(
name="BFP",
version="0.0.1",
packages=find_packages(),
include_package_data=True,
description="BFP: A Boltzmann Fokker-Planck charged particle transport solver integrating with PyMFEM",
long_description=open("README.md", encoding="utf-8").read() if os.path.exists("README.md") else "",
long_description_content_type="text/markdown",
install_requires=[
"numpy>=1.20.0,<2.0.0",
"numba",
"numba-scipy",
"scipy",
"swig>=4.2.1",
"cmake",
"anywidget>=0.9.9",
"ipywidgets>=8.0.0",
"requests",
"h5py",
"seaborn"
"pandas",
],
author="Melek Derman",
author_email="dermanm@oregonstate.edu",
url="https://github.com/melekderman/BFP",
cmdclass={'install': CustomInstallCommand},
)