Kirill Simonov avatar Kirill Simonov committed fa4825b

Make `python setup.py sdist` respect `--dry-run` option.

Comments (0)

Files changed (2)

 ===============
 
 
-2.2.0 rc 1 (2011-11-21)
+2.2.0 rc 1 (2011-11-22)
 -----------------------
 
 * Added ``@`` scope reset operator.
 class sdist(_sdist):
 
     def make_release_tree(self, base_dir, files):
+        # On `--dry-run`, create the `base_dir`; otherwise setuptools fails.
+        if self.dry_run:
+            if not os.path.exists(base_dir):
+                os.mkdir(base_dir)
         # Populate the release tree.
         _sdist.make_release_tree(self, base_dir, files)
+        # Remove `base_dir` if we previously created it.
+        if self.dry_run:
+            shutil.rmtree(base_dir)
         # `setup.cfg` is overriden by setuptools, so copy it back.
         release_setup_cfg = os.path.join(base_dir, 'setup.cfg')
-        os.unlink(release_setup_cfg)
+        if os.path.exists(release_setup_cfg):
+            os.unlink(release_setup_cfg)
         self.copy_file('setup.cfg', release_setup_cfg)
         # Check if we have source documentation.
         if not os.path.isfile('doc/conf.py'):
         sys.path.append(os.path.join(root, 'src'))
         # Instantiate and run Sphinx builder.
         log.info("compiling documentation")
+        # Do not do anything on `--dry-run`.
+        if self.dry_run:
+            return
         srcdir = os.path.abspath('doc')
         confdir = srcdir
         outdir = os.path.abspath(os.path.join(base_dir, 'doc'))
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.