From 8eea4ca54400d58cd69ae142374bac25a6039d0b Mon Sep 17 00:00:00 2001 From: Ross McFarland Date: Wed, 5 Apr 2023 14:53:30 -0700 Subject: [PATCH 1/2] Add header to generated requirements --- requirements-dev.txt | 1 + requirements.txt | 1 + script/update-requirements | 5 +++++ 3 files changed, 7 insertions(+) diff --git a/requirements-dev.txt b/requirements-dev.txt index 6573491..068d690 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -1,3 +1,4 @@ +# DO NOT EDIT THIS FILE DIRECTLY - use ./script/update-requirements to update Pygments==2.13.0 attrs==22.1.0 black==22.10.0 diff --git a/requirements.txt b/requirements.txt index cb174a4..22f9237 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,3 +1,4 @@ +# DO NOT EDIT THIS FILE DIRECTLY - use ./script/update-requirements to update PyYAML==6.0 dnspython==2.3.0 fqdn==1.5.1 diff --git a/script/update-requirements b/script/update-requirements index 6275c05..7e749b4 100755 --- a/script/update-requirements +++ b/script/update-requirements @@ -2,6 +2,7 @@ from os.path import join from subprocess import check_call, check_output +from sys import argv from tempfile import TemporaryDirectory import re @@ -43,10 +44,14 @@ dev_frozen = sorted([p for p in dev_frozen print_packages(frozen, 'frozen') print_packages(dev_frozen, 'dev_frozen') +script = argv[0] + with open('requirements.txt', 'w') as fh: + fh.write(f'# DO NOT EDIT THIS FILE DIRECTLY - use {script} to update\n') fh.write('\n'.join(frozen)) fh.write('\n') with open('requirements-dev.txt', 'w') as fh: + fh.write(f'# DO NOT EDIT THIS FILE DIRECTLY - use {script} to update\n') fh.write('\n'.join(dev_frozen)) fh.write('\n') From ddba96c2896a67904f55e02b69b062855e200a83 Mon Sep 17 00:00:00 2001 From: Ross McFarland Date: Wed, 5 Apr 2023 14:54:08 -0700 Subject: [PATCH 2/2] Include python in scripts directory in lint & formatting --- script/format | 2 +- script/lint | 2 +- script/update-requirements | 7 ++++--- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/script/format b/script/format index 1e9fe4f..2a8438d 100755 --- a/script/format +++ b/script/format @@ -2,7 +2,7 @@ set -e -SOURCES=$(find *.py octodns tests -name "*.py") +SOURCES="$(find *.py octodns tests -name '*.py') $(grep --files-with-matches '^#!.*python' script/*)" . env/bin/activate diff --git a/script/lint b/script/lint index 24c7643..fd0d36c 100755 --- a/script/lint +++ b/script/lint @@ -15,6 +15,6 @@ if [ ! -f "$ACTIVATE" ]; then fi . "$ACTIVATE" -SOURCES="*.py octodns/*.py octodns/*/*.py tests/*.py" +SOURCES="$(find *.py octodns tests -name '*.py') $(grep --files-with-matches '^#!.*python' script/*)" pyflakes $SOURCES diff --git a/script/update-requirements b/script/update-requirements index 7e749b4..7696f6d 100755 --- a/script/update-requirements +++ b/script/update-requirements @@ -1,10 +1,10 @@ #!/usr/bin/env python3 +import re from os.path import join from subprocess import check_call, check_output from sys import argv from tempfile import TemporaryDirectory -import re def print_packages(packages, heading): @@ -38,8 +38,9 @@ with TemporaryDirectory() as tmpdir: # pip installs the module itself along with deps so we need to get that out of # our list by finding the thing that was file installed during dev frozen = sorted([p for p in frozen if not p.startswith(our_package_name)]) -dev_frozen = sorted([p for p in dev_frozen - if not p.startswith(our_package_name)]) +dev_frozen = sorted( + [p for p in dev_frozen if not p.startswith(our_package_name)] +) print_packages(frozen, 'frozen') print_packages(dev_frozen, 'dev_frozen')