[x] If an exception occurs when executing a command, I executed it again in debug mode (-vvv option).
OS version and name: Ubuntu 18.04.1
importlib_metadata)When I build and install my package, bump the version, then build and install again, the metadata of the package is not always showing the right version, but an older version number. It works for the first version bump, but fails for further.
I am not sure whether this is doe to the way poetry installs the package, or whether this is a bug in importlib.
Step 1: Bump the version
$ poetry version patch
Bumping version from 0.1.1 to 0.1.2
Step 2: Build and install the package
$ poetry install -vvv --no-dev
...
Installing the current project: pi (0.1.2)
- Building package pi in editable mode
- Adding pi.pth to /tmp/test/folder/env/lib/python3.8/site-packages for /tmp/test/folder
- Adding the pi-0.1.2.dist-info directory to /tmp/test/folder/env/lib/python3.8/site-packages
Step 3: Check the metadata
$ python -c "from importlib.metadata import version; print(version('pi'))"
0.1.1
This should be 0.1.2, not 0.1.1.
To reproduce this, please have a look at the gist.
Would you mind finding the site-packages directory for your environment, and see if you can find a pi-0.1.1.dist-info directory in there?
Sure!
$ ls /tmp/test/folder/env/lib/python3.8/site-packages/pi-*
/tmp/test/folder/env/lib/python3.8/site-packages/pi-0.1.0.dist-info:
INSTALLER METADATA RECORD
/tmp/test/folder/env/lib/python3.8/site-packages/pi-0.1.1.dist-info:
INSTALLER METADATA RECORD
/tmp/test/folder/env/lib/python3.8/site-packages/pi-0.1.2.dist-info:
INSTALLER METADATA RECORD
PS:
I should add that the metadata are correctly shown when I reset my venv in between.
Following my gist: When I do make clean build test after the failure, the correct version number is shown. Most likely because I then have in my fresh venv's site-packages only the lastest pi-0.1.2.dist-info folder and no distracting other versions.
There should be only one of those dist-info directory per project. That might be the reason why importlib.metadata gets confused. What does pip show pi say? poetry version?
Both correctly say 0.1.2. But, importlib.metadata still finds 0.1.1.
In the end it does not matter much what pip or importlib.metadata say. I am pretty sure there should be only one dist-info directory per project. Looks like a bug to me.
If you delete the superfluous dist-info directories, everything is back to normal, right?
Yes.
This is equivalent to the effect of installing to a clean env, that I mentioned above.
I didn't have much time to look into, but it seems there is code to remove the old dist-info directory, it just didn't trigger. I also didn't see the corresponding debug message in my output.
@peldszus Looks to me like this piece of code would delete a pre-existing dist-info for the exact same version number. It does not seem to be looking for dist-info with different version numbers (lower or higher).
You're right, only the exact same version is removed, not older or newer ones. When initially looking at this code I got tricked by the for-loop into thinking it is iterating over all matching versions.
I propose to rename this issue into: "Existing dist-info of different versions are not removed from site-packages for local build".
I guess https://github.com/python-poetry/poetry/issues/2855 is related, is it?
I guess https://github.com/python-poetry/poetry/issues/2855 is related, is it?
Yes, indeed. 馃憤
And I won't rename this issue here, because the related #2918 is already exactly stating what I would have changed for.