-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.py
58 lines (47 loc) · 1.64 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
from setuptools import setup, find_packages
from setuptools.command.install import install
import subprocess
import os
def read_requirements():
"""Read the contents of the requirements.txt file and add 'rust_aha_formulas'."""
with open("requirements.txt") as f:
requirements = f.read().splitlines()
return requirements
class CustomInstallCommand(install):
def run(self):
# Build the Rust project to a wheel using Maturin
subprocess.check_call(
["maturin", "build", "--release", "--out", "../target/wheels"]
)
# Find the built wheel and install it
wheel_name = next(
w
for w in os.listdir("../target/wheels")
if "pyprevent" in w and w.endswith(".whl")
)
subprocess.check_call(["pip", "install", f"../target/wheels/{wheel_name}"])
# Navigate back to the Python project directory
os.chdir(
"../../"
) # Adjust this as needed to return to your Python project root
# Run the standard setuptools install
install.run(self)
with open("README.md", encoding="utf-8") as f:
long_description = f.read()
setup(
name="pyascvd",
version="0.1.0",
packages=find_packages(),
cmdclass={
"install": CustomInstallCommand,
},
install_requires=read_requirements(),
description="",
long_description=long_description,
long_description_content_type="text/markdown",
url="https://github.com/lhegstrom/PyASCVD/",
project_urls={
"Source": "https://github.com/lhegstrom/PyASCVD/",
"Tracker": "https://github.com/lhegstrom/PyASCVD/issues",
},
)