Commit 173c8617 authored by Jason R. Coombs's avatar Jason R. Coombs

Merge branch 'issue-704'

parents 127dcab5 cd2a519c
...@@ -627,12 +627,20 @@ class easy_install(Command): ...@@ -627,12 +627,20 @@ class easy_install(Command):
(spec.key, self.build_directory) (spec.key, self.build_directory)
) )
@contextlib.contextmanager
def _tmpdir(self):
tmpdir = tempfile.mkdtemp(prefix=six.u("easy_install-"))
try:
# cast to str as workaround for #709 and #710 and #712
yield str(tmpdir)
finally:
os.path.exists(tmpdir) and rmtree(tmpdir)
def easy_install(self, spec, deps=False): def easy_install(self, spec, deps=False):
tmpdir = tempfile.mkdtemp(prefix="easy_install-")
if not self.editable: if not self.editable:
self.install_site_py() self.install_site_py()
try: with self._tmpdir() as tmpdir:
if not isinstance(spec, Requirement): if not isinstance(spec, Requirement):
if URL_SCHEME(spec): if URL_SCHEME(spec):
# It's a url, download it to tmpdir and process # It's a url, download it to tmpdir and process
...@@ -664,10 +672,6 @@ class easy_install(Command): ...@@ -664,10 +672,6 @@ class easy_install(Command):
else: else:
return self.install_item(spec, dist.location, tmpdir, deps) return self.install_item(spec, dist.location, tmpdir, deps)
finally:
if os.path.exists(tmpdir):
rmtree(tmpdir)
def install_item(self, spec, download, tmpdir, deps, install_needed=False): def install_item(self, spec, download, tmpdir, deps, install_needed=False):
# Installation is also needed if file in tmpdir or is not an egg # Installation is also needed if file in tmpdir or is not an egg
......
...@@ -241,8 +241,15 @@ def run_setup(setup_script, args): ...@@ -241,8 +241,15 @@ def run_setup(setup_script, args):
working_set.__init__() working_set.__init__()
working_set.callbacks.append(lambda dist: dist.activate()) working_set.callbacks.append(lambda dist: dist.activate())
# __file__ should be a byte string on Python 2 (#712)
dunder_file = (
setup_script
if isinstance(setup_script, str) else
setup_script.encode(sys.getfilesystemencoding())
)
def runner(): def runner():
ns = dict(__file__=setup_script, __name__='__main__') ns = dict(__file__=dunder_file, __name__='__main__')
_execfile(setup_script, ns) _execfile(setup_script, ns)
DirectorySandbox(setup_dir).run(runner) DirectorySandbox(setup_dir).run(runner)
......
...@@ -169,10 +169,8 @@ class TestEasyInstallTest: ...@@ -169,10 +169,8 @@ class TestEasyInstallTest:
sdist_zip.close() sdist_zip.close()
return str(sdist) return str(sdist)
@pytest.mark.xfail(reason="#709 and #710") @pytest.mark.xfail(setuptools.tests.is_ascii,
# also reason="https://github.com/pypa/setuptools/issues/706")
#@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): def test_unicode_filename_in_sdist(self, sdist_unicode, tmpdir, monkeypatch):
""" """
The install command should execute correctly even if The install command should execute correctly even if
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment