Skip to content

Commit

Permalink
Merge 272d9e3 into dcbeec2
Browse files Browse the repository at this point in the history
  • Loading branch information
prescod committed Feb 2, 2023
2 parents dcbeec2 + 272d9e3 commit 55da700
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 1 deletion.
4 changes: 3 additions & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@ jobs:
python-version: 3.8
cache: pip
- name: Install build tools
run: python -m pip install hatch
run: python -m pip install hatch tomli tomli-w
- name: Pin dependencies
run: python utility/pin_dependencies.py
- name: Build source tarball and binary wheel
run: hatch build -c
- name: Upload to PyPI
Expand Down
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ servedocs: docs ## compile the docs watching for changes
watchmedo shell-command -p '*.rst' -c '$(MAKE) -C docs html' -R -D .

release: clean ## package and upload a release
python utility/pin_dependencies.py
hatch build
hatch publish

Expand Down
28 changes: 28 additions & 0 deletions utility/pin_dependencies.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import re
from pathlib import Path

import tomli
import tomli_w


def main(toml_filename: Path, requirements_txt: Path):
with open(toml_filename, "rb") as f:
data = tomli.load(f)

with open(requirements_txt) as f:
requirements = re.findall(r".*==.*", f.read())

pin_dependencies(data, requirements)

with open(toml_filename, "wb") as f:
tomli_w.dump(data, f)


def pin_dependencies(data: dict, requirements: str):
data["project"]["dependencies"] = requirements


root = Path(__file__).parent.parent
requirements = root / "requirements"
main(root / "pyproject.toml", requirements / "prod.txt")
print("Updated ", root / "pyproject.toml")

0 comments on commit 55da700

Please sign in to comment.