[Zope-CVS] SVN: zpkgtools/trunk/ add a way to trim branches off the
included portions of the dependency tree
Fred L. Drake, Jr.
fdrake at gmail.com
Mon Nov 8 13:20:50 EST 2004
Log message for revision 28403:
add a way to trim branches off the included portions of the dependency tree
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 2004-11-08 17:20:15 UTC (rev 28402)
+++ zpkgtools/trunk/doc/zpkg.txt 2004-11-08 18:20:50 UTC (rev 28403)
@@ -80,6 +80,12 @@
--version
Print the version number of **zpkg** and exit.
+-x PACKAGE, --exclude=PACKAGE
+ Name a resource (usually a Python package) to exclude the from
+ distribution. Dependencies of the named package will be included
+ due to `PACKAGE` needing them, but may be included due to an another
+ dependency. This option may be given as many times as needed.
+
If neither **-C** nor **-f** is specified on the command line, a
default configuration file is loaded if it exists. This is
`~/.zpkg/zpkg.conf` on Unix and `~/zpkg/zpkg.conf` on Windows (note
Modified: zpkgtools/trunk/zpkgtools/app.py
===================================================================
--- zpkgtools/trunk/zpkgtools/app.py 2004-11-08 17:20:15 UTC (rev 28402)
+++ zpkgtools/trunk/zpkgtools/app.py 2004-11-08 18:20:50 UTC (rev 28403)
@@ -114,6 +114,10 @@
self.support_packages = DEFAULT_SUPPORT_PACKAGES[:]
self.support_packages.extend(
[(pkg, None) for pkg in options.support_packages])
+ self.exclude_packages = sets.Set()
+ for pkg in options.exclude_packages:
+ if pkg not in self.exclude_packages:
+ self.exclude_packages.add(pkg)
def build_distribution(self):
"""Create the distribution tree.
@@ -128,7 +132,7 @@
if self.options.collect:
depsdir = os.path.join(self.destination, "Dependencies")
first = True
- handled = sets.Set()
+ handled = self.exclude_packages.copy()
handled.add(self.resource)
remaining = top.get_dependencies() - handled
while remaining:
@@ -611,6 +615,11 @@
parser.add_option(
"--distribution", dest="distribution_class",
help="name of the distribution class", metavar="CLASS")
+ parser.add_option(
+ "-x", "--exclude", dest="exclude_packages", action="append",
+ default=[], metavar="PACKAGE",
+ help=("resource to exclude the from distribution"
+ " (dependencies will be ignored)"))
options, args = parser.parse_args(argv[1:])
if len(args) != 1:
Modified: zpkgtools/trunk/zpkgtools/tests/test_app.py
===================================================================
--- zpkgtools/trunk/zpkgtools/tests/test_app.py 2004-11-08 17:20:15 UTC (rev 28402)
+++ zpkgtools/trunk/zpkgtools/tests/test_app.py 2004-11-08 18:20:50 UTC (rev 28403)
@@ -256,7 +256,20 @@
options = self.parse_args(["--support", "pkg1", "--support=pkg2"])
self.assertEqual(options.support_packages, ["pkg1", "pkg2"])
+ def test_exclude_resources(self):
+ options = self.parse_args([])
+ self.assertEqual(options.exclude_packages, [])
+ # one package, short option:
+ options = self.parse_args(["-x", "pkg"])
+ self.assertEqual(options.exclude_packages, ["pkg"])
+ # one package, long option:
+ options = self.parse_args(["--exclude", "pkg"])
+ self.assertEqual(options.exclude_packages, ["pkg"])
+ # two packages:
+ options = self.parse_args(["--exclude=pkg1", "-xpkg2"])
+ self.assertEqual(options.exclude_packages, ["pkg1", "pkg2"])
+
class ComponentTestCase(unittest.TestCase):
def setUp(self):
More information about the Zope-CVS
mailing list