-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.py
More file actions
25 lines (21 loc) · 729 Bytes
/
setup.py
File metadata and controls
25 lines (21 loc) · 729 Bytes
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
#!/usr/bin/env python
# Based on: https://stackoverflow.com/a/62983901/1806760
import setuptools
import os
if __name__ == "__main__":
ref_name = os.getenv("GITHUB_REF_NAME")
if 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:
pass
setuptools.setup()