-
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
Editable mode is gone since 1.1.0a2
#2725
Comments
The short answer here is that this is expected and highlights the fragility of how editable installs are handled today. This is an expected side-effect of the transition to a more standard approach to handle editable installs in PEP 517 build backends as recommended in PEP 610. This does not have any functional change in behaviour, and it is important to note that curently there is no formal implemented standard around this. Prior to #2400 (
Additional References: |
@snejus would be great to get some more details on how this is blocking your upgrade. |
Okay, this makes sense. Though considering that many people do rely on editable installs, I wouldn't say that releasing these changes is the best option (even if we're talking about pre-releases). I take my words back if (a) majority of things going on now depend on it being present or (b) it's about to be completed. For example, maybe it would be possible to isolate PEP 610 to a specific branch/letter of pre-releases (is that even a thing, really?), say I'm assuming here though that there is less coupling between things than there may actually be. Also, I've never seen a setup like this - probably because now I realise that it does sound like it'd be a pain in the ass to manage this kind of thing.
For example, I often have In general, I find having the most recent code available in all contexts (i.e. editable mode) more preferable than not. |
To be clear, in this context, functionality has not changed. The issue reported here has to do with how
In development environments this may be true for most cases excluding isolated testing. This is not desireable nor recommended in managed environments. |
This is also breaking our upgrade to 1.1.0 - we install a package in editable mode so we can, later in a docker build step, inject built protocol buffers into that package. Without editable mode this process breaks. Any ideas how to work around it in 1.1.0 series? |
Hello @adamf, the editable mode still works. The default behavior has changed. So if you define a path dependency, you have to set the
|
I've struggled with this: apparently, you cannot simply add the key My solution was to do this:
I wish I could simply run |
@dpompeu-xgeeks, Removing a package will "forget" its dependencies, isn't that a problem? When you add again, you get the latest. Switching with minimal impacts will the best behaviour. Refer the linked discussion; |
That's a good point. We got some changes in our This works for us, but doesn't seem feasible for other use cases, eg a public library which should be more flexible with its dependencies versions. |
Another workaround we used which worked more reliably, but with great effort:
(We use git to host our internal libraries). Being able to change existing dependency to editable mode would be much quicker. |
@dpompeu-xgeeks have you tried specifying those dependencies as local paths? I have been successfully using the following configuration: [tool.poetry.dependencies]
python = ">=3.6.2,<4"
beets = { path = "../beets", develop = true, extras = ["chroma", "discogs", "fetchart", "lastgenre", "mpdstats", "web"] }
beetcamp = { path = "../beetcamp", develop = true }
rich_tables = { path = "../rich-tables", develop = true }
beets-importreplace = { git = "https://github.com/edgars-supe/beets-importreplace.git" }
discogs-client = "*" As expected, poetry uses a $ print -l $VIRTUAL_ENV/lib/python3.10/site-packages/*.pth(:t)
beetcamp.pth
beets.pth
distutils-precedence.pth
rich_tables.pth
_virtualenv.pth Edit:
As you can see, the If this for some reason is not feasible for your application, I think |
@snejus , Are you talking about a scenario where there is a tag in your project and switch to git
Another possibility: Start with The main problem is the nuking part; as long as it is there in |
@nishantvarma, in the case above (specifying a git-based dependency) inclusion of Instead of that I provide a path to a local repository (e.g. |
@snejus: My problem is when I change from git to local paths: poetry does not apply the changes. I can reproduce this by creating a lib and app (using poetry 1.1.13): # mylib
$ echo 'print("Hello World from git tag")' > mylib.py
$ git commit -m "some message"
$ git rev-parse HEAD
cad773cb633c3d8be5ddd16ef6767d5d0bc6e7cc
$ git push # myapp
$ poetry add git+ssh://[email protected]:dpompeu-xgeeks/example-lib.git#cad773cb633c3d8be5ddd16ef6767d5d0bc6e7cc
$ cat myapp.py
import mylib.mylib
$ poetry run python myapp.py
Hello World from git tag Now let's say I want to make some changes and debug them locally before pushing: #mylib
$ echo 'print("Hello World from path")' > mylib.py
$ vim pyproject.toml # bump version, not sure if needed #myapp
$ vim pyproject.toml # mylib = {path = "../mylib/", develop = true }
$ poetry lock
$ poetry install
$ poetry run python myapp.py
Hello World from git tag # <--- no changes!!! My expectation is that poetry would use the local files. Instead, I'm either removing the package before, or giving up and just pushing experimental versions to git, which is a slow process. |
@nishantvarma: Thanks for the tip, I can confirm this works! It does seem better than removing the packages. However, I'd still hope this would work more simply: this way is prone to mistakes, eg forgetting to remove the package and then wondering why there are no changes. It has happened with different people in my project. Reproducing with the example above: $ rm -rf .venv/
$ poetry install
$ poetry run python myapp.py
Hello world from file |
@dpompeu-xgeeks Could you confirm I understood it correctly:
Could you also check what output do you see after running the following?
|
Thanks for the followup @snejus .
Yes, exactly. However, I don't get the latest changes after step 2.
Sure, here's the output: $ poetry run python myapp.py
Hello World from git tag # <--- no changes
$ poetry --version
Poetry version 1.1.13
$ poetry shell
Virtual environment already activated: /home/dpompeu/dev/experiments/poetry-experiment/myapp/.venv
$ grep . $VIRTUAL_ENV/lib/*/*/*.pth | grep -oP '\K/lib.*'
/lib/python3.8/site-packages/_virtualenv.pth:import _virtualenv
/lib/python3.8/site-packages/distutils-precedence.pth:import os; var = 'SETUPTOOLS_USE_DISTUTILS'; enabled = os.environ.get(var, 'local') == 'local'; enabled and __import__('_distutils_hack').add_shim();
/lib/python3.8/site-packages/myapp.pth:/home/dpompeu/dev/experiments/poetry-experiment/myapp
/lib/python3.8/site-packages/mylib.pth:/home/dpompeu/dev/experiments/poetry-experiment/mylib If I remove $ rm -rf .venv
$ poetry install
Creating virtualenv myapp in /home/dpompeu/dev/experiments/poetry-experiment/myapp/.venv
Installing dependencies from lock file
Warning: The lock file is not up to date with the latest changes in pyproject.toml. You may be getting outdated dependencies. Run update to update them.
Package operations: 1 install, 0 updates, 0 removals
• Installing mylib (0.2.0 /home/dpompeu/dev/experiments/poetry-experiment/mylib)
$ poetry run python myapp.py
Hello world from file # <--- correct changes
$ grep . $VIRTUAL_ENV/lib/*/*/*.pth | grep -oP '\K/lib.*'
/lib/python3.8/site-packages/_virtualenv.pth:import _virtualenv
/lib/python3.8/site-packages/distutils-precedence.pth:import os; var = 'SETUPTOOLS_USE_DISTUTILS'; enabled = os.environ.get(var, 'local') == 'local'; enabled and __import__('_distutils_hack').add_shim();
/lib/python3.8/site-packages/myapp.pth:/home/dpompeu/dev/experiments/poetry-experiment/myapp
/lib/python3.8/site-packages/mylib.pth:/home/dpompeu/dev/experiments/poetry-experiment/mylib |
I've tried doing the same in my machine and encountered your issue. After some investigation, it seems that To fix this, before adding the path dependency, run both Then, add the local path dependency and lock/install. It worked okay for me. |
Thanks for the input. I prefer the workaround provided by @nishantvarma , which does preserves
I'm glad there's a workaround but I don't think it's a good solution for the long term. In my team, there has been a lot of confusion about this, especially because poetry fails to update the dependency but writes successful messages anyway. It will be inevitable that someone will forget one of the steps and gets some unnecessary pain and loss of time. I think this deserves its own issue. I can create it and link to this thread. |
FYI this seems to be fixed by the recent release |
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. |
I am on the latest Poetry version.
I have searched the issues of this repo and believe that this is not a duplicate.
If an exception occurs when executing a command, I executed it again in debug mode (
-vvv
option).OS version and name: Ubuntu 18.04.4 LTS x86_64
Poetry version:
1.1.0a2-b2
Link of a Gist with the contents of your pyproject.toml file:
Issue
I've been using
1.1.0a1
version since the beginning and having seen the recent pre-release updates I thought I'd try them out. Unfortunately, it doesn't seem that Poetry has been able to install the root project in editable mode since1.1.0a2
pre-release. I've checked also checkeda3
andb2
and found the same behaviour.pip list
output using1.1.0a1
, as expected:and what I saw for the more recent pre-releases mentioned above:
It's telling me that the editable installation is in the
site-packages
- by this logic every each of my dependencies is an editable one too 😅Would be good to have sorted since it's something that's blocking me from updating. I'd be happy to help with this if you need extra hands.
See below for the
pyproject.toml
. The package metadata is altered a bitThe text was updated successfully, but these errors were encountered: