Skip to content

Commit

Permalink
Merge branch 'master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
GMouzourou authored Jan 6, 2024
2 parents 0957c00 + 7497e45 commit c2e85da
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 1 deletion.
1 change: 1 addition & 0 deletions docs/_index.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 %}}
Expand Down
13 changes: 13 additions & 0 deletions docs/basic-usage.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`.
Expand Down
8 changes: 8 additions & 0 deletions docs/cli.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`.
Expand Down
2 changes: 1 addition & 1 deletion src/poetry/console/commands/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ def handle(self) -> int:
self.line(self.poetry.package.pretty_version)
else:
self.line(
f"<comment>{self.poetry.package.name}</>"
f"<comment>{self.poetry.package.pretty_name}</>"
f" <info>{self.poetry.package.pretty_version}</>"
)

Expand Down
23 changes: 23 additions & 0 deletions tests/console/commands/test_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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",
[
Expand Down Expand Up @@ -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"
Expand Down

0 comments on commit c2e85da

Please sign in to comment.