Skip to content

Commit

Permalink
When bumping the galaxy metapackage, also bump its galaxy-* deps and …
Browse files Browse the repository at this point in the history
…include/update pinned-requirements.txt
  • Loading branch information
natefoo committed Dec 6, 2024
1 parent 14b989d commit 534cd1f
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions galaxy_release_util/point_release.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
"""
RELEASE_BRANCH_REGEX = re.compile(r"^release_(\d{2}\.\d{1,2})$")
FIRST_RELEASE_CHANGELOG_TEXT = "First release"
GALAXY_PACKAGE_DEP_REGEX = re.compile(r"^( galaxy-[^=]+)==.*$")


@dataclass
Expand Down Expand Up @@ -113,6 +114,10 @@ def changelog(self) -> str:
changelog_string = "\n".join(str(h) for h in self.package_history)
return f"{HISTORY_TEMPLATE}{changelog_string}"

@property
def pinned_requirements_txt(self) -> str:
return self.path / ".." / ".." / "lib" / "galaxy" / "dependencies" / "pinned-requirements.txt"

def write_history(self):
self.history_rst.write_text(self.changelog)
self.modified_paths.append(self.history_rst)
Expand Down Expand Up @@ -230,9 +235,30 @@ def add_changelog_item(changes, child):
def bump_package_version(package: Package, new_version: Version):
new_content = []
content = package.setup_cfg.read_text().splitlines()
install_requires = False
requirements_txt = False
for line in content:
if line.startswith("version = "):
line = f"version = {new_version}"
elif line.startswith("install_requires ="):
install_requires = True
elif package.name == "galaxy" and install_requires:
# Update requirements in the galaxy metapackage
if requirements_txt and line.startswith(" "):
continue
if requirements_txt and not line.startswith(" "):
install_requires = False
elif not requirements_txt and line.startswith(" galaxy-"):
match = GALAXY_PACKAGE_DEP_REGEX.match(line)
if match:
line = f"{match.group(1)}=={new_version}"
elif line == " # BEGIN pinned-requirements.txt":
new_content.append(line)
requirements_txt = True
requirements = [f" {x.strip()}" for x in open(package.pinned_requirements_txt).readlines() if
x.strip() and not x.startswith('--')]
new_content.extend(requirements)
continue
new_content.append(line)
package.setup_cfg.write_text("\n".join(new_content))
package.modified_paths.append(package.setup_cfg)
Expand Down

0 comments on commit 534cd1f

Please sign in to comment.