Skip to content

Commit

Permalink
Add --pip-compile-args flag
Browse files Browse the repository at this point in the history
  • Loading branch information
KSmanis committed Jan 2, 2022
1 parent 6f93954 commit 662e5a7
Showing 1 changed file with 11 additions and 22 deletions.
33 changes: 11 additions & 22 deletions src/pipautocompile/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import tempfile
from itertools import groupby
from pathlib import Path
from shlex import split

import click

Expand All @@ -15,26 +16,13 @@
from pipautocompile.logging import info
from pipautocompile.utils import quote_args

DEFAULT_DOCKER_BUILD_STAGE = "build-deps"
DEFAULT_PIP_COMPILE_ARGS = (
"--allow-unsafe",
"--generate-hashes",
"--no-reuse-hashes",
"--upgrade",
)


@click.command(
context_settings={
"help_option_names": ("-h", "--help"),
"ignore_unknown_options": True,
}
)
@click.command(context_settings={"help_option_names": ["-h", "--help"]})
@click.version_option(package_name="pip-autocompile") # type: ignore
@click.option(
"--docker-build-stage",
help="Docker build stage to search for.",
default=DEFAULT_DOCKER_BUILD_STAGE,
default="build-deps",
show_default=True,
)
@click.option(
Expand All @@ -49,21 +37,22 @@
default=False,
show_default=True,
)
@click.argument(
"pip_compile_args",
nargs=-1,
type=click.UNPROCESSED,
@click.option(
"--pip-compile-args",
"pip_compile_args_str",
help="Arguments to pass directly to the pip-compile command.",
default="--allow-unsafe --generate-hashes --no-reuse-hashes --upgrade",
show_default=True,
)
def cli(
docker_build_stage: str,
docker_ssh_agent_passthrough: bool,
git_recurse_submodules: bool,
pip_compile_args: tuple[str, ...],
pip_compile_args_str: str,
):
"""Automate pip-compile for multiple environments."""

if not pip_compile_args:
pip_compile_args = DEFAULT_PIP_COMPILE_ARGS
pip_compile_args = split(pip_compile_args_str)

initial_working_tree = working_tree()
for spec_dir, specs in groupby(sorted(find_spec_files()), key=lambda s: s.parent):
Expand Down

0 comments on commit 662e5a7

Please sign in to comment.