Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions .github/workflows/dependencies_check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
---
name: Dependencies Check
on:
pull_request:
types:
- opened
- reopened
- synchronize
paths:
- pyproject.toml
- requirements.txt
- scripts/check_deps.py

jobs:
test:
name: Check dependencies sync between pyproject.toml and requirements.txt
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@master
- name: Set up Python 3.13
uses: actions/setup-python@v4
with:
python-version: 3.13
- name: Install dependencies
run: python -m pip install --upgrade tomli
- name: Run script
run: python3 bin/check_deps.py
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.

## \[Unreleased\]

- Nothing yet.
### Fixed

- Updated pyproject.toml dependencies. Thanks, @kkorlyak ([#244](https://github.com/amplify-education/python-hcl2/pull/244))

## \[7.3.0\] - 2025-07-23

Expand Down
54 changes: 54 additions & 0 deletions bin/check_deps.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
"""Used by dependencies_check.yml to verify if dependencies between pyproject.yml and requirements.txt are in sync"""
import sys
from typing import Set
import difflib
import tomli


def get_pyproject_deps() -> Set[str]:
with open("pyproject.toml", "rb") as f:
pyproject_data = tomli.load(f)
return set(pyproject_data.get("project", {}).get("dependencies", set()))


def get_requirements_deps() -> Set[str]:
result = set()
with open("requirements.txt", "r") as f:
for line in f:
line = line.strip()
if line and not line.startswith("#"):
result.add(line)
return result


def main():

pyproject_deps = get_pyproject_deps()
requirements_deps = get_requirements_deps()

pyproject_lines = list(sorted(pyproject_deps))

if pyproject_deps == requirements_deps:
print("All dependencies are in sync:")
for line in pyproject_lines:
print(line)
sys.exit(0)

print("Failed, dependencies mismatch:")
requirements_lines = list(sorted(requirements_deps))

diff = difflib.unified_diff(
pyproject_lines,
requirements_lines,
fromfile="pyproject.toml",
tofile="requirements.txt",
lineterm="",
)
for line in diff:
print(line)

sys.exit(1)


if __name__ == "__main__":
main()
6 changes: 5 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,11 @@ classifiers = [
"Programming Language :: Python :: 3.13",
]
requires-python = ">=3.7.0"
dependencies = ["lark>=1,<2"]

dependencies = [
"lark>=1.1.5,<2.0",
"regex>=2024.4.16"
]
dynamic = ["version"]

[project.readme]
Expand Down