Skip to content

Commit ab6f7b8

Browse files
authored
Merge pull request #3325 from PolicyEngine/fix/bump-country-package-pyproject
Fix bump_country_package.py for pyproject.toml migration
2 parents 7071f66 + bebbd5e commit ab6f7b8

3 files changed

Lines changed: 18 additions & 16 deletions

File tree

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Update bump_country_package.py for pyproject.toml migration.

gcp/bump_country_package.py

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -25,22 +25,22 @@ def main():
2525

2626
def bump_country_package(country, version):
2727
time.sleep(60 * 5)
28-
# Update the version in the country package's setup.py
29-
setup_py_path = f"setup.py"
30-
with open(setup_py_path, "r") as f:
31-
setup_py = f.read()
28+
# Update the version in pyproject.toml
29+
pyproject_path = "pyproject.toml"
30+
with open(pyproject_path, "r") as f:
31+
pyproject = f.read()
3232
# Find where it says {country}=={old version} and replace it with {country}=={new version}
3333
country_package_name = country.replace("-", "_")
3434
package_version_regex = rf"{country_package_name}==(\d+\.\d+\.\d+)"
35-
match = re.search(package_version_regex, setup_py)
35+
match = re.search(package_version_regex, pyproject)
3636

3737
# If the line was found, replace it with the new package version
3838
if match:
3939
new_line = f"{country_package_name}=={version}"
40-
setup_py = setup_py.replace(match.group(0), new_line)
41-
# Write setup_py to setup.py
42-
with open(setup_py_path, "w") as f:
43-
f.write(setup_py)
40+
pyproject = pyproject.replace(match.group(0), new_line)
41+
# Write updated pyproject.toml
42+
with open(pyproject_path, "w") as f:
43+
f.write(pyproject)
4444

4545
country_package_full_name = country.replace("policyengine", "PolicyEngine").replace(
4646
"-", " "
@@ -50,13 +50,14 @@ def bump_country_package(country, version):
5050
country_id, country_id.upper()
5151
)
5252

53-
changelog_yaml = f"""- bump: patch\n changes:\n changed:\n - Update {country_package_full_name} to {version}\n"""
54-
# Write changelog_yaml to changelog.yaml
55-
with open("changelog_entry.yaml", "w") as f:
56-
f.write(changelog_yaml)
57-
58-
# Commit the change and push to a branch
53+
# Define branch name (needed for changelog fragment filename)
5954
branch_name = f"bump-{country}-to-{version}"
55+
56+
# Create a changelog fragment in changelog.d/
57+
changelog_content = f"Update {country_package_full_name} to {version}.\n"
58+
fragment_path = f"changelog.d/{branch_name}.changed.md"
59+
with open(fragment_path, "w") as f:
60+
f.write(changelog_content)
6061
# Checkout a new branch locally, add all the files, commit, and push using the GitHub CLI only
6162

6263
# First, create a new branch off master

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ dependencies = [
3939
"policyengine-ng==0.5.1",
4040
"policyengine-il==0.1.0",
4141
"policyengine_uk==2.39.0",
42-
"policyengine_us==1.592.4",
42+
"policyengine_us==1.596.5",
4343
"policyengine_core>=3.16.6",
4444
"policyengine>=0.7.0",
4545
"pydantic",

0 commit comments

Comments
 (0)