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
593b409f
Commit
593b409f
authored
May 14, 2018
by
Arnon Yaari
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use canonicalize_name to look for .dist-info in wheel files
Fixes issue #1350
parent
5dddf7f2
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
47 additions
and
2 deletions
+47
-2
setuptools/tests/test_wheel.py
setuptools/tests/test_wheel.py
+33
-0
setuptools/wheel.py
setuptools/wheel.py
+14
-2
No files found.
setuptools/tests/test_wheel.py
View file @
593b409f
...
...
@@ -9,12 +9,15 @@ import contextlib
import
glob
import
inspect
import
os
import
shutil
import
subprocess
import
sys
import
zipfile
import
pytest
from
pkg_resources
import
Distribution
,
PathMetadata
,
PY_MAJOR
from
setuptools.extern.packaging.utils
import
canonicalize_name
from
setuptools.wheel
import
Wheel
from
.contexts
import
tempdir
...
...
@@ -506,3 +509,33 @@ def test_wheel_install(params):
_check_wheel_install
(
filename
,
install_dir
,
install_tree
,
project_name
,
version
,
requires_txt
)
def
test_wheel_install_pep_503
():
project_name
=
'Foo_Bar'
# PEP 503 canonicalized name is "foo-bar"
version
=
'1.0'
with
build_wheel
(
name
=
project_name
,
version
=
version
,
)
as
filename
,
tempdir
()
as
install_dir
:
new_filename
=
filename
.
replace
(
project_name
,
canonicalize_name
(
project_name
))
shutil
.
move
(
filename
,
new_filename
)
_check_wheel_install
(
new_filename
,
install_dir
,
None
,
canonicalize_name
(
project_name
),
version
,
None
)
def
test_wheel_no_dist_dir
():
project_name
=
'nodistinfo'
version
=
'1.0'
wheel_name
=
'{0}-{1}-py2.py3-none-any.whl'
.
format
(
project_name
,
version
)
with
tempdir
()
as
source_dir
:
wheel_path
=
os
.
path
.
join
(
source_dir
,
wheel_name
)
# create an empty zip file
zipfile
.
ZipFile
(
wheel_path
,
'w'
).
close
()
with
tempdir
()
as
install_dir
:
with
pytest
.
raises
(
ValueError
):
_check_wheel_install
(
wheel_path
,
install_dir
,
None
,
project_name
,
version
,
None
)
setuptools/wheel.py
View file @
593b409f
...
...
@@ -4,10 +4,12 @@ from distutils.util import get_platform
import
email
import
itertools
import
os
import
posixpath
import
re
import
zipfile
from
pkg_resources
import
Distribution
,
PathMetadata
,
parse_version
from
setuptools.extern.packaging.utils
import
canonicalize_name
from
setuptools.extern.six
import
PY3
from
setuptools
import
Distribution
as
SetuptoolsDistribution
from
setuptools
import
pep425tags
...
...
@@ -77,14 +79,24 @@ class Wheel(object):
platform=(None if self.platform == 'any' else get_platform()),
).egg_name() + '.egg'
def get_dist_info(self, zf):
# find the correct name of the .dist-info dir in the wheel file
for member in zf.namelist():
dirname = posixpath.dirname(member)
if (dirname.endswith('.dist-info') and
canonicalize_name(dirname).startswith(
canonicalize_name(self.project_name))):
return dirname
raise ValueError("unsupported wheel format. .dist-info not found")
def install_as_egg(self, destination_eggdir):
'''Install wheel as an egg directory.'''
with zipfile.ZipFile(self.filename) as zf:
dist_basename = '%s-%s' % (self.project_name, self.version)
dist_info =
'%s.dist-info' % dist_basename
dist_info =
self.get_dist_info(zf)
dist_data = '%s.data' % dist_basename
def get_metadata(name):
with zf.open(
'%s/%s' %
(dist_info, name)) as fp:
with zf.open(
posixpath.join
(dist_info, name)) as fp:
value = fp.read().decode('utf-8') if PY3 else fp.read()
return email.parser.Parser().parsestr(value)
wheel_metadata = get_metadata('WHEEL')
...
...
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