-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add `python/set-version.py` to update versions of Python SDK and adapters. To update specific version (with `uv`): ```shell uv run python/set-version.py 1.4.2 ``` To bump up patch version: ```shell uv run python/set-version.py ```
- Loading branch information
Showing
8 changed files
with
131 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
# /// script | ||
# requires-python = ">=3.8" | ||
# dependencies = [ | ||
# "tomlkit" | ||
# ] | ||
# /// | ||
|
||
# Bump up versions of OMMX Python SDK and adapters | ||
# | ||
# Usage | ||
# ------ | ||
# | ||
# Set the version of the OMMX Python SDK and adapters to the specified version. | ||
# | ||
# ```shell | ||
# uv run python/set-version.py 0.1.0 | ||
# ``` | ||
# | ||
# Bump up patch version of the OMMX Python SDK and adapters | ||
# | ||
# ```shell | ||
# uv run python/set-version.py | ||
# ``` | ||
# | ||
|
||
from pathlib import Path | ||
import tomlkit | ||
import argparse | ||
|
||
|
||
def update_version(pyproject_path: Path, new_version: str): | ||
with open(pyproject_path, "r") as file: | ||
pyproject_data = tomlkit.parse(file.read()) | ||
|
||
pyproject_data["project"]["version"] = new_version # type: ignore | ||
|
||
with open(pyproject_path, "w") as file: | ||
file.write(tomlkit.dumps(pyproject_data)) | ||
|
||
|
||
def generrate_next_version(sdk: Path) -> str: | ||
with open(sdk, "r") as file: | ||
pyproject_data = tomlkit.parse(file.read()) | ||
current = str(pyproject_data["project"]["version"]) # type: ignore | ||
major, minor, patch = current.split(".") | ||
return f"{major}.{minor}.{int(patch) + 1}" | ||
|
||
|
||
def main(): | ||
parser = argparse.ArgumentParser() | ||
parser.add_argument("version", help="New version to set", default=None, nargs="?") | ||
|
||
args = parser.parse_args() | ||
|
||
here = Path(__file__).parent | ||
sdk = here / "ommx" / "pyproject.toml" | ||
adapters = [ | ||
here / name / "pyproject.toml" | ||
for name in [ | ||
"ommx-pyscipopt-adapter", | ||
"ommx-python-mip-adapter", | ||
# Add new adapter here | ||
] | ||
] | ||
|
||
if args.version: | ||
new_version = args.version | ||
else: | ||
new_version = generrate_next_version(sdk) | ||
print(new_version) | ||
|
||
for pyproject in [sdk] + adapters: | ||
update_version(pyproject, new_version) | ||
|
||
|
||
if __name__ == "__main__": | ||
main() |