pypa / pypa/setuptools

Required package already installed redundantly added to easy-install.pth

Open
#400 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug major
Dominant language
Python
Stars
2.9k
Forks
1.4k
Avg merge
1d 1h
Merged PRs (30d)
1

Description

Originally reported by: robind42 (Bitbucket: robind42, GitHub: robind42)


We have a situation where there are already some packages installed in other site-package-like folders (in parent virtual environments in our case, all are on the sys.path). When another package is installed or develop-ed targeting the current site-packages folder and has one of those other packages as a requirement, then the location of the dependency is added to easy-install.pth eventhough it is already available on the sys.path. For example:

#!python
import sys; sys.__plen = len(sys.path)
/Users/robind/projects/tmp/setuptools
/Users/robind/projects/tmp/repeat
./argh-0.26.1-py2.7.egg
<ParentVenv0>/lib/python2.7/site-packages
<ParentVenv1>/lib/python2.7/site-packages
import sys; new=sys.path[sys.__plen:]; del sys.path[sys.__plen:]; p=getattr(sys,'__egginsert',0); sys.path[p:p]=new; sys.__egginsert = p+len(new)

At runtime this causes those additional paths to be searched much earlier than they should be, and potentially having older packages in those parent environments taking precedence over a newer version installed in the current environment. In this case at least removing those two site-packages lines fixes the import order issues because they are searched later after the current site-packges as intended.

Is there a reason why easy_install.process_distribution needs to call self.easy_install for requirement dists that are already installed? Just because their path is not in the easy-install.pth currenlty being worked on does not mean they are not present and active. The earlier call to WorkingSets([]).resolve found them in when it searched self.local_index, so perhaps they can be checked for there before calling self.easy_install for them.


Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with easy_install.process_distribution and trace its call to self.easy_install for requirements already found by WorkingSets([]). Check how the current easy-install.pth is updated when a dependency is already active on sys.path. Done means avoiding redundant path entries while preserving the intended import order; the issue does not name a regression test or file.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
build-system
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.