Skip to content

Commit 46c5d1e

Browse files
committed
Add support for setting dependency version to same version as self
1 parent 0be35e3 commit 46c5d1e

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

robotpy_build/config/pyproject_toml.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -371,7 +371,8 @@ class Config:
371371
license: str
372372

373373
#: A string or list of strings specifying what other distributions need
374-
#: to be installed when this one is.
374+
#: to be installed when this one is. If the requirement is ``==THIS_VERSION``,
375+
#: the requirement is set to be the same version as this package
375376
install_requires: List[str]
376377

377378

robotpy_build/setup.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,11 +123,23 @@ def prepare(self):
123123
# get_version expects the directory to exist
124124
base_package_path = self.base_package_path
125125
os.makedirs(base_package_path, exist_ok=True)
126-
self.setup_kwargs["version"] = get_version(
126+
this_version = get_version(
127127
write_to=join(base_package_path, "version.py"),
128128
fallback_version="master",
129129
search_parent_directories=True,
130130
)
131+
self.setup_kwargs["version"] = this_version
132+
133+
# Support ==THIS_VERSION
134+
install_requires = self.setup_kwargs.get("install_requires")
135+
if install_requires:
136+
137+
def _xform(v: str):
138+
if v.endswith("==THIS_VERSION"):
139+
v = f"{v[:-14]}=={this_version}"
140+
return v
141+
142+
self.setup_kwargs["install_requires"] = list(map(_xform, install_requires))
131143

132144
self.pkgcfg = PkgCfgProvider()
133145

0 commit comments

Comments
 (0)