From 3059d88d17bd42d36de0a7f0d46c9a9269bd2c5a Mon Sep 17 00:00:00 2001 From: Gerrit-K Date: Fri, 5 Jan 2024 17:15:08 +0100 Subject: [PATCH 1/7] Use package.pretty_name in poetry version (#8849) --- src/poetry/console/commands/version.py | 2 +- tests/console/commands/test_version.py | 23 +++++++++++++++++++++++ 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/src/poetry/console/commands/version.py b/src/poetry/console/commands/version.py index 0af2a004719..7e8d118759c 100644 --- a/src/poetry/console/commands/version.py +++ b/src/poetry/console/commands/version.py @@ -86,7 +86,7 @@ def handle(self) -> int: self.line(self.poetry.package.pretty_version) else: self.line( - f"{self.poetry.package.name}" + f"{self.poetry.package.pretty_name}" f" {self.poetry.package.pretty_version}" ) diff --git a/tests/console/commands/test_version.py b/tests/console/commands/test_version.py index 8d671273bbb..4772a400be1 100644 --- a/tests/console/commands/test_version.py +++ b/tests/console/commands/test_version.py @@ -10,7 +10,10 @@ if TYPE_CHECKING: from cleo.testers.command_tester import CommandTester + from poetry.poetry import Poetry from tests.types import CommandTesterFactory + from tests.types import FixtureDirGetter + from tests.types import ProjectFactory @pytest.fixture() @@ -23,6 +26,18 @@ def tester(command_tester_factory: CommandTesterFactory) -> CommandTester: return command_tester_factory("version") +@pytest.fixture +def poetry_with_underscore( + project_factory: ProjectFactory, fixture_dir: FixtureDirGetter +) -> Poetry: + source = fixture_dir("simple_project") + pyproject_content = (source / "pyproject.toml").read_text(encoding="utf-8") + pyproject_content = pyproject_content.replace("simple-project", "simple_project") + return project_factory( + "project_with_underscore", pyproject_content=pyproject_content + ) + + @pytest.mark.parametrize( "version, rule, expected", [ @@ -79,6 +94,14 @@ def test_version_show(tester: CommandTester) -> None: assert tester.io.fetch_output() == "simple-project 1.2.3\n" +def test_version_show_with_underscore( + command_tester_factory: CommandTesterFactory, poetry_with_underscore: Poetry +) -> None: + tester = command_tester_factory("version", poetry=poetry_with_underscore) + tester.execute() + assert tester.io.fetch_output() == "simple_project 1.2.3\n" + + def test_short_version_show(tester: CommandTester) -> None: tester.execute("--short") assert tester.io.fetch_output() == "1.2.3\n" From 24828c71afa9ca85194b3e95f4a064165d781a6f Mon Sep 17 00:00:00 2001 From: Aniruddha Mukherjee Date: Fri, 5 Jan 2024 22:20:15 +0530 Subject: [PATCH 2/7] Add a warning about config in the docs for possible failure point (#8850) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Randy Döring <30527984+radoering@users.noreply.github.com> --- docs/cli.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/docs/cli.md b/docs/cli.md index eff8e9ab256..74ec6dc5334 100644 --- a/docs/cli.md +++ b/docs/cli.md @@ -580,6 +580,14 @@ poetry config [options] [setting-key] [setting-value1] ... [setting-valueN] `setting-key` is a configuration option name and `setting-value1` is a configuration value. See [Configuration]({{< relref "configuration" >}}) for all available settings. +{{% warning %}} +Use `--` to terminate option parsing if your values may start with a hyphen (`-`), e.g. +```bash +poetry config http-basic.custom-repo gitlab-ci-token -- ${GITLAB_JOB_TOKEN} +``` +Without `--` this command will fail if `${GITLAB_JOB_TOKEN}` starts with a hyphen. +{{% /warning%}} + ### Options * `--unset`: Remove the configuration element named by `setting-key`. From f09174e1daee9e79fd1b68831a9ac0a030d7c219 Mon Sep 17 00:00:00 2001 From: Arnaud Esteve Date: Fri, 5 Jan 2024 17:59:55 +0100 Subject: [PATCH 3/7] mention that the virtual environment poetry is installed in should not be activated (#8833) --- docs/_index.md | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/_index.md b/docs/_index.md index edd356119c3..094e91f7a60 100644 --- a/docs/_index.md +++ b/docs/_index.md @@ -28,6 +28,7 @@ Poetry should always be installed in a dedicated virtual environment to isolate It should in no case be installed in the environment of the project that is to be managed by Poetry. This ensures that Poetry's own dependencies will not be accidentally upgraded or uninstalled. (Each of the following installation methods ensures that Poetry is installed into an isolated environment.) +In addition, the isolated virtual environment in which poetry is installed should not be activated for running poetry commands. {{% /warning %}} {{% note %}} From 7497e457592336cc9f4f7ec2833225916b8b43d1 Mon Sep 17 00:00:00 2001 From: James Owers-Bardsley Date: Fri, 5 Jan 2024 17:06:51 +0000 Subject: [PATCH 4/7] Add note to help resolve confusion around `poetry run` and external env management (#8748) --- docs/basic-usage.md | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/docs/basic-usage.md b/docs/basic-usage.md index dd872f4a1c5..b9c0a0d7c41 100644 --- a/docs/basic-usage.md +++ b/docs/basic-usage.md @@ -128,6 +128,19 @@ any Poetry commands that expect to manipulate an environment. To run your script simply use `poetry run python your_script.py`. Likewise if you have command line tools such as `pytest` or `black` you can run them using `poetry run pytest`. +{{% note %}} +If managing your own virtual environment externally, you do not need to use `poetry run` or `poetry shell` since +you will, presumably, already have activated that virtual environment and made available the correct python instance. +For example, these commands should output the same python path: +```shell +conda activate your_env_name +which python +poetry run which python +poetry shell +which python +``` +{{% /note %}} + ### Activating the virtual environment The easiest way to activate the virtual environment is to create a nested shell with `poetry shell`. From 5df28eb972c4fb722179a8a3ba9fd0a340b9c45f Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 9 Jan 2024 12:04:43 +0100 Subject: [PATCH 5/7] [pre-commit.ci] pre-commit autoupdate (#8859) Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index fe7c98b7259..5f449fcffc4 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -32,6 +32,6 @@ repos: - id: validate_manifest - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.1.9 + rev: v0.1.11 hooks: - id: ruff From 7d3151631c57dbf021d3a98aca6ed5ab91e75eb9 Mon Sep 17 00:00:00 2001 From: Mathieu Dupuy Date: Tue, 9 Jan 2024 17:03:11 +0100 Subject: [PATCH 6/7] FAQ: remove reference to tox "isolated_build" and improve spelling (#8658) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Randy Döring <30527984+radoering@users.noreply.github.com> --- docs/faq.md | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/docs/faq.md b/docs/faq.md index 105592ce9bd..a9404955c01 100644 --- a/docs/faq.md +++ b/docs/faq.md @@ -83,8 +83,9 @@ If your package will be used as an application, it might be worth to define an u ### Is tox supported? -**Yes**. By using the [isolated builds](https://tox.readthedocs.io/en/latest/config.html#conf-isolated_build) `tox` provides, -you can use it in combination with the PEP 517 compliant build system provided by Poetry. +**Yes**. Provided that you are using `tox` >= 4, you can use it in combination with +the PEP 517 compliant build system provided by Poetry. (With tox 3, you have to set the +[isolated build](https://tox.wiki/en/3.27.1/config.html#conf-isolated_build) option.) So, in your `pyproject.toml` file, add this section if it does not already exist: @@ -97,10 +98,9 @@ build-backend = "poetry.core.masonry.api" `tox` can be configured in multiple ways. It depends on what should be the code under test and which dependencies should be installed. -#### Usecase #1 +#### Use case #1 ```ini [tox] -isolated_build = true [testenv] deps = @@ -112,10 +112,9 @@ commands = `tox` will create an `sdist` package of the project and uses `pip` to install it in a fresh environment. Thus, dependencies are resolved by `pip`. -#### Usecase #2 +#### Use case #2 ```ini [tox] -isolated_build = true [testenv] allowlist_externals = poetry @@ -126,13 +125,12 @@ commands = ``` `tox` will create an `sdist` package of the project and uses `pip` to install it in a fresh environment. -Thus, dependencies are resolved by `pip` in the first place. But afterwards we run Poetry, +Thus, dependencies are resolved by `pip` in the first place. But afterward we run Poetry, which will install the locked dependencies into the environment. -#### Usecase #3 +#### Use case #3 ```ini [tox] -isolated_build = true [testenv] skip_install = true @@ -198,7 +196,7 @@ For example, if Poetry builds a distribution for a project that uses a version t ### Poetry busts my Docker cache because it requires me to COPY my source files in before installing 3rd party dependencies -By default running `poetry install ...` requires you to have your source files present (both the "root" package and any directory path dependencies you might have). +By default, running `poetry install ...` requires you to have your source files present (both the "root" package and any directory path dependencies you might have). This interacts poorly with Docker's caching mechanisms because any change to a source file will make any layers (subsequent commands in your Dockerfile) re-run. For example, you might have a Dockerfile that looks something like this: From 05f39efa52deb801800309c6ee8cce7c17f61d49 Mon Sep 17 00:00:00 2001 From: Zanie Blue Date: Wed, 10 Jan 2024 09:54:20 -0600 Subject: [PATCH 7/7] Fix documentation for default `format` option for `include` and `exclude` (#8852) --- docs/pyproject.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/docs/pyproject.md b/docs/pyproject.md index 0d23d89ff02..aebad9f52ac 100644 --- a/docs/pyproject.md +++ b/docs/pyproject.md @@ -279,7 +279,9 @@ include = [ ] ``` -If no format is specified, it will default to include both `sdist` and `wheel`. +If no format is specified, `include` defaults to only `sdist`. + +In contrast, `exclude` defaults to both `sdist` and `wheel`. ```toml exclude = ["my_package/excluded.py"]