Say I have this setup:
Running pip install with it as an index URL gives me this:
$ pip install packaging --index-url=/some/path
Looking in indexes: /some/path
Collecting packages
Url '/some/path/packaging/' is ignored. It is either a non-existing path or lacks a specific scheme.
Could not find a version that satisfies the requirement packaging (from versions: )
No matching distribution found for packaging
But if I create an empty directory under it…
$ mkdir /some/path/packaging
$ pip install packaging --index-url=/some/path
Looking in indexes: /some/path
Collecting packaging
Could not find a version that satisfies the requirement packaging (from versions: )
No matching distribution found for packaging
The warning message disappears.
The reason is probably this block of code:
|
for url in locations: |
|
|
|
is_local_path = os.path.exists(url) |
|
is_file_url = url.startswith('file:') |
|
|
|
if is_local_path or is_file_url: |
|
if is_local_path: |
|
path = url |
|
else: |
|
path = url_to_path(url) |
|
if os.path.isdir(path): |
|
if expand_dir: |
|
path = os.path.realpath(path) |
|
for item in os.listdir(path): |
|
sort_path(os.path.join(path, item)) |
|
elif is_file_url: |
|
urls.append(url) |
|
elif os.path.isfile(path): |
|
sort_path(path) |
|
else: |
|
logger.warning( |
|
"Url '%s' is ignored: it is neither a file " |
|
"nor a directory.", url, |
|
) |
|
elif is_url(url): |
|
# Only add url with clear scheme |
|
urls.append(url) |
|
else: |
|
logger.warning( |
|
"Url '%s' is ignored. It is either a non-existing " |
|
"path or lacks a specific scheme.", url, |
|
) |
A local path to an existing directory would go into the if branch at line 212, but would match either conditions inside (expand_dir is only true for --find-links, and this is a path, not URL), and is silently dropped.
The fix would be to add an extra else branch in the L212 if block, but I want to know what is the intended behaviour here. A file: URL would be allowed here (if the directory contains a valid index.html):
$ curl https://pypi.org/simple/packaging/ -o /some/path/packaging/index.html
...
$ pip install packaging --index-url file:///some/path
Looking in indexes: file:///some/path
Collecting packaging
Using cached https://files.pythonhosted.org/packages/89/d1/92e6df2e503a69df9faab187c684585f0136662c12bb1f36901d426f3fab/packaging-18.0-py2.py3-none-any.whl
...
Should a path be allowed as well?
Say I have this setup:
Running
pip installwith it as an index URL gives me this:But if I create an empty directory under it…
The warning message disappears.
The reason is probably this block of code:
pip/src/pip/_internal/index.py
Lines 202 to 233 in 4cc5f37
A local path to an existing directory would go into the if branch at line 212, but would match either conditions inside (
expand_diris only true for--find-links, and this is a path, not URL), and is silently dropped.The fix would be to add an extra else branch in the L212 if block, but I want to know what is the intended behaviour here. A
file:URL would be allowed here (if the directory contains a validindex.html):Should a path be allowed as well?