[Zope-CVS] CVS: Packages/zpkgtools/zpkgtools - app.py:1.21
setup.py:1.12
Fred L. Drake, Jr.
fred at zope.com
Tue Apr 6 12:32:52 EDT 2004
Update of /cvs-repository/Packages/zpkgtools/zpkgtools
In directory cvs.zope.org:/tmp/cvs-serv23403
Modified Files:
app.py setup.py
Log Message:
make collection distributions handle at least package components properly
(non-package components *might* be ok)
=== Packages/zpkgtools/zpkgtools/app.py 1.20 => 1.21 ===
--- Packages/zpkgtools/zpkgtools/app.py:1.20 Mon Apr 5 18:22:16 2004
+++ Packages/zpkgtools/zpkgtools/app.py Tue Apr 6 12:32:51 2004
@@ -103,7 +103,7 @@
pkgdir = os.path.join(self.destination, pkgname)
pkginfo = package.loadPackageInfo(pkgname, pkgdir, pkgname)
self.generate_setup_cfg(self.destination, pkginfo)
- self.generate_package_setup()
+ self.generate_package_setup(self.destination, self.resource_name)
def build_collection_distribution(self):
# Build the destination directory:
@@ -141,7 +141,8 @@
i = name.rfind(".")
deps.add("package:" + name[:i])
remaining |= (deps - self.handled_resources)
- self.generate_collection_setup(packages, collections)
+ self.generate_collection_setup(self.destination, self.resource_name,
+ packages, collections)
def add_component(self, type, name, source):
"""Add a single component to a collection.
@@ -209,6 +210,7 @@
# load package information and generate setup.cfg
pkginfo = package.loadPackageInfo(name, pkgdest, name)
self.generate_setup_cfg(destination, pkginfo)
+ self.generate_package_setup(destination, name)
def load_metadata(self):
metadata_file = os.path.join(self.source, "PUBLICATION.cfg")
@@ -229,14 +231,31 @@
self.target_file = self.target_name + ".tar.bz2"
self.destination = os.path.join(self.tmpdir, self.target_name)
- def generate_package_setup(self):
- """Generate the setup.py file for a package distribution."""
- self.generate_setup_py("Package")
+ def generate_package_setup(self, destination, name):
+ """Generate the setup.py file for a package distribution.
- def generate_collection_setup(self, packages, collections):
+ :Parameters:
+ - `destination`: Directory to write the setup.py into.
+ - `name`: Name of the collection.
+
+ """
+ setup_py = os.path.join(destination, "setup.py")
+ self.ip.add_output(setup_py)
+ f = open(setup_py, "w")
+ print >>f, SETUP_HEADER
+ print >>f, "context = zpkgtools.setup.PackageContext("
+ print >>f, " %r, %r, __file__)" % (name, self.options.version)
+ print >>f
+ print >>f, "context.setup()"
+ f.close()
+
+ def generate_collection_setup(self, destination, name,
+ packages, collections):
"""Generate the setup.py file for a collection distribution.
:Parameters:
+ - `destination`: Directory to write the setup.py into.
+ - `name`: Name of the collection.
- `packages`: List of packages that are included.
- `collections`: List of collections that are included.
@@ -244,7 +263,26 @@
of ``self.destination``; the directory name should match the
component name in these lists.
"""
- self.generate_setup_py("Collection")
+ setup_py = os.path.join(destination, "setup.py")
+ self.ip.add_output(setup_py)
+ f = open(setup_py, "w")
+ print >>f, SETUP_HEADER
+ print >>f, "context = zpkgtools.setup.CollectionContext("
+ print >>f, " %r, %r, __file__," % (name, self.options.version)
+ if collections:
+ f.write(" collections=[%r" % collections[0])
+ for n in collections[1:]:
+ f.write(",\n %r" % n)
+ f.write("],\n")
+ if packages:
+ f.write(" packages=[%r" % packages[0])
+ for n in packages[1:]:
+ f.write(",\n %r" % n)
+ f.write("],\n")
+ print >>f, " )"
+ print >>f
+ print >>f, "context.setup()"
+ f.close()
def generate_setup_cfg(self, destination, pkginfo):
"""Write a setup.cfg file for a distribution component.
@@ -274,19 +312,6 @@
f.write("compile = 1\n")
# generate .pyo files using "python -O"
f.write("optimize = 1\n")
- f.close()
-
- def generate_setup_py(self, typename):
- setup_py = os.path.join(self.destination, "setup.py")
- self.ip.add_output(setup_py)
- type = self.resource_type
- f = open(setup_py, "w")
- print >>f, SETUP_HEADER
- print >>f, "context = zpkgtools.setup.%sContext(" % typename
- print >>f, " %r, %r, __file__)" % (self.resource_name,
- self.options.version)
- print >>f
- print >>f, "context.setup()"
f.close()
def include_support_code(self):
=== Packages/zpkgtools/zpkgtools/setup.py 1.11 => 1.12 ===
--- Packages/zpkgtools/zpkgtools/setup.py:1.11 Mon Apr 5 11:56:53 2004
+++ Packages/zpkgtools/zpkgtools/setup.py Tue Apr 6 12:32:51 2004
@@ -41,6 +41,8 @@
self.scripts = []
self.platforms = None
self.classifiers = None
+ self.load_metadata(
+ os.path.join(self._working_dir, pkgname, PUBLICATION_CONF))
def setup(self):
kwargs = self.__dict__.copy()
@@ -76,6 +78,7 @@
pkginfo = package.loadPackageInfo(name, directory, reldir)
self.scripts.extend(pkginfo.script)
self.ext_modules.extend(pkginfo.extensions)
+ self.add_package_dir(name, reldir)
# scan the files in the directory:
files = os.listdir(directory)
@@ -91,7 +94,6 @@
if os.path.isfile(os.path.join(path, PUBLICATION_CONF)):
continue
pkgname = "%s.%s" % (name, fn)
- self.packages.append(pkgname)
self.scan_package(
pkgname, path, posixpath.join(reldir, fn))
else:
@@ -130,6 +132,7 @@
self.add_package_file(pkgname, posixpath.join(reldir, fn))
def add_package_dir(self, pkgname, reldir):
+ self.packages.append(pkgname)
if pkgname.replace(".", posixpath.sep) != reldir:
self.package_dir[pkgname] = reldir
@@ -142,17 +145,24 @@
def __init__(self, pkgname, version, setup_file):
SetupContext.__init__(self, pkgname, version, setup_file)
- self.packages.append(pkgname)
- self.load_metadata(
- os.path.join(self._working_dir, pkgname, PUBLICATION_CONF))
- self.add_package_dir(pkgname, pkgname)
self.scan_package(pkgname, os.path.join(self._working_dir, pkgname),
pkgname)
class CollectionContext(SetupContext):
- def __init__(self, pkgname, version, setup_file):
+ def __init__(self, pkgname, version, setup_file,
+ packages=(), collections=()):
SetupContext.__init__(self, pkgname, version, setup_file)
- self.load_metadata(os.path.join(self._working_dir,
- PUBLICATION_CONF))
+ for name in packages:
+ pkgdir = os.path.join(self._working_dir, name, name)
+ reldir = posixpath.join(name, name)
+ self.scan_package(name, pkgdir, reldir)
+ for name in collections:
+ pkgdir = os.path.join(self._working_dir, name, name)
+ self.scan_collection(name, pkgdir)
+
+ def scan_collection(self, name, directory):
+ # load the collection metadata
+ pkginfo = package.loadCollectionInfo(directory)
+ self.scripts.extend(pkginfo.script)
More information about the Zope-CVS
mailing list