Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR is a first attempt at addressing the feature request from issue #704. I did not yet add/fix tests or add documentation, as I would first appreciate some feedback on (a) whether this is welcome at all, and (b) if yes, whether this PR is headed in the right direction.
Summary
This PR introduces a new
alias
command suite:poetry alias set fnord
– define “fnord” as alias for the current project. If a different project already used “fnord” as its alias, the command would abort with a corresponding error message. Note: only one alias can be defined per project—i.e., ifpoetry alias set ...
was called again, the current project’s alias would effectively be renamed.poetry alias show
– show the alias that has been defined for the current project.poetry alias list
– list all project aliases in alphabetical order along with their assigned project directories.poetry alias go fnord
– change to the directory of the project aliased “fnord” and executepoetry shell
there to activate the virtualenv. This only works if not already inside an activated virtualenv.poetry alias rm fnord
– remove the “fnord” project alias. The alias name is optional for this command; if omitted, the current project’s alias will be removed.poetry alias prune
– remove all aliases that no longer point to a project directory.poetry alias clean
– remove all alias definitions.Additionally,
poetry init
now also asks for a project alias, with the package name being the default value for it. Users can enter a period.
if they do not want to set an alias this way.Internally, all aliases are centrally stored in an
aliases.toml
file in the virtualenv cache directory, next toenvs.toml
. This PR’s central piece is thepoetry.utils.alias.AliasManager
class, with the console commands being thin wrappers around its functionality.Pull Request Check List
This is just a reminder about the most common mistakes. Please make sure that you tick all appropriate boxes. But please read our contribution guide at least once, it will save you unnecessary review cycles!