Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix unicode isses in pip install #7138

Closed
wants to merge 12 commits into from
1 change: 1 addition & 0 deletions news/1399.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix unicode filename issues on Windows
7 changes: 4 additions & 3 deletions src/pip/_internal/wheel.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import compileall
import csv
import hashlib
import io
import logging
import os.path
import re
Expand Down Expand Up @@ -103,15 +104,15 @@ def rehash(path, blocksize=1 << 20):
return (digest, str(length)) # type: ignore


def open_for_csv(name, mode):
# type: (str, Text) -> IO
def open_for_csv(name, mode, encoding='utf8'):
# type: (str, Text, str) -> IO
if sys.version_info[0] < 3:
nl = {} # type: Dict[str, Any]
bin = 'b'
else:
nl = {'newline': ''} # type: Dict[str, Any]
bin = ''
return open(name, mode + bin, **nl)
return io.open(name, mode + bin, **nl)


def replace_python_tag(wheelname, new_tag):
Expand Down
Binary file not shown.
8 changes: 8 additions & 0 deletions tests/data/src/unicode_files/setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
from setuptools import find_packages, setup

setup(
name="test_unicode",
packages=find_packages(),
version='1.0',
description="A sample unicode project",
)
Empty file.
Empty file.
15 changes: 15 additions & 0 deletions tests/functional/test_install_wheel.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,21 @@ def test_basic_install_from_wheel(script, data):
assert script_file in result.files_created


def test_basic_install_from_unicode_wheel(script, data):
"""
Test installing from a wheel (that has a script)
"""
result = script.pip(
'install', 'test_unicode==1.0', '--no-index',
'--find-links=' + data.find_links,
expect_error=False,
)
dist_info_folder = script.site_packages / 'test_unicode-1.0.dist-info'
assert dist_info_folder in result.files_created, (dist_info_folder,
result.files_created,
result.stdout)


def test_basic_install_from_wheel_with_extras(script, data):
"""
Test installing from a wheel with extras.
Expand Down