Skip to content

Commit

Permalink
Merge pull request #421 from jtpio/version-piplite
Browse files Browse the repository at this point in the history
Version piplite with the `bump-version` script
  • Loading branch information
jtpio committed Nov 25, 2021
2 parents d3c02a4 + fda0358 commit 5f3971d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
4 changes: 2 additions & 2 deletions .bumpversion.cfg
Expand Up @@ -3,12 +3,12 @@ current_version = 0, 1, 0, "alpha", 16
commit = False
tag = False
parse = (?P<major>\d+)\,\ (?P<minor>\d+)\,\ (?P<patch>\d+)\,\ \"(?P<release>\S+)\"\,\ (?P<build>\d+)
serialize =
serialize =
{major}, {minor}, {patch}, "{release}", {build}

[bumpversion:part:release]
optional_value = final
values =
values =
alpha
beta
candidate
Expand Down
11 changes: 6 additions & 5 deletions scripts/bump-version.py
Expand Up @@ -23,13 +23,15 @@

PYOLITE_PACKAGE = ROOT / "packages" / "pyolite-kernel"
PYOLITE_PACKAGE_JSON = PYOLITE_PACKAGE / "package.json"
PYOLITE_KERNEL_SOURCE = PYOLITE_PACKAGE / "src" / "kernel.ts"
PYOLITE_INIT_PY = PYOLITE_PACKAGE / "py" / "pyolite" / "pyolite" / "__init__.py"
PIPLITE_INIT_PY = PYOLITE_PACKAGE / "py" / "piplite" / "piplite" / "__init__.py"


def replace_in_file(path, pattern, replacement):
source = path.read_text(**ENC)
replaced = re.sub(pattern, replacement, source)
if replaced == source:
raise ValueError("pattern not found")
path.write_text(replaced, **ENC)


Expand All @@ -43,17 +45,16 @@ def postbump():

# bump pyolite wheel import
replace_in_file(
PYOLITE_KERNEL_SOURCE,
"pyolite-(.*)-py3-none-any.whl",
f"pyolite-{py_version}-py3-none-any.whl",
PYOLITE_INIT_PY, "__version__ = (.*)", f'__version__ = "{py_version}"'
)
replace_in_file(
PYOLITE_INIT_PY, "__version__ = (.*)", f'__version__ = "{py_version}"'
PIPLITE_INIT_PY, "__version__ = (.*)", f'__version__ = "{py_version}"'
)

# bump pyolite version
pyolite_json = json.loads(PYOLITE_PACKAGE_JSON.read_text(**ENC))
pyolite_json["pyolite"]["packages"]["py/pyolite"] = py_version
pyolite_json["pyolite"]["packages"]["py/piplite"] = py_version
PYOLITE_PACKAGE_JSON.write_text(json.dumps(pyolite_json), **ENC)
run(f"yarn prettier --write {PYOLITE_PACKAGE_JSON}")

Expand Down

0 comments on commit 5f3971d

Please sign in to comment.