Is working on branches with differing requirements possible?
See original GitHub issue- I have searched the issues of this repo and believe that this is not a duplicate.
- I have searched the documentation and believe that my question is not covered.
Question
I’m in the process of testing poetry for my python work. The one stumbling block I’ve hit is how to approach working on a different branch that has different requirements. (For example, working on a bug fix for the current version while still developing a new feature using different version of some dependencies.)
My workflow for this, is to clone a separate copy of the repo in a different directory for the bug fix. (Tests can take hours to run.) However, poetry appears to only allocate one virtualenv for the project, based on the name
field of pyproject.toml
.
How can I get poetry to maintain different virtualenvs for the same project?
Issue Analytics
- State:
- Created 5 years ago
- Reactions:1
- Comments:9 (5 by maintainers)
Top Results From Across the Web
How to work simultaneously on a few branches - Stack Overflow
I would imagine the best-practice method is to duplicate the repository and work in different folders on my computer for each branch --...
Read more >Stop Using Branches for Deploying to Different GitOps ...
Using different Git branches for deployment environments is a relic of the past. Pull requests and merges between different branches is ...
Read more >Working on two git branches at once with git worktree
In this post I describe how you can use git worktree to check out multiple branches at once, and some scenarios in which...
Read more >Branches in a Nutshell - Git SCM
Both of those changes are isolated in separate branches: you can switch back and forth between the branches and merge them together when...
Read more >About branches - GitHub Docs
Branches allow you to develop features, fix bugs, or safely experiment with new ideas in a contained area of your repository. You always...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Ok, to tackle this today, you could remove the virtual environment and let poetry recreate it after you checkout to another branch. The problem, of course, is that you’d have to reinstall everything, which may take some time even if everything’s cached.
In the future we can add a setting like
settings.virtualenvs.per-branch
, which would default to false. That would require some work, but it might be justifiable if it’s a commonly wanted feature and if the alternatives are not very good. I’ll leave this decision to @sdispater.If we get a greenlight, I can give this a go in a few days, after my finals.
Even though this issue has been solved more than four years ago, I would like to point to poetry’s
--remove-untracked
option. A possible workflow is:git checkout branch_you_want_to_work_on
poetry shell
poetry update
poetry install --remove-untracked
This way your venv only contains the packages specified in the poetry.lock file of the branch you switched to.