-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Include cryptography_vectors in our test deps (#10277)
fixes #10242
- Loading branch information
Showing
2 changed files
with
24 additions
and
9 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -38,23 +38,24 @@ def release() -> None: | |
run("git", "push", "--tags", "[email protected]:pyca/cryptography.git") | ||
|
||
|
||
def replace_version( | ||
p: pathlib.Path, variable_name: str, new_version: str | ||
) -> None: | ||
def replace_pattern(p: pathlib.Path, pattern: str, replacement: str) -> None: | ||
content = p.read_text() | ||
|
||
pattern = rf"^{variable_name}\s*=\s*.*$" | ||
match = re.search(pattern, content, re.MULTILINE) | ||
assert match is not None | ||
|
||
start, end = match.span() | ||
new_content = ( | ||
content[:start] + f'{variable_name} = "{new_version}"' + content[end:] | ||
) | ||
|
||
new_content = content[:start] + replacement + content[end:] | ||
p.write_text(new_content) | ||
|
||
|
||
def replace_version( | ||
p: pathlib.Path, variable_name: str, new_version: str | ||
) -> None: | ||
replace_pattern( | ||
p, rf"^{variable_name}\s*=\s*.*$", f'{variable_name} = "{new_version}"' | ||
) | ||
|
||
|
||
@cli.command() | ||
@click.argument("new_version") | ||
def bump_version(new_version: str) -> None: | ||
|
@@ -75,6 +76,19 @@ def bump_version(new_version: str) -> None: | |
new_version, | ||
) | ||
|
||
if Version(new_version).is_prerelease: | ||
replace_pattern( | ||
base_dir / "pyproject.toml", | ||
r'"cryptography_vectors(==.*?)?"', | ||
'"cryptography_vectors"', | ||
) | ||
else: | ||
replace_pattern( | ||
base_dir / "pyproject.toml", | ||
r'"cryptography_vectors(==.*?)?"', | ||
f'"cryptography_vectors=={new_version}"', | ||
) | ||
|
||
|
||
if __name__ == "__main__": | ||
cli() |