question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Add pew style project management to peotry

See original GitHub issue
  • [ X] I have searched the issues of this repo and believe that this is not a duplicate.

Issue

pew, an alternative way to manage virtualenv, has a “project” feature. You give a name to a virtualenv (pew new venv_name), then tie this name to the directory (pew setproject .). You can then activate the virtualenv from anywhere doing pew workon venv_name. It will activate the venv whether you are in the project dir or not. If you are not in the project dir, it will cd you to the project dir. It will do so even if the virtualenv is already activated.

Poetry doesn’t work by virtualenv name though, so the feature would need a tweak. We could imagine it as a alias, with an API like:

$ poetry alias name src_dir # give a name to the directory / virtualenv pair
$ poetry aliases # list all name + src directory + venv dir
$ poetry go name  # activate venv and cd to the src dir 
$ poetry rmaliase name # remove the alias
$ poetry init # also prompt for the project alias name

Because poetry init already asks for a package name, it can offer to use this name as an alias by default, provided it’s not already used elsewhere (which will happen if you have several versions of the same code lying around). Of course the user is free to type in whatever he or she wants, and should be able to disable the automatic cd.

This does require a persistent setting file in the user directory to list all aliases (is it ok to put it in config.toml ?), and some error handling for the case where an alias reference a missing project.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:91
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
zvolskycommented, Jan 26, 2021

In fact this is a single reason why I need virtualenvwrapper together with poetry. This makes me problems with use of non-poetry virtualenv (virtualenvwrapper creates venvs in ~/.virtualenvs) and I sure would prefer the poetry way of venvs management because here is good integration with pyenv. However the workon <project> is too worth for me. So I still use the old style venvs 😦

So it would be really nice to have poetry workon ... (or poetry go ... as proposed here). I think the idea of alias presented here could be good. But it should be a little more analyzed how it could integrate with poetry/pyenv possibility to have 2+ venvs for 1 project but for 2+ different python versions.

0reactions
yggi49commented, Dec 5, 2021

I think this goes beyond the purpose of Poetry. However, once the plugin system (see #1237) is ready that might be a good fit for it.

I just made a first attempt at that. If you are interested, check out poetry-alias—feedback appreciated.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Dependency Management With Python Poetry
Learn how Python Poetry will help you start new projects, maintain existing ones, and master dependency management.
Read more >
Add pew style project management to peotry #704 - GitHub
Issue pew, an alternative way to manage virtualenv, has a "project" feature. You give a name to a virtualenv (pew new venv_name), ...
Read more >
Basic usage | Documentation | Poetry - Python dependency ...
First, let's create our new project, let's call it poetry-demo : poetry new poetry-demo. This will create the poetry-demo directory with the following ......
Read more >
Package Python Projects the Proper Way with Poetry
Create a Python project via Poetry CLI. This is an absurdly convenient way to generate a standard Python folder structure for our new...
Read more >
Using Poetry to manage Python projects - YouTube
Poetry provides an all-in-one tool for setting up projects, including virtual environments, dependency management, and many other moving ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found