mirror of
https://github.com/python/cpython.git
synced 2025-11-02 19:12:55 +00:00
Backing out the basic dependency checking (from pycon sprint).
This support was only a first cut, and doesn't deserve to be in a released version (where we have to support it in an ongoing manner)
This commit is contained in:
parent
9e29fc584c
commit
f2113f0c6e
5 changed files with 3 additions and 145 deletions
|
|
@ -24,7 +24,6 @@ __all__ = ['build',
|
||||||
'bdist_dumb',
|
'bdist_dumb',
|
||||||
'bdist_rpm',
|
'bdist_rpm',
|
||||||
'bdist_wininst',
|
'bdist_wininst',
|
||||||
'checkdep',
|
|
||||||
# These two are reserved for future use:
|
# These two are reserved for future use:
|
||||||
#'bdist_sdux',
|
#'bdist_sdux',
|
||||||
#'bdist_pkgtool',
|
#'bdist_pkgtool',
|
||||||
|
|
|
||||||
|
|
@ -1,70 +0,0 @@
|
||||||
"""distutils.command.x
|
|
||||||
|
|
||||||
Implements the Distutils 'x' command.
|
|
||||||
"""
|
|
||||||
|
|
||||||
# created 2000/mm/dd, John Doe
|
|
||||||
|
|
||||||
__revision__ = "$Id$"
|
|
||||||
|
|
||||||
from distutils.core import Command
|
|
||||||
|
|
||||||
class DependencyFailure(Exception): pass
|
|
||||||
|
|
||||||
class VersionTooOld(DependencyFailure): pass
|
|
||||||
|
|
||||||
class VersionNotKnown(DependencyFailure): pass
|
|
||||||
|
|
||||||
class checkdep (Command):
|
|
||||||
|
|
||||||
# Brief (40-50 characters) description of the command
|
|
||||||
description = "check package dependencies"
|
|
||||||
|
|
||||||
# List of option tuples: long name, short name (None if no short
|
|
||||||
# name), and help string.
|
|
||||||
# Later on, we might have auto-fetch and the like here. Feel free.
|
|
||||||
user_options = []
|
|
||||||
|
|
||||||
def initialize_options (self):
|
|
||||||
self.debug = None
|
|
||||||
|
|
||||||
# initialize_options()
|
|
||||||
|
|
||||||
|
|
||||||
def finalize_options (self):
|
|
||||||
pass
|
|
||||||
# finalize_options()
|
|
||||||
|
|
||||||
|
|
||||||
def run (self):
|
|
||||||
from distutils.version import LooseVersion
|
|
||||||
failed = []
|
|
||||||
for pkg, ver in self.distribution.metadata.requires:
|
|
||||||
if pkg == 'python':
|
|
||||||
if ver is not None:
|
|
||||||
# Special case the 'python' package
|
|
||||||
import sys
|
|
||||||
thisver = LooseVersion('%d.%d.%d'%sys.version_info[:3])
|
|
||||||
if thisver < ver:
|
|
||||||
failed.append(((pkg,ver), VersionTooOld(thisver)))
|
|
||||||
continue
|
|
||||||
# Kinda hacky - we should do more here
|
|
||||||
try:
|
|
||||||
mod = __import__(pkg)
|
|
||||||
except Exception, e:
|
|
||||||
failed.append(((pkg,ver), e))
|
|
||||||
continue
|
|
||||||
if ver is not None:
|
|
||||||
if hasattr(mod, '__version__'):
|
|
||||||
thisver = LooseVersion(mod.__version__)
|
|
||||||
if thisver < ver:
|
|
||||||
failed.append(((pkg,ver), VersionTooOld(thisver)))
|
|
||||||
else:
|
|
||||||
failed.append(((pkg,ver), VersionNotKnown()))
|
|
||||||
|
|
||||||
if failed:
|
|
||||||
raise DependencyFailure, failed
|
|
||||||
|
|
||||||
# run()
|
|
||||||
|
|
||||||
# class x
|
|
||||||
|
|
@ -126,8 +126,6 @@ class install (Command):
|
||||||
"force installation (overwrite any existing files)"),
|
"force installation (overwrite any existing files)"),
|
||||||
('skip-build', None,
|
('skip-build', None,
|
||||||
"skip rebuilding everything (for testing/debugging)"),
|
"skip rebuilding everything (for testing/debugging)"),
|
||||||
('skip-checkdep', None,
|
|
||||||
"skip checking dependencies (use at own risk)"),
|
|
||||||
|
|
||||||
# Where to install documentation (eventually!)
|
# Where to install documentation (eventually!)
|
||||||
#('doc-format=', None, "format of documentation to generate"),
|
#('doc-format=', None, "format of documentation to generate"),
|
||||||
|
|
@ -185,15 +183,12 @@ class install (Command):
|
||||||
|
|
||||||
# 'force' forces installation, even if target files are not
|
# 'force' forces installation, even if target files are not
|
||||||
# out-of-date. 'skip_build' skips running the "build" command,
|
# out-of-date. 'skip_build' skips running the "build" command,
|
||||||
# handy if you know it's not necessary. 'skip_checkdep' skips
|
# handy if you know it's not necessary. 'warn_dir' (which is *not*
|
||||||
# the 'checkdep' command, if you are sure you can work around the
|
|
||||||
# dependency failure in another way. 'warn_dir' (which is *not*
|
|
||||||
# a user option, it's just there so the bdist_* commands can turn
|
# a user option, it's just there so the bdist_* commands can turn
|
||||||
# it off) determines whether we warn about installing to a
|
# it off) determines whether we warn about installing to a
|
||||||
# directory not in sys.path.
|
# directory not in sys.path.
|
||||||
self.force = 0
|
self.force = 0
|
||||||
self.skip_build = 0
|
self.skip_build = 0
|
||||||
self.skip_checkdep = 0
|
|
||||||
self.warn_dir = 1
|
self.warn_dir = 1
|
||||||
|
|
||||||
# These are only here as a conduit from the 'build' command to the
|
# These are only here as a conduit from the 'build' command to the
|
||||||
|
|
@ -505,12 +500,6 @@ class install (Command):
|
||||||
if not self.skip_build:
|
if not self.skip_build:
|
||||||
self.run_command('build')
|
self.run_command('build')
|
||||||
|
|
||||||
# We check dependencies before we install
|
|
||||||
# For now, this is disabled. Before 2.4 is released, this will
|
|
||||||
# be turned on.
|
|
||||||
#if not self.skip_checkdep:
|
|
||||||
# self.run_command('checkdep')
|
|
||||||
|
|
||||||
# Run all sub-commands (at least those that need to be run)
|
# Run all sub-commands (at least those that need to be run)
|
||||||
for cmd_name in self.get_sub_commands():
|
for cmd_name in self.get_sub_commands():
|
||||||
self.run_command(cmd_name)
|
self.run_command(cmd_name)
|
||||||
|
|
|
||||||
|
|
@ -47,8 +47,7 @@ setup_keywords = ('distclass', 'script_name', 'script_args', 'options',
|
||||||
'name', 'version', 'author', 'author_email',
|
'name', 'version', 'author', 'author_email',
|
||||||
'maintainer', 'maintainer_email', 'url', 'license',
|
'maintainer', 'maintainer_email', 'url', 'license',
|
||||||
'description', 'long_description', 'keywords',
|
'description', 'long_description', 'keywords',
|
||||||
'platforms', 'classifiers', 'download_url',
|
'platforms', 'classifiers', 'download_url',)
|
||||||
'provides', 'requires', )
|
|
||||||
|
|
||||||
# Legal keyword arguments for the Extension constructor
|
# Legal keyword arguments for the Extension constructor
|
||||||
extension_keywords = ('name', 'sources', 'include_dirs',
|
extension_keywords = ('name', 'sources', 'include_dirs',
|
||||||
|
|
|
||||||
|
|
@ -223,51 +223,6 @@ class Distribution:
|
||||||
else:
|
else:
|
||||||
sys.stderr.write(msg + "\n")
|
sys.stderr.write(msg + "\n")
|
||||||
|
|
||||||
# Build up the requires sequence
|
|
||||||
from distutils.version import LooseVersion
|
|
||||||
requires = attrs.get('requires')
|
|
||||||
if requires:
|
|
||||||
if isinstance(requires, type('')):
|
|
||||||
raise DistutilsOptionError, 'requires should be a sequence'
|
|
||||||
newreq = []
|
|
||||||
for req in requires:
|
|
||||||
if '-' not in req:
|
|
||||||
# We have a plain package name - any version will do
|
|
||||||
newreq.append((req,None))
|
|
||||||
else:
|
|
||||||
pkg, ver = string.split(req, '-', 1)
|
|
||||||
newreq.append((pkg, LooseVersion(ver)))
|
|
||||||
attrs['requires'] = newreq
|
|
||||||
|
|
||||||
# Build up the provides object. If the setup() has no
|
|
||||||
# provides line, we use packages or modules and the version
|
|
||||||
# to synthesise the provides. If no version is provided (no
|
|
||||||
# pun intended) we don't have a provides entry at all.
|
|
||||||
provides = attrs.get('provides')
|
|
||||||
if provides:
|
|
||||||
if isinstance(provides, type('')):
|
|
||||||
raise DistutilsOptionError, 'provides should be a sequence'
|
|
||||||
newprov = []
|
|
||||||
for prov in provides:
|
|
||||||
if '-' not in prov:
|
|
||||||
# We have a plain package name - any version will do
|
|
||||||
newprov.append((prov,None))
|
|
||||||
else:
|
|
||||||
pkg, ver = string.split(prov, '-', 1)
|
|
||||||
newprov.append((pkg, LooseVersion(ver)))
|
|
||||||
attrs['provides'] = newprov
|
|
||||||
elif attrs.get('version'):
|
|
||||||
# Build a provides line
|
|
||||||
prov = []
|
|
||||||
if attrs.get('packages'):
|
|
||||||
for pkg in attrs['packages']:
|
|
||||||
pkg = string.replace(pkg, '/', '.')
|
|
||||||
prov.append('%s-%s'%(pkg, attrs['version']))
|
|
||||||
elif attrs.get('modules'):
|
|
||||||
for mod in attrs['modules']:
|
|
||||||
prov.append('%s-%s'%(mod, attrs['version']))
|
|
||||||
attrs['provides'] = prov
|
|
||||||
|
|
||||||
# Now work on the rest of the attributes. Any attribute that's
|
# Now work on the rest of the attributes. Any attribute that's
|
||||||
# not already defined is invalid!
|
# not already defined is invalid!
|
||||||
for (key,val) in attrs.items():
|
for (key,val) in attrs.items():
|
||||||
|
|
@ -275,7 +230,6 @@ class Distribution:
|
||||||
setattr(self.metadata, key, val)
|
setattr(self.metadata, key, val)
|
||||||
elif hasattr(self, key):
|
elif hasattr(self, key):
|
||||||
setattr(self, key, val)
|
setattr(self, key, val)
|
||||||
else:
|
|
||||||
msg = "Unknown distribution option: %s" % repr(key)
|
msg = "Unknown distribution option: %s" % repr(key)
|
||||||
if warnings is not None:
|
if warnings is not None:
|
||||||
warnings.warn(msg)
|
warnings.warn(msg)
|
||||||
|
|
@ -1060,7 +1014,7 @@ class DistributionMetadata:
|
||||||
"license", "description", "long_description",
|
"license", "description", "long_description",
|
||||||
"keywords", "platforms", "fullname", "contact",
|
"keywords", "platforms", "fullname", "contact",
|
||||||
"contact_email", "license", "classifiers",
|
"contact_email", "license", "classifiers",
|
||||||
"download_url", "provides", "requires",)
|
"download_url")
|
||||||
|
|
||||||
def __init__ (self):
|
def __init__ (self):
|
||||||
self.name = None
|
self.name = None
|
||||||
|
|
@ -1077,8 +1031,6 @@ class DistributionMetadata:
|
||||||
self.platforms = None
|
self.platforms = None
|
||||||
self.classifiers = None
|
self.classifiers = None
|
||||||
self.download_url = None
|
self.download_url = None
|
||||||
self.requires = []
|
|
||||||
self.provides = []
|
|
||||||
|
|
||||||
def write_pkg_info (self, base_dir):
|
def write_pkg_info (self, base_dir):
|
||||||
"""Write the PKG-INFO file into the release tree.
|
"""Write the PKG-INFO file into the release tree.
|
||||||
|
|
@ -1094,10 +1046,6 @@ class DistributionMetadata:
|
||||||
pkg_info.write('Author: %s\n' % self.get_contact() )
|
pkg_info.write('Author: %s\n' % self.get_contact() )
|
||||||
pkg_info.write('Author-email: %s\n' % self.get_contact_email() )
|
pkg_info.write('Author-email: %s\n' % self.get_contact_email() )
|
||||||
pkg_info.write('License: %s\n' % self.get_license() )
|
pkg_info.write('License: %s\n' % self.get_license() )
|
||||||
for req in self.get_requires():
|
|
||||||
pkg_info.write('Requires: %s\n' % req )
|
|
||||||
for prov in self.get_provides():
|
|
||||||
pkg_info.write('Provides: %s\n' % prov )
|
|
||||||
if self.download_url:
|
if self.download_url:
|
||||||
pkg_info.write('Download-URL: %s\n' % self.download_url)
|
pkg_info.write('Download-URL: %s\n' % self.download_url)
|
||||||
|
|
||||||
|
|
@ -1176,13 +1124,6 @@ class DistributionMetadata:
|
||||||
def get_download_url(self):
|
def get_download_url(self):
|
||||||
return self.download_url or "UNKNOWN"
|
return self.download_url or "UNKNOWN"
|
||||||
|
|
||||||
def get_requires(self):
|
|
||||||
return [ '%s%s%s'%(x, (y and '-') or '', y or '')
|
|
||||||
for x,y in self.requires ]
|
|
||||||
|
|
||||||
def get_provides(self):
|
|
||||||
return self.provides
|
|
||||||
|
|
||||||
# class DistributionMetadata
|
# class DistributionMetadata
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue