Skip to content

Commit

Permalink
Move production deps constraint to update script
Browse files Browse the repository at this point in the history
Require the lock files (mandatory)

Remove requirements.txt from static files
  • Loading branch information
TheByronHimes committed Sep 20, 2023
1 parent 9e275cc commit 5777bb1
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 12 deletions.
2 changes: 2 additions & 0 deletions .mandatory_files
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@ example_config.yaml
LICENSE
pyproject.toml
README.md
requirements-dev.in
requirements-dev.txt
requirements.txt

.description.md
.design.md
3 changes: 1 addition & 2 deletions .static_files
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 0 additions & 2 deletions requirements.in

This file was deleted.

17 changes: 9 additions & 8 deletions scripts/update_lock.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down Expand Up @@ -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",
Expand All @@ -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,
Expand Down Expand Up @@ -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(
Expand All @@ -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,
)
Expand Down

0 comments on commit 5777bb1

Please sign in to comment.