In virtual environment populated with `flit install -s` (editable), `python3 -m pip freeze` raises `AssertionError` on MacOS
See original GitHub issueEnvironment
- pip version: 20.2.3
- Python version: 3.8
- OS: MacOS 10.15.7 and Ubuntu 20.04 (tested on two different machines)
I created the virtual environments with python3 -m venv ...
and populated them with flit install -s
(which installs a local script as “editable” analogously to python3 -m pip install --editable .
.
Description
When I run `python3 -m pip freeze’ within the virtual environment, the following exception is raised:
ERROR: Exception:
Traceback (most recent call last):
File "/Users/tbaker/venvs/dcapenv/lib/python3.8/site-packages/pip/_internal/cli/base_command.py", line 228, in _main
status = self.run(options, args)
File "/Users/tbaker/venvs/dcapenv/lib/python3.8/site-packages/pip/_internal/commands/freeze.py", line 101, in run
for line in freeze(**freeze_kwargs):
File "/Users/tbaker/venvs/dcapenv/lib/python3.8/site-packages/pip/_internal/operations/freeze.py", line 67, in freeze
req = FrozenRequirement.from_dist(dist)
File "/Users/tbaker/venvs/dcapenv/lib/python3.8/site-packages/pip/_internal/operations/freeze.py", line 257, in from_dist
req = direct_url_as_pep440_direct_reference(
File "/Users/tbaker/venvs/dcapenv/lib/python3.8/site-packages/pip/_internal/utils/direct_url_helpers.py", line 49, in direct_url_as_pep440_direct_reference
assert not direct_url.info.editable
AssertionError
@sbidoul @chrahunt I note that this assertion error was introduced a few months ago (see #7612).
Expected behavior
I expected pip to display a list of installed modules, as it does when I run pip 20.2.3 within virtual environments created prior to mid-August, e.g.:
alabaster==0.7.12
appdirs==1.4.4
astroid==2.4.2
attrs==19.3.0
Babel==2.8.0
black==19.10b0
How to Reproduce
- Go to a Github repo with a Python script under development - or clone the small project mklists that I used for this test (and note its pyproject.toml.
- Create a virtual environment, e.g.:
python3 -m venv .venv
- Activate the virtual environment, e.g.:
source .venv/bin/activate
(MacOS) or. .venv/bin/activate
(Ubuntu) - Install
flit
:python3 -m pip install --upgrade flit
- Run
flit install -s
to install the local code as “editable”. - Run
python3 -m pip freeze
. - Instead of displaying a list of installed modules, an exception is raised (as described above).
Output (MacOS)
577 [master] ~/github/tombaker/mklists> python3 -m venv .venv
578 [master] ~/github/tombaker/mklists> source .venv/bin/activate
(.venv) 579 [master] ~/github/tombaker/mklists> python3 -m pip install --upgrade flit
Collecting flit
Using cached flit-3.0.0-py3-none-any.whl (48 kB)
... etc ...
Successfully installed certifi-2020.6.20 chardet-3.0.4 docutils-0.16 flit-3.0.0 flit-core-3.0.0 idna-2.10 pytoml-0.1.21 requests-2.24.0 urllib3-1.25.10
WARNING: You are using pip version 20.2.1; however, version 20.2.3 is available.
You should consider upgrading via the '/Users/tbaker/github/tombaker/mklists/.venv/bin/python3 -m pip install --upgrade pip' command.
(.venv) 580 [master] ~/github/tombaker/mklists> python3 -m pip install --upgrade pip
...
Successfully installed pip-20.2.3
(.venv) 581 [master] ~/github/tombaker/mklists> flit install -s
Extras to install for deps 'all': {'test', 'doc', '.none'} I-flit.install
Installing requirements I-flit.install
Collecting pytest
Using cached pytest-6.1.1-py3-none-any.whl (272 kB)
... etc ...
Successfully installed Jinja2-2.11.2 MarkupSafe-1.1.1 ... etc ...
Symlinking mklists -> /Users/tbaker/github/tombaker/mklists/.venv/lib/python3.8/site-packages/mklists I-flit.install
Writing script to /Users/tbaker/github/tombaker/mklists/.venv/bin/mklists I-flit.install
(.venv) 582 [master] ~/github/tombaker/mklists> python3 -m pip freeze
ERROR: Exception:
Traceback (most recent call last):
File "/Users/tbaker/github/tombaker/mklists/.venv/lib/python3.8/site-packages/pip/_internal/cli/base_command.py", line 228, in _main
status = self.run(options, args)
File "/Users/tbaker/github/tombaker/mklists/.venv/lib/python3.8/site-packages/pip/_internal/commands/freeze.py", line 101, in run
for line in freeze(**freeze_kwargs):
File "/Users/tbaker/github/tombaker/mklists/.venv/lib/python3.8/site-packages/pip/_internal/operations/freeze.py", line 67, in freeze
req = FrozenRequirement.from_dist(dist)
File "/Users/tbaker/github/tombaker/mklists/.venv/lib/python3.8/site-packages/pip/_internal/operations/freeze.py", line 257, in from_dist
req = direct_url_as_pep440_direct_reference(
File "/Users/tbaker/github/tombaker/mklists/.venv/lib/python3.8/site-packages/pip/_internal/utils/direct_url_helpers.py", line 49, in direct_url_as_pep440_direct_reference
assert not direct_url.info.editable
AssertionError
Note
On 13 October, I described this issue on Stackoverflow
Issue Analytics
- State:
- Created 3 years ago
- Comments:11 (6 by maintainers)
Top Results From Across the Web
Python virtual environments created since mid-August ...
The failure of pip freeze was indeed a bug in Pip 2.2. This bug has already been fixed for the upcoming Pip 2.3....
Read more >pip freeze - pip documentation v22.3.1
If in a virtualenv that has global access, do not output globally-installed packages. --user#. Only output packages installed in user-site.
Read more >pip Changelog
- Only calculate topological installation order, for packages that are going to be installed/upgraded. This fixes an `AssertionError` that occurred when ...
Read more >Pip freeze, vcs urls and pep 517 (feat. editable installs)
Hello, I'm posting here following a conversation on pip issue #609, where Chris Jerdonek suggested I bring the topic to this forum for...
Read more >Release Notes — pip 8.1.1 documentation
Add a --all option to pip freeze to include usually skipped package (like pip, ... installed item that is installed outside of a...
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 Free
Top 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
Flit 2.x didn’t do anything about the direct_url info - @sbidoul added it for 3.0. So no surprise that only Flit 3 causes this. I’ll trust Stéphane on what needs changing. 🙂
@tombaker thanks for the report. I think that’s a combination of flit generating the editable flag in direct_url.json (which is correct) and pip beeing confused because flit’s notion of editable is not recognized by pip. Perhaps this assert should be replaced with a warning or nothing at all. I’ll look into this.