Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not write PEP610 URL reference for cached packages installed from … #5362

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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