aboutsummaryrefslogtreecommitdiffstats
path: root/setuptools
diff options
context:
space:
mode:
authorErik Bray <embray@stsci.edu>2012-09-06 15:51:09 -0400
committerErik Bray <embray@stsci.edu>2012-09-06 15:51:09 -0400
commitd847dbfeee2b2c85d7bc0a66813c33836a9850fa (patch)
treecf4b50b5a36018e59664e0a3b0ab6866db53c461 /setuptools
parent9ebbe014df37c19976a5a9cb0ac2fa228a03144a (diff)
downloadexternal_python_setuptools-d847dbfeee2b2c85d7bc0a66813c33836a9850fa.tar.gz
external_python_setuptools-d847dbfeee2b2c85d7bc0a66813c33836a9850fa.tar.bz2
external_python_setuptools-d847dbfeee2b2c85d7bc0a66813c33836a9850fa.zip
Adds a fix for issue #318, including a regression test. This also fixes another test that was passing trivially due to *bug* in yet another test, ugh
--HG-- branch : distribute extra : rebase_source : 476550766b7b756dced040ad4356b7685d6f062a
Diffstat (limited to 'setuptools')
-rw-r--r--setuptools/dist.py3
-rwxr-xr-xsetuptools/sandbox.py10
-rw-r--r--setuptools/tests/__init__.py2
-rw-r--r--setuptools/tests/test_easy_install.py102
4 files changed, 88 insertions, 29 deletions
diff --git a/setuptools/dist.py b/setuptools/dist.py
index 0ad18122..6607cf7b 100644
--- a/setuptools/dist.py
+++ b/setuptools/dist.py
@@ -264,6 +264,7 @@ class Distribution(_Distribution):
def fetch_build_egg(self, req):
"""Fetch an egg needed for building"""
+
try:
cmd = self._egg_fetcher
cmd.package_index.to_scan = []
@@ -287,7 +288,7 @@ class Distribution(_Distribution):
cmd = easy_install(
dist, args=["x"], install_dir=os.curdir, exclude_scripts=True,
always_copy=False, build_directory=None, editable=False,
- upgrade=False, multi_version=True, no_report = True
+ upgrade=False, multi_version=True, no_report=True, user=False
)
cmd.ensure_finalized()
self._egg_fetcher = cmd
diff --git a/setuptools/sandbox.py b/setuptools/sandbox.py
index ab2543d9..64f725e7 100755
--- a/setuptools/sandbox.py
+++ b/setuptools/sandbox.py
@@ -166,12 +166,12 @@ else:
_EXCEPTIONS = []
try:
- from win32com.client.gencache import GetGeneratePath
- _EXCEPTIONS.append(GetGeneratePath())
- del GetGeneratePath
+ from win32com.client.gencache import GetGeneratePath
+ _EXCEPTIONS.append(GetGeneratePath())
+ del GetGeneratePath
except ImportError:
- # it appears pywin32 is not installed, so no need to exclude.
- pass
+ # it appears pywin32 is not installed, so no need to exclude.
+ pass
class DirectorySandbox(AbstractSandbox):
"""Restrict operations to a single subdirectory - pseudo-chroot"""
diff --git a/setuptools/tests/__init__.py b/setuptools/tests/__init__.py
index eec76efd..b6988a08 100644
--- a/setuptools/tests/__init__.py
+++ b/setuptools/tests/__init__.py
@@ -38,7 +38,7 @@ def makeSetup(**args):
try:
return setuptools.setup(**args)
finally:
- distutils.core_setup_stop_after = None
+ distutils.core._setup_stop_after = None
class DependsTests(unittest.TestCase):
diff --git a/setuptools/tests/test_easy_install.py b/setuptools/tests/test_easy_install.py
index 13f668d0..ce8b611b 100644
--- a/setuptools/tests/test_easy_install.py
+++ b/setuptools/tests/test_easy_install.py
@@ -12,6 +12,7 @@ import urlparse
import StringIO
import distutils.core
+from setuptools.sandbox import run_setup, SandboxViolation
from setuptools.command.easy_install import easy_install, get_script_args, main
from setuptools.command.easy_install import PthDistributions
from setuptools.command import easy_install as easy_install_pkg
@@ -110,7 +111,9 @@ class TestEasyInstallTest(unittest.TestCase):
old_wd = os.getcwd()
try:
os.chdir(dir)
- main([])
+ reset_setup_stop_context(
+ lambda: self.assertRaises(SystemExit, main, [])
+ )
finally:
os.chdir(old_wd)
shutil.rmtree(dir)
@@ -247,7 +250,7 @@ class TestUserInstallTest(unittest.TestCase):
cmd.local_index.scan([new_location])
res = cmd.easy_install('foo')
self.assertEqual(os.path.realpath(res.location),
- os.path.realpath(new_location))
+ os.path.realpath(new_location))
finally:
sys.path.remove(target)
for basedir in [new_location, target, ]:
@@ -262,6 +265,50 @@ class TestUserInstallTest(unittest.TestCase):
else:
del os.environ['PYTHONPATH']
+ def test_setup_requires(self):
+ """Regression test for issue #318
+
+ Ensures that a package with setup_requires can be installed when
+ distribute is installed in the user site-packages without causing a
+ SandboxViolation.
+ """
+
+ test_setup_attrs = {
+ 'name': 'test_pkg', 'version': '0.0',
+ 'setup_requires': ['foobar'],
+ 'dependency_links': [os.path.abspath(self.dir)]
+ }
+
+ test_pkg = os.path.join(self.dir, 'test_pkg')
+ test_setup_py = os.path.join(test_pkg, 'setup.py')
+ test_setup_cfg = os.path.join(test_pkg, 'setup.cfg')
+ os.mkdir(test_pkg)
+
+ f = open(test_setup_py, 'w')
+ f.write(textwrap.dedent("""\
+ import setuptools
+ setuptools.setup(**%r)
+ """ % test_setup_attrs))
+ f.close()
+
+ foobar_path = os.path.join(self.dir, 'foobar-0.1.tar.gz')
+ make_trivial_sdist(
+ foobar_path,
+ textwrap.dedent("""\
+ import setuptools
+ setuptools.setup(
+ name='foobar',
+ version='0.1'
+ )
+ """))
+
+ try:
+ reset_setup_stop_context(
+ lambda: run_setup(test_setup_py, ['install'])
+ )
+ except SandboxViolation:
+ self.fail('Installation caused SandboxViolation')
+
class TestSetupRequires(unittest.TestCase):
@@ -319,30 +366,41 @@ class TestSetupRequires(unittest.TestCase):
doesn't exist) and invoke installer on it.
"""
def build_sdist(dir):
- setup_py = tarfile.TarInfo(name="setup.py")
- try:
- # Python 3 (StringIO gets converted to io module)
- MemFile = StringIO.BytesIO
- except AttributeError:
- MemFile = StringIO.StringIO
- setup_py_bytes = MemFile(textwrap.dedent("""
- import setuptools
- setuptools.setup(
- name="distribute-test-fetcher",
- version="1.0",
- setup_requires = ['does-not-exist'],
- )
- """).lstrip().encode('utf-8'))
- setup_py.size = len(setup_py_bytes.getvalue())
dist_path = os.path.join(dir, 'distribute-test-fetcher-1.0.tar.gz')
- dist = tarfile.open(dist_path, 'w:gz')
- try:
- dist.addfile(setup_py, fileobj=setup_py_bytes)
- finally:
- dist.close()
+ make_trivial_sdist(
+ dist_path,
+ textwrap.dedent("""
+ import setuptools
+ setuptools.setup(
+ name="distribute-test-fetcher",
+ version="1.0",
+ setup_requires = ['does-not-exist'],
+ )
+ """).lstrip())
installer(dist_path)
tempdir_context(build_sdist)
+
+def make_trivial_sdist(dist_path, setup_py):
+ """Create a simple sdist tarball at dist_path, containing just a
+ setup.py, the contents of which are provided by the setup_py string.
+ """
+
+ setup_py_file = tarfile.TarInfo(name='setup.py')
+ try:
+ # Python 3 (StringIO gets converted to io module)
+ MemFile = StringIO.BytesIO
+ except AttributeError:
+ MemFile = StringIO.StringIO
+ setup_py_bytes = MemFile(setup_py.encode('utf-8'))
+ setup_py_file.size = len(setup_py_bytes.getvalue())
+ dist = tarfile.open(dist_path, 'w:gz')
+ try:
+ dist.addfile(setup_py_file, fileobj=setup_py_bytes)
+ finally:
+ dist.close()
+
+
def tempdir_context(f, cd=lambda dir:None):
"""
Invoke f in the context