Skip to content

Commit

Permalink
Include cryptography_vectors in our test deps (#10277)
Browse files Browse the repository at this point in the history
fixes #10242
  • Loading branch information
alex authored Jan 28, 2024
1 parent 581b928 commit 36368cc
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 9 deletions.
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ ssh = ["bcrypt >=3.1.5"]
# All the following are used for our own testing.
nox = ["nox"]
test = [
"cryptography_vectors",
"pytest >=6.2.0",
"pytest-benchmark",
"pytest-cov",
Expand Down
32 changes: 23 additions & 9 deletions release.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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()

0 comments on commit 36368cc

Please sign in to comment.