diff options
| -rw-r--r-- | .travis.yml | 2 | ||||
| -rw-r--r-- | CHANGES.rst | 7 | ||||
| -rw-r--r-- | appveyor.yml | 3 | ||||
| -rwxr-xr-x | setuptools/command/easy_install.py | 36 | ||||
| -rw-r--r-- | setuptools/tests/fixtures.py | 16 | ||||
| -rw-r--r-- | setuptools/tests/test_easy_install.py | 53 | ||||
| -rw-r--r-- | setuptools/tests/test_msvc.py | 4 |
7 files changed, 75 insertions, 46 deletions
diff --git a/.travis.yml b/.travis.yml index e91f7e78..32b664d8 100644 --- a/.travis.yml +++ b/.travis.yml @@ -20,7 +20,7 @@ script: # update egg_info based on setup.py in checkout - python bootstrap.py - - python setup.py test --addopts='-rs' + - python setup.py test --addopts='-rsx' before_deploy: - export SETUPTOOLS_INSTALL_WINDOWS_SPECIFIC_FILES=1 diff --git a/CHANGES.rst b/CHANGES.rst index 77bd1c79..13ffe9e7 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -2,6 +2,13 @@ CHANGES ======= +v25.1.2 +------- + +* #704: Fix errors when installing a zip sdist which contained + files named with non-ascii characters on Windows would + crash the install when it attempted to clean up the build. + v25.1.1 ------- diff --git a/appveyor.yml b/appveyor.yml index 4ae6c791..ebf446bf 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -2,6 +2,7 @@ environment: matrix: - PYTHON: "C:\\Python35-x64" + - PYTHON: "C:\\Python27-x64" install: # symlink python from a directory with a space @@ -13,4 +14,4 @@ build: off test_script: - "python bootstrap.py" - - "python setup.py test" + - "python setup.py test --addopts='-rsx'" diff --git a/setuptools/command/easy_install.py b/setuptools/command/easy_install.py index 0e0dc2c4..4783ce48 100755 --- a/setuptools/command/easy_install.py +++ b/setuptools/command/easy_install.py @@ -627,7 +627,7 @@ class easy_install(Command): ) def easy_install(self, spec, deps=False): - tmpdir = tempfile.mkdtemp(prefix="easy_install-") + tmpdir = tempfile.mkdtemp(prefix=six.u("easy_install-")) if not self.editable: self.install_site_py() @@ -2230,39 +2230,7 @@ def load_launcher_manifest(name): def rmtree(path, ignore_errors=False, onerror=auto_chmod): - """Recursively delete a directory tree. - - This code is taken from the Python 2.4 version of 'shutil', because - the 2.3 version doesn't really work right. - """ - if ignore_errors: - def onerror(*args): - pass - elif onerror is None: - def onerror(*args): - raise - names = [] - try: - names = os.listdir(path) - except os.error: - onerror(os.listdir, path, sys.exc_info()) - for name in names: - fullname = os.path.join(path, name) - try: - mode = os.lstat(fullname).st_mode - except os.error: - mode = 0 - if stat.S_ISDIR(mode): - rmtree(fullname, ignore_errors, onerror) - else: - try: - os.remove(fullname) - except os.error: - onerror(os.remove, fullname, sys.exc_info()) - try: - os.rmdir(path) - except os.error: - onerror(os.rmdir, path, sys.exc_info()) + return shutil.rmtree(path, ignore_errors, onerror) def current_umask(): diff --git a/setuptools/tests/fixtures.py b/setuptools/tests/fixtures.py index c70c38cb..5204c8d1 100644 --- a/setuptools/tests/fixtures.py +++ b/setuptools/tests/fixtures.py @@ -1,24 +1,20 @@ -try: - from unittest import mock -except ImportError: - import mock import pytest from . import contexts @pytest.yield_fixture -def user_override(): +def user_override(monkeypatch): """ Override site.USER_BASE and site.USER_SITE with temporary directories in a context. """ with contexts.tempdir() as user_base: - with mock.patch('site.USER_BASE', user_base): - with contexts.tempdir() as user_site: - with mock.patch('site.USER_SITE', user_site): - with contexts.save_user_site_setting(): - yield + monkeypatch.setattr('site.USER_BASE', user_base) + with contexts.tempdir() as user_site: + monkeypatch.setattr('site.USER_SITE', user_site) + with contexts.save_user_site_setting(): + yield @pytest.yield_fixture diff --git a/setuptools/tests/test_easy_install.py b/setuptools/tests/test_easy_install.py index 11299c7c..b2094901 100644 --- a/setuptools/tests/test_easy_install.py +++ b/setuptools/tests/test_easy_install.py @@ -14,6 +14,7 @@ import logging import itertools import distutils.errors import io +import zipfile import time from setuptools.extern.six.moves import urllib @@ -135,6 +136,58 @@ class TestEasyInstallTest: monkeypatch.delattr(site, 'getsitepackages', raising=False) assert ei.get_site_dirs() + @pytest.fixture + def sdist_unicode(self, tmpdir): + files = [ + ( + 'setup.py', + DALS(""" + import setuptools + setuptools.setup( + name="setuptools-test-unicode", + version="1.0", + packages=["mypkg"], + include_package_data=True, + ) + """), + ), + ( + 'mypkg/__init__.py', + "", + ), + ( + u'mypkg/\u2603.txt', + "", + ), + ] + sdist_name = 'setuptools-test-unicode-1.0.zip' + sdist = tmpdir / sdist_name + # can't use make_sdist, because the issue only occurs + # with zip sdists. + sdist_zip = zipfile.ZipFile(str(sdist), 'w') + for filename, content in files: + sdist_zip.writestr(filename, content) + sdist_zip.close() + return str(sdist) + + @pytest.mark.xfail(setuptools.tests.is_ascii, + reason="https://github.com/pypa/setuptools/issues/706") + def test_unicode_filename_in_sdist(self, sdist_unicode, tmpdir, monkeypatch): + """ + The install command should execute correctly even if + the package has unicode filenames. + """ + dist = Distribution({'script_args': ['easy_install']}) + target = (tmpdir / 'target').ensure_dir() + cmd = ei.easy_install( + dist, + install_dir=str(target), + args=['x'], + ) + monkeypatch.setitem(os.environ, 'PYTHONPATH', str(target)) + cmd.ensure_finalized() + cmd.easy_install(sdist_unicode) + class TestPTHFileWriter: diff --git a/setuptools/tests/test_msvc.py b/setuptools/tests/test_msvc.py index a0c76ea0..8c7e17d3 100644 --- a/setuptools/tests/test_msvc.py +++ b/setuptools/tests/test_msvc.py @@ -6,6 +6,8 @@ import os import contextlib import distutils.errors +from setuptools.extern import six + import pytest try: from unittest import mock @@ -71,6 +73,8 @@ class TestModulePatch: mod_name = distutils.msvc9compiler.find_vcvarsall.__module__ assert mod_name == "setuptools.msvc", "find_vcvarsall unpatched" + @pytest.mark.xfail(six.PY2, + reason="https://github.com/pypa/setuptools/issues/707") def test_no_registry_entries_means_nothing_found(self): """ No registry entries or environment variable should lead to an error |
