Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/main' into static-pyproj
Browse files Browse the repository at this point in the history
  • Loading branch information
hauntsaninja committed Mar 25, 2024
2 parents 7ca2879 + 6f2c9cd commit 4e8f59f
Show file tree
Hide file tree
Showing 16 changed files with 274 additions and 48 deletions.
14 changes: 7 additions & 7 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
repos:
- repo: https://github.com/psf/black
rev: 23.11.0
rev: 24.2.0
hooks:
- id: black
args: [--target-version=py38]
- repo: https://github.com/PyCQA/isort
rev: 5.12.0
rev: 5.13.2
hooks:
- id: isort
- repo: https://github.com/asottile/pyupgrade
rev: v3.15.0
rev: v3.15.1
hooks:
- id: pyupgrade
args: [--py38-plus]
- repo: https://github.com/PyCQA/flake8
rev: 6.1.0
rev: 7.0.0
hooks:
- id: flake8
additional_dependencies:
- flake8-pytest-style
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.7.1
rev: v1.9.0
hooks:
- id: mypy
# Avoid error: Duplicate module named 'setup'
Expand All @@ -37,13 +37,13 @@ repos:
- pytest==7.4.2
language_version: python3.8
- repo: https://github.com/PyCQA/bandit
rev: 1.7.5
rev: 1.7.8
hooks:
- id: bandit
args: [--ini, .bandit]
exclude: ^tests/
- repo: https://github.com/pre-commit/mirrors-prettier
rev: v3.1.0
rev: v4.0.0-alpha.8
hooks:
- id: prettier
additional_dependencies:
Expand Down
42 changes: 42 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,45 @@
## v7.4.1

05 Mar 2024

Bug Fixes:

