diff --git a/galaxy_release_util/point_release.py b/galaxy_release_util/point_release.py index 0e8fcba..4838e28 100644 --- a/galaxy_release_util/point_release.py +++ b/galaxy_release_util/point_release.py @@ -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 @@ -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) @@ -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)