Skip to content

Commit 78c0eca

Browse files
committed
Change Version Setting Mechanism
1 parent a798358 commit 78c0eca

File tree

5 files changed

+34
-12
lines changed

5 files changed

+34
-12
lines changed

.github/scripts/generate_tag.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,26 +14,28 @@
1414
# See the License for the specific language governing permissions and
1515
# limitations under the License.
1616
import os
17+
import subprocess
1718
import sys
1819

1920
from gh import gh
2021

21-
sys.path.insert(0, os.getcwd())
22-
23-
import volare # noqa: E402
22+
version = subprocess.check_output(
23+
[sys.executable, os.path.join("libparse", "__version__.py")],
24+
encoding="utf8",
25+
)
2426

2527
print("Getting tags…")
2628

2729
latest_tag = None
2830
latest_tag_commit = None
29-
tags = [pair[1] for pair in gh.volare.tags]
31+
tags = [pair[1] for pair in gh.libparse.tags]
3032

31-
tag_exists = volare.__version__ in tags
33+
tag_exists = version in tags
3234

3335
if tag_exists:
3436
print("Tag already exists. Leaving NEW_TAG unaltered.")
3537
else:
36-
new_tag = volare.__version__
38+
new_tag = version
3739

3840
print("Found new tag %s." % new_tag)
3941
gh.export_env("NEW_TAG", new_tag)

.github/scripts/gh.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ def export_env_alt(key, value):
120120
export_env = export_env_alt
121121

122122
origin = os.getenv("REPO_URL")
123-
repo = Repo("parselib", origin)
123+
repo = Repo("libparse", origin)
124124

125125
# public
126126
gh = SimpleNamespace(
@@ -134,6 +134,6 @@ def export_env_alt(key, value):
134134
"event": SimpleNamespace(**{"name": os.getenv("GITHUB_EVENT_NAME")}),
135135
"export_env": export_env,
136136
"Repo": Repo,
137-
"parselib": repo,
137+
"libparse": repo,
138138
}
139139
)

libparse/__init__.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1-
from .libparse import *
1+
from .libparse import *
2+
from .__version__ import __version__

libparse/__version__.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
__version__ = "0.2.0"
2+
3+
if __name__ == "__main__":
4+
print(__version__, end="")

setup.py

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#!/usr/bin/env python3
22
import os
3+
import sys
34
import platform
45
import subprocess
56
from setuptools import setup, Extension
@@ -8,6 +9,18 @@
89
module_name = "libparse"
910
__dir__ = os.path.dirname(os.path.abspath(__file__))
1011

12+
version = subprocess.check_output(
13+
[
14+
sys.executable,
15+
os.path.join(
16+
os.path.abspath(__dir__),
17+
module_name,
18+
"__version__.py",
19+
),
20+
],
21+
encoding="utf8",
22+
)
23+
1124
compiler_opts = ["-std=c++11", "-DFILTERLIB"]
1225
if platform.system() == "Windows":
1326
compiler_opts = ["/DFILTERLIB"]
@@ -25,16 +38,18 @@
2538
extra_compile_args=compiler_opts,
2639
)
2740

41+
2842
class build_py(_build_py):
2943
def run(self) -> None:
3044
subprocess.check_call(["make", "patch"], cwd=__dir__)
3145
self.run_command("build_ext")
3246
return super().run()
33-
47+
48+
3449
setup(
3550
name=module_name,
3651
packages=["libparse"],
37-
version="0.2.0",
52+
version=version,
3853
description="Python wrapper around Yosys' libparse module",
3954
long_description=open("Readme.md").read(),
4055
long_description_content_type="text/markdown",
@@ -51,6 +66,6 @@ def run(self) -> None:
5166
python_requires=">3.6",
5267
ext_modules=[ext],
5368
cmdclass={
54-
'build_py': build_py,
69+
"build_py": build_py,
5570
},
5671
)

0 commit comments

Comments
 (0)