Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Copy dependencies to requirements.txt in pre commit #890

Merged
merged 1 commit into from
Mar 13, 2024
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
5 changes: 5 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -55,3 +55,8 @@ repos:
pass_filenames: true
files: ^src/.*\.py$
exclude: ^src/snowflake/cli/app/telemetry.py$
- id: dependencies-sync
name: "Copy dependencies from pyproject.toml to requirements.txt"
language: system
entry: python .snyk/dependency-sync.py
Comment on lines +58 to +61
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add files to run this only on pyproject.toml change, WDYT?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good idea, added

files: ^pyproject.toml$
19 changes: 19 additions & 0 deletions .snyk/dependency-sync.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
from pathlib import Path

import tomllib


def sync():
pyproject = tomllib.loads(Path("pyproject.toml").read_text())
dependencies = pyproject["project"]["dependencies"]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are these all dependencies including dev deps or we have some development packages listed as dependencies?
coverage

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point, I forgot about them

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added

dev_dependencies = pyproject["project"]["optional-dependencies"]["development"]
with open(".snyk/req-auto-generated.txt", "w") as req:
req.write("# Auto generated\n")
for dep in dependencies:
req.write(f"{dep}\n")
for dep in dev_dependencies:
req.write(f"{dep}\n")


if __name__ == "__main__":
sync()
20 changes: 20 additions & 0 deletions .snyk/req-auto-generated.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Auto generated
jinja2==3.1.3
pluggy==1.4.0
PyYAML==6.0.1
rich==13.7.1
requests==2.31.0
requirements-parser==0.5.0
setuptools==69.1.1
snowflake-connector-python[secure-local-storage]==3.7.1
strictyaml==1.7.3
tomlkit==0.12.3
typer==0.9.0
urllib3>=1.21.1,<2.3
GitPython==3.1.42
pydantic==2.6.3
coverage==7.4.3
pre-commit>=3.5.0
pytest==8.1.1
pytest-randomly==3.15.0
syrupy==4.6.1
1 change: 0 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ requires-python = ">=3.8"
description = "Snowflake CLI"
readme = "README.md"
dependencies = [
"coverage==7.4.3",
"jinja2==3.1.3",
"pluggy==1.4.0",
"PyYAML==6.0.1",
Expand Down
Loading