mirror of
https://github.com/davidhalter/jedi.git
synced 2025-12-15 18:17:07 +08:00
sys_path: prepend/prefer egg-link files
With `pip install -e` the generated .egg-link file gets preferred over any normally installed distribution, and `pip uninstall` will first remove the egg-link before the normal package.
This commit is contained in:
@@ -27,14 +27,13 @@ def get_venv_path(venv):
|
|||||||
def _get_sys_path_with_egglinks(sys_path):
|
def _get_sys_path_with_egglinks(sys_path):
|
||||||
"""Find all paths including those referenced by egg-links.
|
"""Find all paths including those referenced by egg-links.
|
||||||
|
|
||||||
Egg-link-referenced directories are inserted into path immediately after
|
Egg-link-referenced directories are inserted into path immediately before
|
||||||
the directory on which their links were found. Such directories are not
|
the directory on which their links were found. Such directories are not
|
||||||
taken into consideration by normal import mechanism, but they are traversed
|
taken into consideration by normal import mechanism, but they are traversed
|
||||||
when doing pkg_resources.require.
|
when doing pkg_resources.require.
|
||||||
"""
|
"""
|
||||||
result = []
|
result = []
|
||||||
for p in sys_path:
|
for p in sys_path:
|
||||||
result.append(p)
|
|
||||||
# pkg_resources does not define a specific order for egg-link files
|
# pkg_resources does not define a specific order for egg-link files
|
||||||
# using os.listdir to enumerate them, we're sorting them to have
|
# using os.listdir to enumerate them, we're sorting them to have
|
||||||
# reproducible tests.
|
# reproducible tests.
|
||||||
@@ -47,6 +46,7 @@ def _get_sys_path_with_egglinks(sys_path):
|
|||||||
# pkg_resources package only interprets the first
|
# pkg_resources package only interprets the first
|
||||||
# non-empty line in egg-link files.
|
# non-empty line in egg-link files.
|
||||||
break
|
break
|
||||||
|
result.append(p)
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -42,9 +42,9 @@ def test_get_venv_path(venv):
|
|||||||
site_pkgs = (glob(pjoin(venv, 'lib', 'python*', 'site-packages')) +
|
site_pkgs = (glob(pjoin(venv, 'lib', 'python*', 'site-packages')) +
|
||||||
glob(pjoin(venv, 'lib', 'site-packages')))[0]
|
glob(pjoin(venv, 'lib', 'site-packages')))[0]
|
||||||
ETALON = [
|
ETALON = [
|
||||||
site_pkgs,
|
|
||||||
pjoin('/path', 'from', 'egg-link'),
|
pjoin('/path', 'from', 'egg-link'),
|
||||||
pjoin(site_pkgs, '.', 'relative', 'egg-link', 'path'),
|
pjoin(site_pkgs, '.', 'relative', 'egg-link', 'path'),
|
||||||
|
site_pkgs,
|
||||||
pjoin(site_pkgs, 'dir-from-foo-pth'),
|
pjoin(site_pkgs, 'dir-from-foo-pth'),
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user