[Zope-CVS] CVS: Packages/zpkgtools/zpkgtools - loggingapi.py:1.1
app.py:1.68 include.py:1.45 loader.py:1.16
locationmap.py:1.19 runlog.py:1.3 setup.py:1.26
Fred L. Drake, Jr.
fred at zope.com
Fri Jun 11 15:24:36 EDT 2004
Update of /cvs-repository/Packages/zpkgtools/zpkgtools
In directory cvs.zope.org:/tmp/cvs-serv11757/zpkgtools
Modified Files:
app.py include.py loader.py locationmap.py runlog.py setup.py
Added Files:
loggingapi.py
Log Message:
Python 2.2 compatibilty: allow zpkg-based distros to be installable.
This is not sufficient to build distros using Python 2.2.
=== Added File Packages/zpkgtools/zpkgtools/loggingapi.py ===
##############################################################################
#
# Copyright (c) 2004 Zope Corporation and Contributors.
# All Rights Reserved.
#
# This software is subject to the provisions of the Zope Public License,
# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE.
#
##############################################################################
"""Compatibility wrapper around the logging package.
If the logging package isn't available (as in Python 2.2), this
provides a limited implementation so the zpkgtools setup.py support
code doesn't fall over.
This isn't sufficient to support building packages with Python 2.2.
$Id: loggingapi.py,v 1.1 2004/06/11 19:24:35 fdrake Exp $
"""
try:
from logging import getLogger
from logging import CRITICAL, FATAL, ERROR, WARNING, WARN
from logging import INFO, DEBUG, NOTSET
from logging import StreamHandler
except ImportError:
CRITICAL = 50
FATAL = CRITICAL
ERROR = 40
WARNING = 30
WARN = WARNING
INFO = 20
DEBUG = 10
NOTSET = 0
_loggers = {}
def getLogger(name=None):
if "root" not in _loggers:
_loggers["root"] = Logger("root")
_loggers["root"].setLevel(WARNING)
name = name or "root"
if name not in _loggers:
_loggers[name] = Logger(name, _loggers["root"])
return _loggers[name]
class Logger:
def __init__(self, name, root=None):
self.name = name
self.level = NOTSET
self._handler = None
self._root = root
def setLevel(self, level):
self.level = level
def addHandler(self, handler):
self._handler = handler
def log(self, level, msg, *args, **kwargs):
loggers = [self]
if self._root is not None:
loggers.append(self._root)
for logger in loggers:
effective_level = logger.level
if effective_level == NOTSET and logger._root is not None:
effective_level = self._root.level
if level >= effective_level:
self._log(self.name, level, msg, args, kwargs)
def _log(self, name, level, msg, args, kwargs):
if args:
msg = msg % args
elif kwargs:
msg = msg % kwargs
msg = "%s(%s):%s" % (name, level, msg)
print >>self._handler, msg
def StreamHandler():
import sys
return sys.stderr
=== Packages/zpkgtools/zpkgtools/app.py 1.67 => 1.68 ===
--- Packages/zpkgtools/zpkgtools/app.py:1.67 Thu Jun 10 19:01:15 2004
+++ Packages/zpkgtools/zpkgtools/app.py Fri Jun 11 15:24:34 2004
@@ -13,7 +13,6 @@
##############################################################################
"""Top-level application object for **zpkg**."""
-import logging
import optparse
import os
import re
@@ -28,6 +27,7 @@
from zpkgtools import dependencies
from zpkgtools import include
from zpkgtools import loader
+from zpkgtools import loggingapi as logging
from zpkgtools import package
from zpkgtools import publication
from zpkgtools import runlog
@@ -460,6 +460,13 @@
#
import os
import sys
+
+try:
+ __file__
+except NameError:
+ # Python 2.2.x does not have __file__ for scripts.
+ __file__ = sys.argv[0]
+
support_dir = os.path.join(os.path.dirname(os.path.realpath(__file__)),
'Support')
if os.path.isdir(support_dir):
=== Packages/zpkgtools/zpkgtools/include.py 1.44 => 1.45 ===
--- Packages/zpkgtools/zpkgtools/include.py:1.44 Tue May 25 16:07:46 2004
+++ Packages/zpkgtools/zpkgtools/include.py Fri Jun 11 15:24:35 2004
@@ -29,7 +29,6 @@
import fnmatch
import glob
-import logging
import os
import posixpath
import shutil
@@ -39,6 +38,7 @@
from zpkgtools import cfgparser
from zpkgtools import loader
+from zpkgtools import loggingapi as logging
from zpkgtools import publication
=== Packages/zpkgtools/zpkgtools/loader.py 1.15 => 1.16 ===
--- Packages/zpkgtools/zpkgtools/loader.py:1.15 Thu May 13 11:06:34 2004
+++ Packages/zpkgtools/zpkgtools/loader.py Fri Jun 11 15:24:35 2004
@@ -18,7 +18,6 @@
import copy
import errno
-import logging
import os
import posixpath
import shutil
@@ -28,6 +27,7 @@
import urlparse
from zpkgtools import cvsloader
+from zpkgtools import loggingapi as logging
from zpkgtools import svnloader
=== Packages/zpkgtools/zpkgtools/locationmap.py 1.18 => 1.19 ===
--- Packages/zpkgtools/zpkgtools/locationmap.py:1.18 Tue Jun 8 23:07:00 2004
+++ Packages/zpkgtools/zpkgtools/locationmap.py Fri Jun 11 15:24:35 2004
@@ -13,7 +13,6 @@
##############################################################################
"""Tools to deal with the mapping of resources to URLs."""
-import logging
import os.path
import posixpath
import re
@@ -25,6 +24,7 @@
from zpkgtools import cvsloader
from zpkgtools import loader
+from zpkgtools import loggingapi as logging
from zpkgtools import svnloader
=== Packages/zpkgtools/zpkgtools/runlog.py 1.2 => 1.3 ===
--- Packages/zpkgtools/zpkgtools/runlog.py:1.2 Thu Apr 29 19:21:40 2004
+++ Packages/zpkgtools/zpkgtools/runlog.py Fri Jun 11 15:24:35 2004
@@ -13,9 +13,10 @@
##############################################################################
"""Utilities to help log running an external command."""
-import logging
import os
import sys
+
+from zpkgtools import loggingapi as logging
def report_command(cmd):
=== Packages/zpkgtools/zpkgtools/setup.py 1.25 => 1.26 ===
--- Packages/zpkgtools/zpkgtools/setup.py:1.25 Thu Jun 10 16:28:55 2004
+++ Packages/zpkgtools/zpkgtools/setup.py Fri Jun 11 15:24:35 2004
@@ -14,7 +14,6 @@
"""Generator for distutils setup.py files."""
import errno
-import logging
import os
import posixpath
import sys
@@ -24,9 +23,6 @@
from zpkgtools import publication
-_logger = logging.getLogger(__name__)
-
-
class SetupContext:
"""Object representing the arguments to distutils.core.setup()."""
@@ -87,15 +83,16 @@
if e.errno != errno.EPIPE:
raise
else:
- root_logger = logging.getLogger()
- if not root_logger.handlers:
- root_logger.addHandler(logging.StreamHandler())
+ if sys.version_info < (2, 3):
+ from distutils.dist import DistributionMetadata
+ DistributionMetadata.classifiers = None
+ DistributionMetadata.download_url = None
try:
from setuptools import setup
except ImportError:
# package_data can't be handled this way ;-(
if self.package_data:
- _logger.error(
+ print >>sys.stderr, (
"can't import setuptools;"
" some package data will not be properly installed")
from distutils.core import setup
@@ -166,7 +163,7 @@
for dir, files in pkginfo.data_files:
non_pkgdata.extend(files)
for ext in pkginfo.extensions:
- for fn in ext.sources + ext.depends:
+ for fn in ext.sources + getattr(ext, "depends", []):
if fn not in non_pkgdata:
non_pkgdata.append(fn)
for fn in non_pkgdata:
@@ -201,7 +198,7 @@
def add_package_dir(self, pkgname, reldir):
self.packages.append(pkgname)
- if pkgname.replace(".", posixpath.sep) != reldir:
+ if pkgname.replace(".", "/") != reldir:
self.package_dir[pkgname] = reldir
def add_package_file(self, pkgname, relfn):
More information about the Zope-CVS
mailing list