Skip to content

Commit

Permalink
Do not write PEP610 URL reference for cached packages installed from …
Browse files Browse the repository at this point in the history
…a private source (#5362)
  • Loading branch information
radoering committed Mar 26, 2022
1 parent e1b8dd9 commit 4da3bcb
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/poetry/installation/executor.py
Original file line number Diff line number Diff line change
Expand Up @@ -725,11 +725,11 @@ def _save_url_reference(self, operation: OperationTypes) -> None:

package = operation.package

if not package.source_url:
if not package.source_url or package.source_type == "legacy":
# Since we are installing from our own distribution cache
# pip will write a `direct_url.json` file pointing to the cache
# distribution.
# That's not what we want so we remove the direct_url.json file,
# That's not what we want, so we remove the direct_url.json file,
# if it exists.
for (
direct_url_json
Expand Down
36 changes: 36 additions & 0 deletions tests/installation/test_executor.py
Original file line number Diff line number Diff line change
Expand Up @@ -411,6 +411,42 @@ def verify_installed_distribution(
assert not direct_url_file.exists()


@pytest.mark.parametrize(
"package",
[
Package("demo", "0.1.0"), # PyPI
Package( # private source
"demo",
"0.1.0",
source_type="legacy",
source_url="http://localhost:3141/root/pypi/+simple",
source_reference="private",
),
],
)
def test_executor_should_not_write_pep610_url_references_for_cached_package(
package: Package,
mocker: MockerFixture,
fixture_dir: FixtureDirGetter,
tmp_venv: VirtualEnv,
pool: Pool,
config: Config,
io: BufferedIO,
):
link_cached = Link(
fixture_dir("distributions")
.joinpath("demo-0.1.0-py2.py3-none-any.whl")
.as_uri()
)
mocker.patch(
"poetry.installation.executor.Executor._download", return_value=link_cached
)

executor = Executor(tmp_venv, pool, config, io)
executor.execute([Install(package)])
verify_installed_distribution(tmp_venv, package)


def test_executor_should_write_pep610_url_references_for_files(
tmp_venv: VirtualEnv, pool: Pool, config: Config, io: BufferedIO
):
Expand Down

0 comments on commit 4da3bcb

Please sign in to comment.