[BUG] [easy_install] bug on checking the path of the distribution location
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 2.9k
- Forks
- 1.4k
- Avg merge
- 1d 1h
- Merged PRs (30d)
- 1
Description
setuptools version
setuptools===68.2.2
Python version
Python 3.10
OS
Windows 11
Additional environment information
No response
Description
I can see if the package source path is already added to the PYTHONPATH then it's failing add the package source directory to the easy-install.pth when I run the "pip install -e ."
easy_install.py
def add(self, dist):
"""Add `dist` to the distribution map"""
new_path = dist.location not in self.paths and (
dist.location not in self.sitedirs
or
# account for '.' being in PYTHONPATH
dist.location == os.getcwd()
)
if new_path:
self.paths.append(dist.location)
self.dirty = True
super().add(dist)
In def add(self, dist) function in easy_install.py
dist.location == os.getcwd()
This code will return False, because the dist.location is already normcased during finalize_options in develop.py
target = _path.normpath(self.egg_base)
This target is passed as the location in Distribution
# Make a distribution for the package's source self.dist = pkg_resources.Distribution( target, pkg_resources.PathMetadata(target, os.path.abspath(ei.egg_info)), project_name=ei.egg_name, )
For example, if the dist.location and os.getcwd() is
dist.location = 'c:\users\abc\work\helloworld'
os.getcwd() = 'C:\Users\abc\work\helloworld'
The result is False, even though they are pointing same path.
it should be updated to
dist.location == os.path.normcase(os.getcwd())
easy_install.py
def add(self, dist):
"""Add `dist` to the distribution map"""
new_path = dist.location not in self.paths and (
dist.location not in self.sitedirs
or
# account for '.' being in PYTHONPATH
# dist.location is _path.nomcased but the os.getcwd() is not
dist.location == os.path.normcase(os.getcwd())
)
if new_path:
self.paths.append(dist.location)
self.dirty = True
super().add(dist)
Expected behavior
The path of source code should be added to the easy-install.pth file when it's installed as editable.
How to Reproduce
Add "." (current path) to the PYTHONPATH then run the "pip install -e ."
Output
If the easy-install.pth is not exist. it will not dump any error.
But if there is easy-install.pth file exist, it will show this erro.
File "C:\Users\...\lib\site-packages\setuptools\command\easy_install.py", line 1690, in save
self.dirty |= last_dirty or self.paths != self._init_paths
TypeError: unsupported operand type(s) for |=: 'list' and 'bool'
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in easy_install.py at DistributionMap.add and save, then compare the path normalization in develop.py's finalize_options. Reproduce on Windows with the current directory in PYTHONPATH and run pip install -e .; done means the source path is written to easy-install.pth without the reported TypeError.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- build-system
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 55/100