Skip to content

Commit

Permalink
mraba/snyk-support-requirements: automate process
Browse files Browse the repository at this point in the history
  • Loading branch information
sfc-gh-mraba committed Apr 22, 2024
1 parent 3650813 commit 6c39645
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 1 deletion.
7 changes: 7 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -44,3 +44,10 @@ repos:
- id: flake8
additional_dependencies:
- flake8-bugbear
- repo: local
hooks:
- id: requirements-update
name: "Update dependencies from pyproject.toml to snyk/requirements.txt"
language: system
entry: python snyk/requirements-update.py
files: ^pyproject.toml$
4 changes: 3 additions & 1 deletion snyk/requiremtnts.txt → snyk/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
snowflake-connector-python<4.0.0
SQLAlchemy>=1.4.19,<2.0.0
snowflake-connector-python<4.0.0
pandas
development
19 changes: 19 additions & 0 deletions snyk/requirements_sync.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
from pathlib import Path

import tomlkit


def sync():
pyproject = tomlkit.loads(Path("pyproject.toml").read_text())
snyk_reqiurements = Path("snyk/requirements.txt")
dependencies = set(pyproject.get("project", {}).get("dependencies", []))
dev_dependencies = set(
pyproject.get("project", {}).get("optional-dependencies", [])
)

with snyk_reqiurements.open("w") as fh:
fh.write("\n".join(dependencies | dev_dependencies))


if __name__ == "__main__":
sync()

0 comments on commit 6c39645

Please sign in to comment.