[Zope-CVS] SVN: zpkgtools/trunk/ add a -t/--tree option to build the tree without making a tarball

Fred L. Drake, Jr. fdrake at gmail.com
Tue Aug 23 10:06:14 EDT 2005


Log message for revision 38043:
  add a -t/--tree option to build the tree without making a tarball

Changed:
  U   zpkgtools/trunk/doc/zpkg.txt
  U   zpkgtools/trunk/zpkgtools/app.py
  U   zpkgtools/trunk/zpkgtools/tests/test_app.py

-=-
Modified: zpkgtools/trunk/doc/zpkg.txt
===================================================================
--- zpkgtools/trunk/doc/zpkg.txt	2005-08-23 13:30:38 UTC (rev 38042)
+++ zpkgtools/trunk/doc/zpkg.txt	2005-08-23 14:06:13 UTC (rev 38043)
@@ -74,6 +74,13 @@
   This can be used to provide additional software to be used when
   distutils is running for the distributed package.
 
+-t, --tree
+  Build the distribution tree only, but don't create a tarball.  The
+  distribution tree will be created in the current directory and will
+  be given the same name it would have in the tarball.  A directory of
+  that name must not already exist; if it does, it is considered an
+  error.
+
 -v VERSION
   Set the version number of the release to `VERSION`.
 

Modified: zpkgtools/trunk/zpkgtools/app.py
===================================================================
--- zpkgtools/trunk/zpkgtools/app.py	2005-08-23 13:30:38 UTC (rev 38042)
+++ zpkgtools/trunk/zpkgtools/app.py	2005-08-23 14:06:13 UTC (rev 38043)
@@ -118,7 +118,10 @@
         release_name = self.options.release_name
         self.target_name = "%s-%s" % (release_name, self.options.version)
         self.target_file = self.target_name + ".tgz"
-        self.destination = os.path.join(self.tmpdir, self.target_name)
+        if self.options.tree_only:
+            self.destination = os.path.abspath(self.target_name)
+        else:
+            self.destination = os.path.join(self.tmpdir, self.target_name)
         os.mkdir(self.destination)
         self.support_packages = DEFAULT_SUPPORT_PACKAGES[:]
         self.support_packages.extend(
@@ -347,7 +350,8 @@
             except zpkgtools.LoadingError, e:
                 self.error(str(e), e.exitcode)
             self.write_manifests()
-            self.create_tarball()
+            if not self.options.tree_only:
+                self.create_tarball()
             self.cleanup()
         except:
             print >>sys.stderr, "----\ntemporary files are in", self.tmpdir
@@ -601,6 +605,9 @@
         "-s", dest="include_support_code", action="store_true",
         help="include copies of the zpkgtools support code (the default)")
     parser.add_option(
+        "-t", "--tree", dest="tree_only", action="store_true",
+        help="generate an unpacked distribution tree, not a tarball")
+    parser.add_option(
         "-v", dest="version",
         help="version label for the new distribution")
     parser.add_option(

Modified: zpkgtools/trunk/zpkgtools/tests/test_app.py
===================================================================
--- zpkgtools/trunk/zpkgtools/tests/test_app.py	2005-08-23 13:30:38 UTC (rev 38042)
+++ zpkgtools/trunk/zpkgtools/tests/test_app.py	2005-08-23 14:06:13 UTC (rev 38043)
@@ -46,6 +46,14 @@
         self.assertEqual(options.resource, "resource")
         return options
 
+    def test_set_tree_only(self):
+        options = self.parse_args([])
+        self.assert_(not options.tree_only)
+        options = self.parse_args(["-t"])
+        self.assert_(options.tree_only)
+        options = self.parse_args(["--tree"])
+        self.assert_(options.tree_only)
+
     def test_set_package_version(self):
         options = self.parse_args([])
         self.assertEqual(options.version, "0.0.0")
@@ -403,6 +411,26 @@
         # convert package_map to URL so relative names are resolved properly
         return "file://" + urllib.pathname2url(package_map)
 
+    def test_building_distribution_tree_only(self):
+        # This builds a package and checks that the tree_only flag
+        # causes the application to build a tree in the current
+        # directory instead of a tarball.
+        package_map = self.createPackageMap()
+        app = self.createApplication(
+            ["-f", "-t", "-m", package_map, "package"])
+        app.run()
+        # make sure the local tree is present and looks like one of
+        # our distributions:
+        self.assert_(os.path.isdir("package-0.0.0"))
+        self.assert_(os.path.isdir(os.path.join("package-0.0.0", "package")))
+        self.assert_(os.path.isdir(os.path.join("package-0.0.0", "Support")))
+        self.assert_(isfile("package-0.0.0", "setup.py"))
+        self.assert_(isfile("package-0.0.0", "setup.cfg"))
+        self.assert_(isfile("package-0.0.0", "MANIFEST"))
+        self.assert_(isfile("package-0.0.0", "Support", "MANIFEST"))
+        self.assert_(isfile("package-0.0.0", "Support", "README.txt"))
+        self.assert_(isfile("package-0.0.0", "Support", "setup.py"))
+
     def test_adding_extra_support_code(self):
         package_map = self.createPackageMap()
         app = self.createApplication(



More information about the Zope-CVS mailing list