Skip to content

Commit 9f28794

Browse files
committed
Change versioning policy to avoid .dev versions.
It is no longer possible to write half-open version constraints with packages that publish `.dev` versions. Since that was a misuse of `.dev` versions anyway, stop doing that. See also pypa/setuptools#3807.
1 parent 8d4ef82 commit 9f28794

File tree

2 files changed

+25
-12
lines changed

2 files changed

+25
-12
lines changed

README.rst

+11
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,17 @@ The Amaranth HDL Yosys wheels provide a specialized `WebAssembly <https://webass
77

88
Although this package is platform-independent, it depends on wasmtime-py wheels, which are currently available only for x86_64 Windows, Linux, and macOS. This is expected to improve in the future.
99

10+
Versioning
11+
==========
12+
13+
The version of this package (which is derived from the upstream Yosys package version) is comprised of five parts in a ``X.Y.Z.N.postM`` format:
14+
15+
1. ``X``: Yosys major version
16+
2. ``Y``: Yosys minor version
17+
3. ``Z``: Yosys patch version; only present for some Yosys releases, zero if not present
18+
4. ``N``: Yosys node version; only present for unreleased Yosys snapshots (where it matches the ``N`` in the ``X.Y+N`` upstream version), zero for releases
19+
5. ``postM``: package version, monotonically incrementing from the initial commit
20+
1021
Building
1122
========
1223

setup.py

+14-12
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,25 @@
1+
import re
12
import subprocess
2-
from setuptools import setup, find_packages
3+
from setuptools import setup
34
from setuptools_scm.git import parse as parse_git
45

56

67
def version():
7-
yosys_makefile_ver = subprocess.check_output([
8+
yosys_version_raw = subprocess.check_output([
89
"make", "-s", "-C", "yosys-src", "echo-yosys-ver"
9-
], encoding="utf-8").strip().split("+")
10-
if len(yosys_makefile_ver) == 1:
11-
yosys_version = yosys_makefile_ver[0]
12-
elif len(yosys_makefile_ver) == 2:
13-
yosys_version = f"{yosys_makefile_ver[0]}.post{yosys_makefile_ver[1]}"
14-
else:
15-
assert False
10+
], encoding="utf-8").strip()
1611

17-
package_git = parse_git(".")
18-
package_version = package_git.format_with(".dev{distance}")
12+
# Yosys can't figure out if it should have a patch version or not.
13+
# Match one, and add one below in our version just in case.
14+
yosys_version = re.match(r"^(\d+)\.(\d+)(?:\.(\d+))?(?:\+(\d+))?$", yosys_version_raw)
1915

20-
return yosys_version + package_version
16+
yosys_major = yosys_version[1]
17+
yosys_minor = yosys_version[2]
18+
yosys_patch = yosys_version[3] or "0"
19+
yosys_node = yosys_version[4] or "0"
20+
git_distance = parse_git(".").format_with("post{distance}")
21+
22+
return ".".join([yosys_major, yosys_minor, yosys_patch, yosys_node, git_distance])
2123

2224

2325
setup(

0 commit comments

Comments
 (0)