Skip to content

Commit

Permalink
Merge branch 'master' into patch-1
Browse files Browse the repository at this point in the history
  • Loading branch information
atugushev authored Nov 9, 2022
2 parents d8e272f + a77a5a7 commit a8dcc5b
Show file tree
Hide file tree
Showing 7 changed files with 113 additions and 7 deletions.
4 changes: 1 addition & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ jobs:
- Windows
- macOS
python-version:
- "3.11"
- "3.10"
- "3.9"
- "3.8"
Expand All @@ -50,9 +51,6 @@ jobs:
- "latest"
- "previous"
include:
- os: Ubuntu
python-version: 3.11-dev
pip-version: latest
- os: Ubuntu
python-version: 3.7
pip-version: main
Expand Down
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ repos:
hooks:
- id: isort
- repo: https://github.com/asottile/pyupgrade
rev: v3.0.0
rev: v3.2.0
hooks:
- id: pyupgrade
args: [--py37-plus]
Expand Down Expand Up @@ -39,6 +39,6 @@ repos:
args: [--ini, .bandit]
exclude: ^tests/
- repo: https://github.com/pre-commit/mirrors-prettier
rev: v3.0.0-alpha.1
rev: v3.0.0-alpha.4
hooks:
- id: prettier
17 changes: 16 additions & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ even when you've pinned them. You do pin them, right? (In building your Python
.. |pyversions| image:: https://img.shields.io/pypi/pyversions/pip-tools.svg
:alt: Supported Python versions
:target: https://pypi.org/project/pip-tools/
.. _You do pin them, right?: http://nvie.com/posts/pin-your-packages/
.. _You do pin them, right?: https://nvie.com/posts/pin-your-packages/

Installation
============
Expand Down Expand Up @@ -572,6 +572,21 @@ This section lists ``pip-tools`` features that are currently deprecated.
recommended to pass the ``--allow-unsafe`` now to adapt to the upcoming
change.

A Note on Resolvers
===================

You can choose from either the legacy or the backtracking resolver.
The backtracking resolver is recommended, and will become the default
with the 7.0 release.

Use it now with the ``--resolver=backtracking`` option to ``pip-compile``.

The legacy resolver will occasionally fail to resolve dependencies. The
backtracking resolver is more robust, but can take longer to run in
general.

You can continue using the legacy resolver with ``--resolver=legacy``.

Versions and compatibility
==========================

Expand Down
2 changes: 1 addition & 1 deletion piptools/resolver.py
Original file line number Diff line number Diff line change
Expand Up @@ -770,7 +770,7 @@ def _get_install_requirement_from_candidate(

# Save source for annotation
source_ireq = self._constraints_map.get(ireq_key)
if source_ireq is not None and ireq_key not in self.existing_constraints:
if source_ireq is not None:
pinned_ireq._source_ireqs = [source_ireq]

return pinned_ireq
1 change: 1 addition & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ classifiers =
Programming Language :: Python :: 3.8
Programming Language :: Python :: 3.9
Programming Language :: Python :: 3.10
Programming Language :: Python :: 3.11
Programming Language :: Python :: Implementation :: CPython
Programming Language :: Python :: Implementation :: PyPy
Topic :: System :: Systems Administration
Expand Down
11 changes: 11 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import json
import os
import platform
import subprocess
import sys
from contextlib import contextmanager
Expand Down Expand Up @@ -423,3 +424,13 @@ def fake_dists(tmpdir, make_package, make_wheel):
for pkg in pkgs:
make_wheel(pkg, dists_path)
return dists_path


@pytest.fixture
def venv(tmp_path):
"""Create a temporary venv and get the path of its directory of executables."""
subprocess.run(
[sys.executable, "-m", "venv", os.fspath(tmp_path)],
check=True,
)
return tmp_path / ("Scripts" if platform.system() == "Windows" else "bin")
81 changes: 81 additions & 0 deletions tests/test_cli_compile.py
Original file line number Diff line number Diff line change
Expand Up @@ -511,6 +511,50 @@ def test_editable_package_vcs(runner):
assert "click" in out.stderr # dependency of pip-tools


@pytest.mark.network
def test_compile_cached_vcs_package(runner, venv):
"""
Test pip-compile doesn't write local paths for cached wheels of VCS packages.
Regression test for issue GH-1647.
"""
vcs_package = (
"typing-extensions @ git+https://github.com/python/typing_extensions@"
"9c0759a260fe126210a1e2026720000a3c40a919"
)
vcs_wheel_prefix = "typing_extensions-4.3.0-py3"

# Install and cache VCS package.
subprocess.run(
[os.fspath(venv / "python"), "-m" "pip", "install", vcs_package],
check=True,
)
assert (
vcs_wheel_prefix
in subprocess.run(
[
sys.executable,
"-m" "pip",
"cache",
"list",
"--format=abspath",
vcs_wheel_prefix,
],
check=True,
capture_output=True,
text=True,
).stdout
)

with open("requirements.in", "w") as req_in:
req_in.write(vcs_package)

out = runner.invoke(cli, ["--no-header", "--no-emit-options", "--no-annotate"])

assert out.exit_code == 0, out
assert vcs_package == out.stderr.strip()


@legacy_resolver_only
def test_locally_available_editable_package_is_not_archived_in_cache_dir(
pip_conf, tmpdir, runner
Expand Down Expand Up @@ -2406,3 +2450,40 @@ def test_resolver_reaches_max_rounds(runner):
out = runner.invoke(cli, ["--max-rounds", 0])

assert out.exit_code != 0, out


def test_preserve_via_requirements_constrained_dependencies_when_run_twice(
pip_conf, runner
):
"""
Test that 2 consecutive runs of pip-compile (first with a non-existing requirements.txt file,
second with an existing file) produce the same output.
"""
with open("constraints.txt", "w") as constraints_in:
constraints_in.write("small-fake-a==0.1")

with open("requirements.in", "w") as req_in:
req_in.write("-c constraints.txt\nsmall_fake_with_deps")

cli_arguments = ["--no-emit-options", "--no-header"]

# First run of the command will generate `requirements.txt`, which doesn't yet exist.
first_out = runner.invoke(cli, cli_arguments)

# Second run of the command will update `requirements.txt`.
second_out = runner.invoke(cli, cli_arguments)

expected_output = dedent(
"""\
small-fake-a==0.1
# via
# -c constraints.txt
# small-fake-with-deps
small-fake-with-deps==0.1
# via -r requirements.in
"""
)

for output in (first_out, second_out):
assert output.exit_code == 0, output
assert output.stderr == expected_output

0 comments on commit a8dcc5b

Please sign in to comment.