1. Tarek Ziadé
  2. distribute

Commits

phillip.eby  committed 99dee48

Source distributions now always include a ``setup.cfg`` file that explicitly
sets ``egg_info`` options such that they produce an identical version number
to the source distribution's version number. (Previously, the default
version number could be different due to the use of ``--tag-date``, or if
the version was overridden on the command line that built the source
distribution.)

(backport from trunk)

  • Participants
  • Parent commits 9196765
  • Branches setuptools-0.6

Comments (0)

Files changed (3)

File setuptools.txt

View file
  * Support ``extra_path`` option to ``setup()`` when ``install`` is run in
    backward-compatibility mode.
 
+ * Rewrite ``setup.cfg`` in ``sdist`` distributions to include any ``egg_info``
+   options that were set on the command line when ``sdist`` was run, so that
+   the building from the source distribution will create a package with an
+   identical version number (unless ``--tag-date`` is in effect).
+
 0.6b4
  * Fix ``register`` not obeying name/version set by ``egg_info`` command, if
    ``egg_info`` wasn't explicitly run first on the same command line.

File setuptools/command/egg_info.py

View file
 
 
 
-    def initialize_options (self):
+    def initialize_options(self):
         self.egg_name = None
         self.egg_version = None
         self.egg_base = None
         self.tag_svn_revision = 0
         self.tag_date = 0
         self.broken_egg_info = False
+        self.vtags = None
 
-
-
-
-
-
-
-
-
-
+    def save_version_info(self, filename):
+        from setopt import edit_config
+        edit_config(
+            filename,
+            {'egg_info':
+                {'tag_svn_revision':0, 'tag_date': 0, 'tag_build': self.tags()}
+            }
+        )
 
 
 
 
     def finalize_options (self):
         self.egg_name = safe_name(self.distribution.get_name())
+        self.vtags = self.tags()
         self.egg_version = self.tagged_version()
 
         try:
             self.distribution._patched_dist = None
 
 
-
     def write_or_delete_file(self, what, filename, data, force=False):
         """Write `data` to `filename` or delete if empty
 
         if not self.dry_run:
             os.unlink(filename)
 
-
-
+    def tagged_version(self):
+        return safe_version(self.distribution.get_version() + self.vtags)
 
     def run(self):
         self.mkpath(self.egg_info)
             writer(self, ep.name, os.path.join(self.egg_info,ep.name))
         self.find_sources()
 
-    def tagged_version(self):
-        version = self.distribution.get_version()
+    def tags(self):
+        version = ''
         if self.tag_build:
             version+=self.tag_build
         if self.tag_svn_revision and (
         ):  version += '-r%s' % self.get_svn_revision()
         if self.tag_date:
             import time; version += time.strftime("-%Y%m%d")
-        return safe_version(version)
+        return version
 
     def get_svn_revision(self):
         revision = 0

File setuptools/command/sdist.py

View file
             )
 
 
+    def make_release_tree(self, base_dir, files):
+        _sdist.make_release_tree(self, base_dir, files)
 
+        # Save any egg_info command line options used to create this sdist
+        dest = os.path.join(base_dir, 'setup.cfg')
+        if hasattr(os,'link') and os.path.exists(dest):
+            # unlink and re-copy, since it might be hard-linked, and
+            # we don't want to change the source version
+            os.unlink(dest)
+            self.copy_file('setup.cfg', dest)
 
-
-
-
-
-
-
-
-
-
-
+        self.get_finalized_command('egg_info').save_version_info(dest)