-
Notifications
You must be signed in to change notification settings - Fork 2
/
setup.py
31 lines (27 loc) · 1.04 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
#!/usr/bin/env python
import sys
from os import getenv
from shutil import which
from setuptools import find_packages, setup
from setuptools_rust import RustExtension
if __name__ == "__main__":
if "sdist" not in sys.argv and which("cargo") is None:
raise FileNotFoundError(f"Rust not found, visit https://rustup.rs for installation instructions")
ref_name = getenv("GITHUB_REF_NAME")
if getenv("GITHUB_REF", "").startswith("refs/tags/") and ref_name:
from pkg_resources import parse_version
try:
parse_version(ref_name)
print(f"injecting version = {ref_name} into setup.cfg")
with open("setup.cfg", "r") as f:
lines = f.readlines()
with open("setup.cfg", "w") as f:
for line in lines:
if line.startswith("version = "):
line = f"version = {ref_name}\n"
f.write(line)
except Exception:
pass
setup(
rust_extensions=[RustExtension("icicle.icicle")],
)