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

replace poetry plugin commands with more generic poetry self commands #5450

Merged
merged 12 commits into from
May 30, 2022

Conversation

abn
Copy link
Member

@abn abn commented Apr 14, 2022

Conceptual Changes

  1. The poetry instance's runtime additional packages are now maintained in <user-config-dir>/pypoetry/pyproject.toml instead of the current (1.2.0b1) localtion at the base of the virtual envrionment. This was changes in order to preserve plugin/additional package configuration even when the virtual environment (Poetry's runtime environment) was recreated. You can simply do poetry self install to get everything back in order. (Might need to implement self lock command to faciititate some use cases).
  2. The self command now simply switches context to <user-config-dir>/pypoetry and treats it as a Poetry managed project.
  3. Additional packages are stored in the tool.poetry.group.additional.dependencies section of the <user-config-dir>/pypoetry/pyproject.toml file and can be listed using poetry self show --addons.
  4. Additional packages can now be any package, not just Poetry plugins. This allows for use cases where you want to override a single dependency in the environment and/or add plugin for another package (eg: keyring, requests etc.).

Commands Added

self add

$ poetry self add --help

Description:
  Add additional packages to Poetry's runtime environment.

Usage:
  self add [options] [--] <name>...

Arguments:
  name                     The packages to add.

Options:
  -e, --editable           Add vcs/path dependencies as editable.
  -E, --extras=EXTRAS      Extras to activate for the dependency. (multiple values allowed)
      --source=SOURCE      Name of the source to use to install the package.
      --allow-prereleases  Accept prereleases.
      --dry-run            Output the operations but do not execute anything (implicitly enables --verbose).
<--snipped-->

Help:
  The self add command installs additional package's to Poetry's runtime environment.
  
  This is managed in the /home/abn/.config/pypoetry/pyproject.toml file.
  
  If you do not specify a version constraint, poetry will choose a suitable one based on the available package versions.
  
  You can specify a package in the following forms:
<--snipped-->

self remove

$ poetry self remove --help

Description:
  Remove additional packages from Poetry's runtime environment.

Usage:
  self remove [options] [--] <packages>...

Arguments:
  packages              The packages to remove.

Options:
      --dry-run         Output the operations but do not execute anything (implicitly enables --verbose).
<--snipped-->

Help:
  The self remove command removes additional package's to Poetry's runtime environment.
  
  This is managed in the /home/abn/.config/pypoetry/pyproject.toml file.

self install

$ poetry self install --help

Description:
  Add additional packages to Poetry's runtime environment.

Usage:
  self install [options]

Options:
      --sync            Synchronize the environment with the locked packages and the specified groups.
      --dry-run         Output the operations but do not execute anything (implicitly enables --verbose).
<--snipped-->

Help:
  The self install command all additional packages specified are installed in the current runtime environment.
  
  This is managed in the /home/abn/.config/pypoetry/pyproject.toml file.
  
  You can add more packages using the self add command and remove them using the self remove command.

self show

$ poetry self show --help

Description:
  Show packages from Poetry's runtime environment.

Usage:
  self show [options] [--] [<package>]

Arguments:
  package               The package to inspect

Options:
      --addons          List only add-on packages installed.
  -t, --tree            List the dependencies as a tree.
  -l, --latest          Show the latest version.
  -o, --outdated        Show the latest version but only for packages that are outdated.
<--snipped-->

Help:
  The self show command behaves similar to the show command, but
  working within Poetry's runtime environment. This lists all packages installed within
  the Poetry install environment.
  
  To show only additional packages that have been added via self add and their
  dependencies use self show --addons.
  
  This is managed in the /home/abn/.config/pypoetry/pyproject.toml file.

self show plugins

$ poetry self show plugins --help

Description:
  Shows information about the currently installed plugins.

Usage:
  self show plugins [options]

Options:
<--snipped-->

