-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
Install dependancies in virtualenv without adding it to pyproject.toml file #951
Comments
Does |
I was thinking about this issue while fixing coffee this morning, for whatever reason 😅 A somewhat clean way to do this would be to support nested keys under Default when doing This would accomplish the optional aspect, while also offering a cleaner way than entirely-untracked dev dependencies (so it can help with tracking known-good total snapshots of the pyproject.toml that people on your team / repo are using) |
@hangtwenty My goal is to not leave any trace at all in the |
# create a new project
❯ poetry new plic
Created package plic in plic
❯ cd plic
❯ ls
plic/ pyproject.toml README.rst tests/
# ipython seems to call my system ipython if not in virtualenv, ok
❯ which ipython
/home/antoine/.pyenv/shims/ipython
# ipython seems to call my system ipython also when in virtualenv, ok, it's falling back on system packages
❯ poetry run which ipython
/home/antoine/.pyenv/shims/ipython
# try to install ipython in the project virtualenv
❯ poetry run pip install ipython
Collecting ipython
Using cached https://files.pythonhosted.org/packages/14/3b/3fcf422a99a04ee493e6a4fc3014e3c8ff484a7feed238fef68bdc285085/ipython-7.3.0-py3-none-any.whl
<...lots of install output...>
Successfully installed backcall-0.1.0 decorator-4.3.2 ipython-7.3.0 ipython-genutils-0.2.0 jedi-0.13.3 parso-0.3.4 pexpect-4.6.0 pickleshare-0.7.5 prompt-toolkit-2.0.9 ptyprocess-0.6.0 pygments-2.3.1 six-1.12.0 traitlets-4.3.2 wcwidth-0.1.7
# ipython seems to be accessible using `poetry run` prefix
❯ poetry run which ipython
/home/antoine/.cache/pypoetry/virtualenvs/plic-py3.7/bin/ipython
# from inside poetry shell, yet, I'm getting back system ipython
❯ poetry shell
Spawning shell within /home/antoine/.cache/pypoetry/virtualenvs/plic-py3.7
# inside venv shell
plic-py3.7 ❯ which ipython
/home/antoine/.pyenv/shims/ipython
# exit poetry shell
❯ exit
❯ source source ~/.cache/pypoetry/virtualenvs/plic-py3.7/bin/activate.fish
plic-py3.7 ❯ which ipython
/home/antoine/.cache/pypoetry/virtualenvs/plic-py3.7/bin/ipython Looks like the shell is not correctly activated with fish shell For info, the equivalent sequence of actions works as expected in |
My subjective understanding is that 'the Poetry way' would want it to be reflected in the |
|
@antoine-gallix there are cases for either side of that argument given how dependencies can interact. But overall it's probably ideal to find a solution that does not require a TOML change, agreed. |
So I think the real issue is probably just the If I uninstall I think this issue becomes about is the difference between The main effect we are talking about here is the impact to |
@antoine-gallix could you run similar commands to the below, and we can see if we are reproducing the same thing?
|
seems related to #571 |
@antoine-gallix haha I was just about to post that! We were looking at the same time |
Related to #497 too (which may/maynot get closed in favor of solutions discussed on #571 ...?) But already can say, proper solution is not only about
|
OK so to summarize, my problem comes from the fact that the # works with the latest 1.0.0 version of poetry
function poetry_shell
source (poetry env info -p)/bin/activate.fish
end From there I can install things in the venv with |
Pasting a post for posterity, regarding virtualenv and https://pythonspeed.com/articles/activate-virtualenv-dockerfile/ |
You might still install a package with confliciting dependencies though. Perhaps it would make sense to have a special mode of |
True, that would be a nice feature. Something like |
Or |
Continuing the discussion from here
I think that the only sensible action for conflicting dependencies is to fail loudly. If someones wants to install the package anyway, he can always use plain
Trying to keep things simple is indeed an important goal. That being said, I think that this is a valid and not that uncommon usecase + adding an extra flag to |
I agree, though at that point I don't see what value Poetry is adding if any conflict leads to failure and it's specifically not locking dependencies. I would be concerned about mixed messaging about what Poetry is actually doing, though whether it actually is mixed messaging would depend on the resolution of #648, i.e., if Poetry defaults/prefers to remove dependencies not in the lock file then it seems like a conflicting feature to support installing things without locking them in the same tool.
|
The problem is that if you just blindly pip install some tool with conflicting dependencies you will break your application/library. The added value of using poetry to resolve the dependencies before installing it are:
Depending on how you do it, Installing things globally might break other stuff/tools.
Some tools, e.g. |
I can’t tell from this issue what the recommended approach is for this use case. It looks like the author of the issue closed it because they found a workaround involving a shell alias, but is that still the recommended approach? Thanks Amin advance for any guidance here! |
I'm running with poetry 1.3.2 and running |
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
Feature Request
My use case for my library is the following:
I have dependancies that I add with
poetry add <...>
. I have dev dependancies, that are required to run the tests, that I add withpoetry add --dev <...>
.Then there are tools that I use personnally to develop, but are not required to run tests. Examples are
ipython
,icecream
,pdb++
. Those are more personal preferencies that real requirements.I would need a way to install manually those dependencies inside the project virtualenv, without adding them to the
pyproject.toml
file. UsingPipenv
, I could just usepip
inside the environement without affecting thePipfile
. But insidepoetry shell
, if I use pip, it installs packages system wide (orpyenv
-wide in my case).For example if I
poetry shell
andpip install ipython
, it doesn't installipython
in the project's virtualenv.The text was updated successfully, but these errors were encountered: