Skip to content

Commit

Permalink
deprecate "installer.modern-installation false"
Browse files Browse the repository at this point in the history
  • Loading branch information
dimbleby committed Feb 18, 2024
1 parent 0eedea4 commit 3d794ce
Show file tree
Hide file tree
Showing 2 changed files with 116 additions and 75 deletions.
11 changes: 11 additions & 0 deletions src/poetry/installation/executor.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,17 @@ def __init__(
self._use_modern_installation = config.get(
"installer.modern-installation", True
)
if not self._use_modern_installation:
self._io.write_line(
"<warning>Setting `installer.modern-installation` to `false` "
"is deprecated.</>"
)
self._io.write_line(
"<warning>The pip-based installer will be removed in a future release.</>"
)
self._io.write_line(
"<warning>See https://github.com/python-poetry/poetry/issues/8987.</>"
)

if parallel is None:
parallel = config.get("installer.parallel", True)
Expand Down
180 changes: 105 additions & 75 deletions tests/installation/test_executor.py
Original file line number Diff line number Diff line change
Expand Up @@ -206,16 +206,18 @@ def test_execute_executes_a_batch_of_operations(
develop=True,
)

return_code = executor.execute([
Install(Package("pytest", "3.5.1")),
Uninstall(Package("attrs", "17.4.0")),
Update(Package("requests", "2.18.3"), Package("requests", "2.18.4")),
Update(Package("pytest", "3.5.1"), Package("pytest", "3.5.0")),
Uninstall(Package("clikit", "0.2.3")).skip("Not currently installed"),
Install(file_package),
Install(directory_package),
Install(git_package),
])
return_code = executor.execute(
[
Install(Package("pytest", "3.5.1")),
Uninstall(Package("attrs", "17.4.0")),
Update(Package("requests", "2.18.3"), Package("requests", "2.18.4")),
Update(Package("pytest", "3.5.1"), Package("pytest", "3.5.0")),
Uninstall(Package("clikit", "0.2.3")).skip("Not currently installed"),
Install(file_package),
Install(directory_package),
Install(git_package),
]
)

expected = f"""
Package operations: 4 installs, 2 updates, 1 removal
Expand Down Expand Up @@ -316,24 +318,26 @@ def test_execute_prints_warning_for_invalid_wheels(
base_url = "https://files.pythonhosted.org/"
wheel1 = "demo_invalid_record-0.1.0-py2.py3-none-any.whl"
wheel2 = "demo_invalid_record2-0.1.0-py2.py3-none-any.whl"
return_code = executor.execute([
Install(
Package(
"demo-invalid-record",
"0.1.0",
source_type="url",
source_url=f"{base_url}/{wheel1}",
)
),
Install(
Package(
"demo-invalid-record2",
"0.1.0",
source_type="url",
source_url=f"{base_url}/{wheel2}",
)
),
])
return_code = executor.execute(
[
Install(
Package(
"demo-invalid-record",
"0.1.0",
source_type="url",
source_url=f"{base_url}/{wheel1}",
)
),
Install(
Package(
"demo-invalid-record2",
"0.1.0",
source_type="url",
source_url=f"{base_url}/{wheel2}",
)
),
]
)

warning1 = f"""\
<warning>Warning: Validation of the RECORD file of {wheel1} failed.\
Expand Down Expand Up @@ -426,9 +430,11 @@ def test_execute_works_with_ansi_output(

executor = Executor(env, pool, config, io_decorated)

return_code = executor.execute([
Install(Package("cleo", "1.0.0a5")),
])
return_code = executor.execute(
[
Install(Package("cleo", "1.0.0a5")),
]
)

# fmt: off
expected = [
Expand Down Expand Up @@ -461,9 +467,11 @@ def test_execute_works_with_no_ansi_output(

executor = Executor(env, pool, config, io_not_decorated)

return_code = executor.execute([
Install(Package("cleo", "1.0.0a5")),
])
return_code = executor.execute(
[
Install(Package("cleo", "1.0.0a5")),
]
)

expected = """
Package operations: 1 install, 0 updates, 0 removals
Expand Down Expand Up @@ -626,12 +634,14 @@ def test_executor_should_not_write_pep610_url_references_for_cached_package(
io: BufferedIO,
) -> None:
link_cached = fixture_dir("distributions") / "demo-0.1.0-py2.py3-none-any.whl"
package.files = [{
"file": "demo-0.1.0-py2.py3-none-any.whl",
"hash": (
"sha256:70e704135718fffbcbf61ed1fc45933cfd86951a744b681000eaaa75da31f17a"
),
}]
package.files = [
{
"file": "demo-0.1.0-py2.py3-none-any.whl",
"hash": (
"sha256:70e704135718fffbcbf61ed1fc45933cfd86951a744b681000eaaa75da31f17a"
),
}
]

mocker.patch(
"poetry.installation.executor.Executor._download", return_value=link_cached
Expand All @@ -653,12 +663,14 @@ def test_executor_should_write_pep610_url_references_for_wheel_files(
url = (fixture_dir("distributions") / "demo-0.1.0-py2.py3-none-any.whl").resolve()
package = Package("demo", "0.1.0", source_type="file", source_url=url.as_posix())
# Set package.files so the executor will attempt to hash the package
package.files = [{
"file": "demo-0.1.0-py2.py3-none-any.whl",
"hash": (
"sha256:70e704135718fffbcbf61ed1fc45933cfd86951a744b681000eaaa75da31f17a"
),
}]
package.files = [
{
"file": "demo-0.1.0-py2.py3-none-any.whl",
"hash": (
"sha256:70e704135718fffbcbf61ed1fc45933cfd86951a744b681000eaaa75da31f17a"
),
}
]

executor = Executor(tmp_venv, pool, config, io)
executor.execute([Install(package)])
Expand Down Expand Up @@ -687,12 +699,14 @@ def test_executor_should_write_pep610_url_references_for_non_wheel_files(
url = (fixture_dir("distributions") / "demo-0.1.0.tar.gz").resolve()
package = Package("demo", "0.1.0", source_type="file", source_url=url.as_posix())
# Set package.files so the executor will attempt to hash the package
package.files = [{
"file": "demo-0.1.0.tar.gz",
"hash": (
"sha256:9fa123ad707a5c6c944743bf3e11a0e80d86cb518d3cf25320866ca3ef43e2ad"
),
}]
package.files = [
{
"file": "demo-0.1.0.tar.gz",
"hash": (
"sha256:9fa123ad707a5c6c944743bf3e11a0e80d86cb518d3cf25320866ca3ef43e2ad"
),
}
]

executor = Executor(tmp_venv, pool, config, io)
executor.execute([Install(package)])
Expand Down Expand Up @@ -796,12 +810,14 @@ def test_executor_should_write_pep610_url_references_for_wheel_urls(
source_url="https://files.pythonhosted.org/demo-0.1.0-py2.py3-none-any.whl",
)
# Set package.files so the executor will attempt to hash the package
package.files = [{
"file": "demo-0.1.0-py2.py3-none-any.whl",
"hash": (
"sha256:70e704135718fffbcbf61ed1fc45933cfd86951a744b681000eaaa75da31f17a"
),
}]
package.files = [
{
"file": "demo-0.1.0-py2.py3-none-any.whl",
"hash": (
"sha256:70e704135718fffbcbf61ed1fc45933cfd86951a744b681000eaaa75da31f17a"
),
}
]

executor = Executor(tmp_venv, pool, config, io)
operation = Install(package)
Expand Down Expand Up @@ -890,12 +906,14 @@ def mock_get_cached_archive_func(
source_url="https://files.pythonhosted.org/demo-0.1.0.tar.gz",
)
# Set package.files so the executor will attempt to hash the package
package.files = [{
"file": "demo-0.1.0.tar.gz",
"hash": (
"sha256:9fa123ad707a5c6c944743bf3e11a0e80d86cb518d3cf25320866ca3ef43e2ad"
),
}]
package.files = [
{
"file": "demo-0.1.0.tar.gz",
"hash": (
"sha256:9fa123ad707a5c6c944743bf3e11a0e80d86cb518d3cf25320866ca3ef43e2ad"
),
}
]

executor = Executor(tmp_venv, pool, config, io)
operation = Install(package)
Expand Down Expand Up @@ -1163,12 +1181,20 @@ def test_executor_fallback_on_poetry_create_error_without_wheel_installer(
"poetry.factory.Factory.create_poetry", side_effect=RuntimeError
)

config.merge({
"cache-dir": str(tmp_path),
"installer": {"modern-installation": False},
})
config.merge(
{
"cache-dir": str(tmp_path),
"installer": {"modern-installation": False},
}
)

executor = Executor(env, pool, config, io)
warning_lines = io.fetch_output().splitlines()
assert warning_lines == [
"Setting `installer.modern-installation` to `false` is deprecated.",
"The pip-based installer will be removed in a future release.",
"See https://github.com/python-poetry/poetry/issues/8987.",
]

directory_package = Package(
"simple-project",
Expand All @@ -1177,9 +1203,11 @@ def test_executor_fallback_on_poetry_create_error_without_wheel_installer(
source_url=fixture_dir("simple_project").resolve().as_posix(),
)

return_code = executor.execute([
Install(directory_package),
])
return_code = executor.execute(
[
Install(directory_package),
]
)

expected = f"""
Package operations: 1 install, 0 updates, 0 removals
Expand Down Expand Up @@ -1485,10 +1513,12 @@ def test_other_error(
},
),
(
[{
"file": "demo-0.1.0.tar.gz",
"hash": "md5:d1912c917363a64e127318655f7d1fe7",
}],
[
{
"file": "demo-0.1.0.tar.gz",
"hash": "md5:d1912c917363a64e127318655f7d1fe7",
}
],
{
"archive_info": {
"hashes": {"md5": "d1912c917363a64e127318655f7d1fe7"},
Expand Down

0 comments on commit 3d794ce

Please sign in to comment.