|
| 1 | +#!/usr/bin/env python3 |
| 2 | +# Copyright 2025 Janek Bevendorff |
| 3 | +# |
| 4 | +# Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | +# you may not use this file except in compliance with the License. |
| 6 | +# You may obtain a copy of the License at |
| 7 | +# |
| 8 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | +# |
| 10 | +# Unless required by applicable law or agreed to in writing, software |
| 11 | +# distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | +# See the License for the specific language governing permissions and |
| 14 | +# limitations under the License. |
| 15 | + |
| 16 | +# Keep Python package versions in sync with Rust workspace version |
| 17 | + |
| 18 | +import tomllib |
| 19 | +import re |
| 20 | +from subprocess import run |
| 21 | + |
| 22 | +cargo_ver = tomllib.load(open('Cargo.toml', 'rb'))['workspace']['package']['version'] |
| 23 | + |
| 24 | +print(f'Updating Python package versions to {cargo_ver}.') |
| 25 | + |
| 26 | +run(['poetry', 'version', '--project=fastwarc-py', cargo_ver], check=True) |
| 27 | +run(['poetry', 'version', '--project=resiliparse-py', cargo_ver], check=True) |
| 28 | + |
| 29 | +# Patch fastwarc dependency (cannot use `poetry add` for this if fastwarc is not yet published) |
| 30 | +with open('resiliparse-py/pyproject.toml', 'r') as f: |
| 31 | + resiliparse_toml = f.read() |
| 32 | +with open('resiliparse-py/pyproject.toml', 'w') as f: |
| 33 | + f.write(re.sub(r'"fastwarc==\d+\.\d+\.\d+"', |
| 34 | + f'"fastwarc=={cargo_ver}"', |
| 35 | + resiliparse_toml)) |
0 commit comments