-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup.py
39 lines (31 loc) · 1.02 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
from setuptools import setup, find_packages
from subprocess import Popen
import shutil
import os
import sys
# key = module name (the exact name of the cargo project)
# val = destination of the generated shared object
# header files must have the same name as the module and be present in the root
# of the Rust project dir
rust_modules = {
"triangular_lattice_ext": "models",
}
def build_rust_binary(lib, dest_dir):
os.chdir("rust/{}".format(lib))
p = Popen(["cargo", "build", "--release"])
p.wait()
if p.returncode != 0:
sys.exit("Cargo build failure. Abort.")
os.chdir("../..")
if shutil.which("cargo"):
for lib, dest_dir in rust_modules.items():
build_rust_binary(lib, dest_dir)
else:
print("Cargo not found in path. Continue without building Rust modules.")
print("Note: The Rust-based functions will not be available.")
setup(
name="spinsys",
packages=find_packages(),
install_requires=['numpy>=1.8', 'scipy>=0.13', 'cffi>=1.11'],
include_package_data=True,
)