Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
setuptools
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jérome Perrin
setuptools
Commits
e7ff68af
Commit
e7ff68af
authored
Jul 31, 2017
by
Jason R. Coombs
Committed by
GitHub
Jul 31, 2017
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1116 from leorochael/fix-462
Better detect unpacked eggs
parents
49df713e
e265e456
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
88 additions
and
5 deletions
+88
-5
.gitignore
.gitignore
+1
-0
CHANGES.rst
CHANGES.rst
+6
-0
pkg_resources/__init__.py
pkg_resources/__init__.py
+14
-4
pkg_resources/tests/test_find_distributions.py
pkg_resources/tests/test_find_distributions.py
+65
-0
setup.py
setup.py
+1
-1
tests/requirements.txt
tests/requirements.txt
+1
-0
No files found.
.gitignore
View file @
e7ff68af
...
...
@@ -7,6 +7,7 @@ lib
distribute.egg-info
setuptools.egg-info
.coverage
.eggs
.tox
*.egg
*.py[cod]
...
...
CHANGES.rst
View file @
e7ff68af
v36
.2.6
-------
*
#
462
:
Don
't assume a directory is an egg by the ``.egg``
extension alone.
v36.2.5
-------
...
...
pkg_resources/__init__.py
View file @
e7ff68af
...
...
@@ -1553,7 +1553,7 @@ class EggProvider(NullProvider):
path = self.module_path
old = None
while path != old:
if _is_
unpacked_egg
(path):
if _is_
egg_path
(path):
self.egg_name = os.path.basename(path)
self.egg_info = os.path.join(path, 'EGG-INFO')
self.egg_root = path
...
...
@@ -1956,7 +1956,7 @@ def find_eggs_in_zip(importer, path_item, only=False):
# don't yield nested distros
return
for subitem in metadata.resource_listdir('/'):
if _is_
unpacked_egg
(subitem):
if _is_
egg_path
(subitem):
subpath = os.path.join(path_item, subitem)
for dist in find_eggs_in_zip(zipimport.zipimporter(subpath), subpath):
yield dist
...
...
@@ -2033,7 +2033,7 @@ def find_on_path(importer, path_item, only=False):
yield Distribution.from_location(
path_item, entry, metadata, precedence=DEVELOP_DIST
)
elif not only and _is_
unpacked_egg
(entry):
elif not only and _is_
egg_path
(entry):
dists = find_distributions(os.path.join(path_item, entry))
for dist in dists:
yield dist
...
...
@@ -2221,12 +2221,22 @@ def _normalize_cached(filename, _cache={}):
return result
def _is_egg_path(path):
"""
Determine
if
given
path
appears
to
be
an
egg
.
"""
return (
path.lower().endswith('.egg')
)
def _is_unpacked_egg(path):
"""
Determine
if
given
path
appears
to
be
an
unpacked
egg
.
"""
return (
path.lower().endswith('.egg')
_is_egg_path(path) and
os.path.isfile(os.path.join(path, 'EGG-INFO', 'PKG-INFO'))
)
...
...
pkg_resources/tests/test_find_distributions.py
0 → 100644
View file @
e7ff68af
import
subprocess
import
sys
import
pytest
import
pkg_resources
SETUP_TEMPLATE
=
"""
import setuptools
setuptools.setup(
name="my-test-package",
version="1.0",
zip_safe=True,
)
"""
.
lstrip
()
class
TestFindDistributions
:
@
pytest
.
fixture
def
target_dir
(
self
,
tmpdir
):
target_dir
=
tmpdir
.
mkdir
(
'target'
)
# place a .egg named directory in the target that is not an egg:
target_dir
.
mkdir
(
'not.an.egg'
)
return
str
(
target_dir
)
@
pytest
.
fixture
def
project_dir
(
self
,
tmpdir
):
project_dir
=
tmpdir
.
mkdir
(
'my-test-package'
)
(
project_dir
/
"setup.py"
).
write
(
SETUP_TEMPLATE
)
return
str
(
project_dir
)
def
test_non_egg_dir_named_egg
(
self
,
target_dir
):
dists
=
pkg_resources
.
find_distributions
(
target_dir
)
assert
not
list
(
dists
)
def
test_standalone_egg_directory
(
self
,
project_dir
,
target_dir
):
# install this distro as an unpacked egg:
args
=
[
sys
.
executable
,
'-c'
,
'from setuptools.command.easy_install import main; main()'
,
'-mNx'
,
'-d'
,
target_dir
,
'--always-unzip'
,
project_dir
,
]
subprocess
.
check_call
(
args
)
dists
=
pkg_resources
.
find_distributions
(
target_dir
)
assert
[
dist
.
project_name
for
dist
in
dists
]
==
[
'my-test-package'
]
dists
=
pkg_resources
.
find_distributions
(
target_dir
,
only
=
True
)
assert
not
list
(
dists
)
def
test_zipped_egg
(
self
,
project_dir
,
target_dir
):
# install this distro as an unpacked egg:
args
=
[
sys
.
executable
,
'-c'
,
'from setuptools.command.easy_install import main; main()'
,
'-mNx'
,
'-d'
,
target_dir
,
'--zip-ok'
,
project_dir
,
]
subprocess
.
check_call
(
args
)
dists
=
pkg_resources
.
find_distributions
(
target_dir
)
assert
[
dist
.
project_name
for
dist
in
dists
]
==
[
'my-test-package'
]
dists
=
pkg_resources
.
find_distributions
(
target_dir
,
only
=
True
)
assert
not
list
(
dists
)
setup.py
View file @
e7ff68af
...
...
@@ -89,7 +89,7 @@ def pypi_link(pkg_filename):
setup_params
=
dict
(
name
=
"setuptools"
,
version
=
"36.2.
5
"
,
version
=
"36.2.
6
"
,
description
=
"Easily download, build, install, upgrade, and uninstall "
"Python packages"
,
author
=
"Python Packaging Authority"
,
...
...
tests/requirements.txt
View file @
e7ff68af
importlib; python_version<"2.7"
mock
pytest-flake8; python_version>="2.7"
virtualenv>=13.0.0
pytest-virtualenv>=1.2.7
pytest>=3.0.2
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment