Commits

Tarek Ziadé  committed 20fa781

make sure we test that the directory exists before we install stuff asked by setup_requires fixes #138

  • Participants
  • Parent commits 2ec4746
  • Branches 0.6-maintenance

Comments (0)

Files changed (3)

 * Added easy_install --user
 * Issue 100: Fixed develop --user not taking '.' in PYTHONPATH into account
 * Issue 134: removed spurious UserWarnings. Patch by VanLindberg
+* Issue 138: cant_write_to_target error when setup_requires is used.
 
 ------
 0.6.10

File setuptools/command/easy_install.py

         ok_exists = os.path.exists(ok_file)
         try:
             if ok_exists: os.unlink(ok_file)
-            os.makedirs(os.path.dirname(ok_file))
+            dirname = os.path.dirname(ok_file)
+            if not os.path.exists(dirname):
+                os.makedirs(dirname)
             f = open(pth_file,'w')
         except (OSError,IOError):
             self.cant_write_to_target()

File setuptools/tests/test_develop.py

 import site
 from StringIO import StringIO
 
+from distutils.errors import DistutilsError
 from setuptools.command.develop import develop
 from setuptools.command import easy_install as easy_install_pkg
 from setuptools.dist import Distribution
 
 class TestDevelopTest(unittest.TestCase):
 
-    def setUp(self): 
+    def setUp(self):
         self.dir = tempfile.mkdtemp()
         setup = os.path.join(self.dir, 'setup.py')
         f = open(setup, 'w')
             self.old_site = site.USER_SITE
             site.USER_SITE = tempfile.mkdtemp()
 
-    def tearDown(self): 
+    def tearDown(self):
         os.chdir(self.old_cwd)
         shutil.rmtree(self.dir)
         if sys.version >= "2.6":
         content.sort()
         self.assertEquals(content, ['UNKNOWN.egg-link', 'easy-install.pth'])
 
+    def test_develop_with_setup_requires(self):
+
+        wanted = ("Could not find suitable distribution for "
+                  "Requirement.parse('I-DONT-EXIST')")
+        old_dir = os.getcwd()
+        os.chdir(self.dir)
+        try:
+            try:
+                dist = Distribution({'setup_requires': ['I_DONT_EXIST']})
+            except DistutilsError, e:
+                error = str(e)
+                if error ==  wanted:
+                    pass
+        finally:
+            os.chdir(old_dir)
+