Help:
  The self show plugins command lists all installed Poetry plugins.
  
  Plugins can be added and removed using the self add and self remove commands respectively.
  
  This command does not list packages that do not provide a Poetry plugin.

Commands Changed

  1. self update now wraps around update instead for special handling.
  2. plugin add is now deprecated and re-routes to self add
  3. plugin remove is now deprecated and re-routes to self remove
  4. plugin show is now deprecated and re-routes to self show plugins

Example Usages

poetry self add artifacts-keyring
poetry self add git+https://github.com/python-poetry/poetry-core@master
poetry self add poetry-plugin-export

Testing

Using pipx

pipx install --suffix=@5450 'poetry @ git+https://github.com/python-poetry/poetry.git@refs/pull/5450/head'
poetry@5450 self add poetry-export-plugin
poetry@5450 self remove poetry-export-plugin
poetry@5450 self install --sync
poetry@5450 self update --preview
poetry@5450 self add artifacts-keyring
poetry@5450 self add git+https://github.com/python-poetry/poetry-core@master
cat ~/.config/pypoetry/pyproject.toml

Using a container (podman | docker)

podman run --rm -i --entrypoint bash docker.io/python:3.10 <<EOF
set -xe
python -m pip install -q git+https://github.com/python-poetry/poetry.git@refs/pull/5450/head
poetry self add poetry-export-plugin
poetry self remove poetry-export-plugin
poetry self install --sync
poetry self update --preview
poetry self add artifacts-keyring
poetry self add git+https://github.com/python-poetry/poetry-core@master
cat ~/.config/pypoetry/pyproject.toml
EOF

@abn abn requested a review from a team April 14, 2022 20:38
@abn abn force-pushed the refactor-plugin-management branch 2 times, most recently from c3ecbda to 8d92477 Compare April 14, 2022 23:14
@abn abn changed the title wip: replace poetry plugin commands with more generic poetry self commands replace poetry plugin commands with more generic poetry self commands Apr 15, 2022
@abn abn marked this pull request as ready for review April 15, 2022 23:02
@abn
Copy link
Member Author

abn commented Apr 15, 2022

Functional changes are ready for review. Will need to add some documentation changes.

@abn abn added this to the 1.2 milestone Apr 15, 2022
@abn abn force-pushed the refactor-plugin-management branch 5 times, most recently from 1d4c79b to 92c3986 Compare April 19, 2022 13:20
@abn abn force-pushed the refactor-plugin-management branch from 92c3986 to 9857880 Compare April 23, 2022 22:48
src/poetry/console/commands/self/self_command.py Outdated Show resolved Hide resolved
finswimmer
finswimmer previously approved these changes May 14, 2022
@abn
Copy link
Member Author

abn commented May 27, 2022

One scenario that has not been handled is a case where multiple poetry instances exist. Right now everything shares the config.

@abn abn force-pushed the refactor-plugin-management branch from 7ed4c68 to 90dd80c Compare May 27, 2022 16:47
@Secrus Secrus linked an issue May 30, 2022 that may be closed by this pull request
1 task
@abn abn force-pushed the refactor-plugin-management branch 2 times, most recently from 2eb14bb to 08778ce Compare May 30, 2022 17:07
@abn abn force-pushed the refactor-plugin-management branch from 08778ce to 5847c83 Compare May 30, 2022 17:11
@abn
Copy link
Member Author

abn commented May 30, 2022

@finswimmer gentle nudge

Copy link
Member

@finswimmer finswimmer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let it fly ✈️

@abn abn merged commit d5c22c2 into python-poetry:master May 30, 2022
@abn abn deleted the refactor-plugin-management branch May 30, 2022 18:45
ashnair1 added a commit to ashnair1/poetry that referenced this pull request May 30, 2022
@abn abn mentioned this pull request Jun 6, 2022
Copy link

This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 29, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area/docs Documentation issues/improvements
Projects
None yet
Development

Successfully merging this pull request may close these issues.

(📚) The documentation doesn't mention the self command at all
3 participants