Skip to content

Commit 8f06fd4

Browse files
authored
mraba/snyk-support-requirements: add requirements.txt file for snyk scanning (snowflakedb#491)
* mraba/snyk-support-requirements: add requirements.txt file for snyk scanning * mraba/snyk-support-requirements: add script for generating requirements and filename fix * mraba/snyk-support-requirements: finish last line with new line * mraba/snyk-support-requirements: add pre-commit hook for auto generating requirements.txt
1 parent d2b3334 commit 8f06fd4

File tree

4 files changed

+27
-1
lines changed

4 files changed

+27
-1
lines changed

.pre-commit-config.yaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,3 +44,10 @@ repos:
4444
- id: flake8
4545
additional_dependencies:
4646
- flake8-bugbear
47+
- repo: local
48+
hooks:
49+
- id: requirements-update
50+
name: "Update dependencies from pyproject.toml to snyk/requirements.txt"
51+
language: system
52+
entry: python snyk/update_requirements.py
53+
files: ^pyproject.toml$

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ classifiers = [
3838
"Topic :: Software Development :: Libraries :: Application Frameworks",
3939
"Topic :: Software Development :: Libraries :: Python Modules",
4040
]
41-
dependencies = ["snowflake-connector-python<4.0.0", "SQLAlchemy>=1.4.19,<2.0.0"]
41+
dependencies = ["SQLAlchemy>=1.4.19,<2.0.0", "snowflake-connector-python<4.0.0"]
4242

4343
[tool.hatch.version]
4444
path = "src/snowflake/sqlalchemy/version.py"

snyk/requirements.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
SQLAlchemy>=1.4.19,<2.0.0
2+
snowflake-connector-python<4.0.0

snyk/update_requirements.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
from pathlib import Path
2+
3+
import tomlkit
4+
5+
6+
def sync():
7+
pyproject = tomlkit.loads(Path("pyproject.toml").read_text())
8+
snyk_reqiurements = Path("snyk/requirements.txt")
9+
dependencies = pyproject.get("project", {}).get("dependencies", [])
10+
11+
with snyk_reqiurements.open("w") as fh:
12+
fh.write("\n".join(dependencies))
13+
fh.write("\n")
14+
15+
16+
if __name__ == "__main__":
17+
sync()

0 commit comments

Comments
 (0)