Commits

Ned Batchelder committed d57fd2b

It works.

  • Participants
  • Parent commits 745797f

Comments (0)

Files changed (3)

+# Makefile for fixtar
+
+default:
+	@echo "* No default action *"
+
+clean:
+	-rm -rf build *.egg-info dist
+	-rm -f *.pyc */*.pyc */*/*.pyc
+	-rm -f *.pyo */*.pyo */*/*.pyo
+	-rm -f *.bak */*.bak */*/*.bak
+	-rm -f MANIFEST
+	-rm -f setuptools-*.egg
+
+kit:
+	python setup.py develop sdist --keep-temp --formats=gztar fixtar
+
+pypi:
+	python setup.py register
+
+install:
+	python setup.py install
     classifiers = trove_classifiers,
     keywords = 'distutils setuptools setup',
     entry_points = {
-        'distutils.commands': [ 'fixtar = setuptools_fixtar.fixtar.py:FixtarCommand', ],
+        'distutils.commands': [ 'fixtar = setuptools_fixtar.fixtar:FixtarCommand', ],
         },
     )

setuptools_fixtar/fixtar.py

 
 """
 from distutils.core import Command
+from distutils.errors import DistutilsOptionError
 import shutil, tarfile
 
-class fixtar(Command):
+class FixtarCommand(Command):
     """A new setup.py command to fix tar file permissions."""
 
     description = "Re-pack the tar file to have correct permissions."
 
     def run(self):
         """The body of the command."""
+        fixed = 0
         for _, _, filename in self.distribution.dist_files:
             if filename.endswith(".tar.gz"):
                 self.repack_tar(filename, "temp.tar.gz")
                 shutil.move("temp.tar.gz", filename)
+                fixed += 1
+        if not fixed:
+            raise DistutilsOptionError("No .tar.gz files for fixtar to fix!")
 
     def repack_tar(self, infilename, outfilename):
         """Re-pack `infilename` as `outfilename`.