From 5777bb1240859e13d64c21bc50607cfc7fb9b423 Mon Sep 17 00:00:00 2001 From: TheByronHimes Date: Wed, 20 Sep 2023 10:46:23 +0000 Subject: [PATCH] Move production deps constraint to update script Require the lock files (mandatory) Remove requirements.txt from static files --- .mandatory_files | 2 ++ .static_files | 3 +-- requirements.in | 2 -- scripts/update_lock.py | 17 +++++++++-------- 4 files changed, 12 insertions(+), 12 deletions(-) delete mode 100644 requirements.in diff --git a/.mandatory_files b/.mandatory_files index 8ec8074e..73ee378d 100644 --- a/.mandatory_files +++ b/.mandatory_files @@ -21,7 +21,9 @@ example_config.yaml LICENSE pyproject.toml README.md +requirements-dev.in requirements-dev.txt +requirements.txt .description.md .design.md diff --git a/.static_files b/.static_files index 3ebfa187..cc53aaa7 100644 --- a/.static_files +++ b/.static_files @@ -45,8 +45,7 @@ example_data/README.md pytest.ini LICENSE -requirements.txt -requirements-dev-common.txt +requirements-dev-common.in setup.py .readme_template.md diff --git a/requirements.in b/requirements.in deleted file mode 100644 index d1dc4ca4..00000000 --- a/requirements.in +++ /dev/null @@ -1,2 +0,0 @@ -# constrain production-only dependency builds --c requirements-dev.txt diff --git a/scripts/update_lock.py b/scripts/update_lock.py index 8f77b85f..fd57d01a 100755 --- a/scripts/update_lock.py +++ b/scripts/update_lock.py @@ -35,7 +35,6 @@ PYPROJECT_TOML_PATH = REPO_ROOT_DIR / "pyproject.toml" DEV_DEPS_PATH = REPO_ROOT_DIR / "requirements-dev.in" -PROD_DEPS_PATH = REPO_ROOT_DIR / "requirements.in" OUTPUT_LOCK_PATH = REPO_ROOT_DIR / "requirements.txt" OUTPUT_DEV_LOCK_PATH = REPO_ROOT_DIR / "requirements-dev.txt" @@ -138,7 +137,7 @@ def compile_lock_file( and write it to the specified output location. """ - print(f"Updating '{output}'...") + print(f"Updating '{output.name}'...") command = [ "pip-compile", @@ -157,6 +156,10 @@ def compile_lock_file( command.extend([str(source.absolute()) for source in sources]) + # constrain the production deps by what's pinned in requirements-dev.txt + if output.name == OUTPUT_LOCK_PATH.name: + command.extend(["-c", str(OUTPUT_DEV_LOCK_PATH)]) + completed_process = subprocess.run( args=command, stdout=subprocess.PIPE, @@ -216,10 +219,8 @@ def main(upgrade: bool = False, check: bool = False): os.makedirs(Path(temp_dir) / "src") # temporary test files - check_dev_path = Path(temp_dir) / "requirements-dev.txt" - # check_dev_path = REPO_ROOT_DIR / "check-requirements-dev.txt" - check_prod_path = Path(temp_dir) / "requirements.txt" - # check_prod_path = REPO_ROOT_DIR / "check-requirements.txt" + check_dev_path = Path(temp_dir) / OUTPUT_DEV_LOCK_PATH.name + check_prod_path = Path(temp_dir) / OUTPUT_LOCK_PATH.name # compile requirements-dev.txt (includes all dependencies) compile_lock_file( @@ -234,8 +235,8 @@ def main(upgrade: bool = False, check: bool = False): # compile requirements.txt (only includes production-related subset of above) compile_lock_file( - sources=[modified_pyproject_path, PROD_DEPS_PATH], - output=check_prod_path if check else OUTPUT_DEV_LOCK_PATH, + sources=[modified_pyproject_path], + output=check_prod_path if check else OUTPUT_LOCK_PATH, upgrade=upgrade, extras=extras, )