- Skip constraint path check ([#2038](https://github.com/jazzband/pip-tools/pull/2038)).
Thanks @honnix
- Fix collecting deps for all extras in multiple input packages
([#1981](https://github.com/jazzband/pip-tools/pull/1981)). Thanks @dragly

## v7.4.0

16 Feb 2024

Features:

- Allow force-enabling or force-disabling colorized output
([#2041](https://github.com/jazzband/pip-tools/pull/2041)). Thanks @aneeshusa
- Add support for command-specific configuration sections
([#1966](https://github.com/jazzband/pip-tools/pull/1966)). Thanks @chrysle
- Add options for including build dependencies in compiled output
([#1681](https://github.com/jazzband/pip-tools/pull/1681)). Thanks @apljungquist

Bug Fixes:

- Fix for `src-files` not being used when specified in a config file
([#2015](https://github.com/jazzband/pip-tools/pull/2015)). Thanks @csalerno-asml
- Fix ignorance of inverted CLI options in config for `pip-sync`
([#1989](https://github.com/jazzband/pip-tools/pull/1989)). Thanks @chrysle
- Filter out origin ireqs for extra requirements before writing output annotations
([#2011](https://github.com/jazzband/pip-tools/pull/2011)). Thanks @chrysle
- Make BacktrackingResolver ignore extras when dropping existing constraints
([#1984](https://github.com/jazzband/pip-tools/pull/1984)). Thanks @chludwig-haufe
- Display `pyproject.toml`'s metatada parsing errors in verbose mode
([#1979](https://github.com/jazzband/pip-tools/pull/1979)). Thanks @szobov

Other Changes:

- Add mention of pip-compile-multi in Other useful tools README section
([#1986](https://github.com/jazzband/pip-tools/pull/1986)). Thanks @peterdemin

## v7.3.0

09 Aug 2023
Expand Down
29 changes: 26 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,7 @@ By default, both `pip-compile` and `pip-sync` will look first
for a `.pip-tools.toml` file and then in your `pyproject.toml`. You can
also specify an alternate TOML configuration file with the `--config` option.

It is possible to specify configuration values both globally and command-specific.
For example, to by default generate `pip` hashes in the resulting
requirements file output, you can specify in a configuration file:

Expand All @@ -311,6 +312,28 @@ so the above could also be specified in this format:
generate_hashes = true
```

Configuration defaults specific to `pip-compile` and `pip-sync` can be put beneath
separate sections. For example, to by default perform a dry-run with `pip-compile`:

```toml
[tool.pip-tools.compile] # "sync" for pip-sync
dry-run = true
```

This does not affect the `pip-sync` command, which also has a `--dry-run` option.
Note that local settings take preference over the global ones of the same name,
whenever both are declared, thus this would also make `pip-compile` generate hashes,
but discard the global dry-run setting:

```toml
[tool.pip-tools]
generate-hashes = true
dry-run = true

[tool.pip-tools.compile]
dry-run = false
```

You might be wrapping the `pip-compile` command in another script. To avoid
confusing consumers of your custom script you can override the update command
generated at the top of requirements files by setting the
Expand Down Expand Up @@ -424,7 +447,7 @@ Sample `.pre-commit-config.yaml`:
```yaml
repos:
- repo: https://github.com/jazzband/pip-tools
rev: 7.3.0
rev: 7.4.1
hooks:
- id: pip-compile
```
Expand All @@ -434,7 +457,7 @@ You might want to customize `pip-compile` args by configuring `args` and/or `fil
```yaml
repos:
- repo: https://github.com/jazzband/pip-tools
rev: 7.3.0
rev: 7.4.1
hooks:
- id: pip-compile
files: ^requirements/production\.(in|txt)$
Expand All @@ -446,7 +469,7 @@ If you have multiple requirement files make sure you create a hook for each file
```yaml
repos:
- repo: https://github.com/jazzband/pip-tools
rev: 7.3.0
rev: 7.4.1
hooks:
- id: pip-compile
name: pip-compile setup.py
Expand Down
1 change: 1 addition & 0 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@

linkcheck_ignore = [
r"^https://matrix\.to/#",
r"^https://img.shields.io/matrix",
]

suppress_warnings = ["myst.xref_missing"]
12 changes: 6 additions & 6 deletions docs/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@ docutils==0.20.1
# myst-parser
# sphinx
furo==2023.8.17
# via -r docs/requirements.in
# via -r requirements.in
idna==3.4
# via requests
imagesize==1.4.1
# via sphinx
jinja2==3.1.2
jinja2==3.1.3
# via
# myst-parser
# sphinx
Expand All @@ -39,7 +39,7 @@ mdit-py-plugins==0.4.0
mdurl==0.1.2
# via markdown-it-py
myst-parser==2.0.0
# via -r docs/requirements.in
# via -r requirements.in
packaging==23.1
# via
# setuptools-scm
Expand All @@ -53,14 +53,14 @@ pyyaml==6.0.1
requests==2.31.0
# via sphinx
setuptools-scm==7.1.0
# via -r docs/requirements.in
# via -r requirements.in
snowballstemmer==2.2.0
# via sphinx
soupsieve==2.4.1
# via beautifulsoup4
sphinx==7.2.2
# via
# -r docs/requirements.in
# -r requirements.in
# furo
# myst-parser
# sphinx-basic-ng
Expand All @@ -81,7 +81,7 @@ sphinxcontrib-htmlhelp==2.0.4
sphinxcontrib-jsmath==1.0.1
# via sphinx
sphinxcontrib-programoutput==0.17
# via -r docs/requirements.in
# via -r requirements.in
sphinxcontrib-qthelp==1.0.6
# via sphinx
sphinxcontrib-serializinghtml==1.1.8
Expand Down
6 changes: 2 additions & 4 deletions piptools/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,10 @@

class PackageMetadata(Protocol):
@overload
def get_all(self, name: str, failobj: None = None) -> list[Any] | None:
...
def get_all(self, name: str, failobj: None = None) -> list[Any] | None: ...

@overload
def get_all(self, name: str, failobj: _T) -> list[Any] | _T:
...
def get_all(self, name: str, failobj: _T) -> list[Any] | _T: ...


@dataclass
Expand Down
6 changes: 3 additions & 3 deletions piptools/resolver.py
Original file line number Diff line number Diff line change
Expand Up @@ -504,9 +504,9 @@ def __init__(
self.existing_constraints = existing_constraints

# Categorize InstallRequirements into sets by key
constraints_sets: DefaultDict[
str, set[InstallRequirement]
] = collections.defaultdict(set)
constraints_sets: DefaultDict[str, set[InstallRequirement]] = (
collections.defaultdict(set)
)
for ireq in constraints:
constraints_sets[key_from_ireq(ireq)].add(ireq)
# Collapse each set of InstallRequirements using combine_install_requirements
Expand Down
24 changes: 19 additions & 5 deletions piptools/scripts/compile.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,13 @@ def _determine_linesep(
}[strategy]


@click.command(context_settings={"help_option_names": options.help_option_names})
@click.command(
name="pip-compile",
context_settings={"help_option_names": options.help_option_names},
)
@click.pass_context
@options.version
@options.color
@options.verbose
@options.quiet
@options.dry_run
Expand Down Expand Up @@ -115,6 +119,7 @@ def _determine_linesep(
@options.only_build_deps
def cli(
ctx: click.Context,
color: bool | None,
verbose: int,
quiet: int,
dry_run: bool,
Expand Down Expand Up @@ -162,8 +167,16 @@ def cli(
Compiles requirements.txt from requirements.in, pyproject.toml, setup.cfg,
or setup.py specs.
"""
if color is not None:
ctx.color = color
log.verbosity = verbose - quiet

# If ``src-files` was not provided as an input, but rather as config,
# it will be part of the click context ``ctx``.
# However, if ``src_files`` is specified, then we want to use that.
if not src_files and ctx.default_map and "src_files" in ctx.default_map:
src_files = ctx.default_map["src_files"]

if all_build_deps and build_deps_targets:
raise click.BadParameter(
"--build-deps-for has no effect when used with --all-build-deps"
Expand Down Expand Up @@ -192,6 +205,10 @@ def cli(
).format(", ".join(DEFAULT_REQUIREMENTS_FILES))
)

if all_extras and extras:
msg = "--extra has no effect when used with --all-extras"
raise click.BadParameter(msg)

if not output_file:
# An output file must be provided for stdin
if src_files == ("-",):
Expand Down Expand Up @@ -360,10 +377,7 @@ def cli(
if not only_build_deps:
constraints.extend(metadata.requirements)
if all_extras:
if extras:
msg = "--extra has no effect when used with --all-extras"
raise click.BadParameter(msg)
extras = metadata.extras
extras += metadata.extras
if build_deps_targets:
assert isinstance(metadata, ProjectMetadata)
constraints.extend(metadata.build_requirements)
Expand Down
14 changes: 6 additions & 8 deletions piptools/scripts/options.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,12 @@ def _get_default_option(option_name: str) -> Any:

version = click.version_option(package_name="pip-tools")

color = click.option(
"--color/--no-color",
default=None,
help="Force output to be colorized or not, instead of auto-detecting color support",
)

verbose = click.option(
"-v",
"--verbose",
Expand Down Expand Up @@ -337,14 +343,6 @@ def _get_default_option(option_name: str) -> Any:
constraint = click.option(
"-c",
"--constraint",
type=click.Path(
exists=True,
file_okay=True,
dir_okay=False,
readable=True,
allow_dash=False,
path_type=str,
),
multiple=True,
help="Constrain versions using the given constraints file; may be used more than once.",
)
Expand Down
4 changes: 3 additions & 1 deletion piptools/scripts/sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,9 @@
DEFAULT_REQUIREMENTS_FILE = "requirements.txt"


@click.command(context_settings={"help_option_names": options.help_option_names})
@click.command(
name="pip-sync", context_settings={"help_option_names": options.help_option_names}
)
@options.version
@options.ask
@options.dry_run
Expand Down
Loading

0 comments on commit 4e8f59f

Please sign in to comment.