mirror of https://github.com/python/cpython
Branch merge
This commit is contained in:
commit
d15b768ddb
|
@ -76,7 +76,7 @@ argument. ::
|
|||
Name:
|
||||
virtualenv
|
||||
|
||||
$ pysetup metadata virtualenv --all
|
||||
$ pysetup metadata virtualenv
|
||||
Metadata-Version:
|
||||
1.0
|
||||
Name:
|
||||
|
|
|
@ -75,9 +75,6 @@ The available formats for built distributions are:
|
|||
| ``gztar`` | gzipped tar file | (1),(3) |
|
||||
| | (:file:`.tar.gz`) | |
|
||||
+-------------+------------------------------+---------+
|
||||
| ``ztar`` | compressed tar file | \(3) |
|
||||
| | (:file:`.tar.Z`) | |
|
||||
+-------------+------------------------------+---------+
|
||||
| ``tar`` | tar file (:file:`.tar`) | \(3) |
|
||||
+-------------+------------------------------+---------+
|
||||
| ``zip`` | zip file (:file:`.zip`) | (2),(4) |
|
||||
|
@ -98,8 +95,8 @@ Notes:
|
|||
default on Windows
|
||||
|
||||
(3)
|
||||
requires external utilities: :program:`tar` and possibly one of :program:`gzip`,
|
||||
:program:`bzip2`, or :program:`compress`
|
||||
requires external utilities: :program:`tar` and possibly one of :program:`gzip`
|
||||
or :program:`bzip2`
|
||||
|
||||
(4)
|
||||
requires either external :program:`zip` utility or :mod:`zipfile` module (part
|
||||
|
@ -109,14 +106,14 @@ You don't have to use the :command:`bdist` command with the :option:`--formats`
|
|||
option; you can also use the command that directly implements the format you're
|
||||
interested in. Some of these :command:`bdist` "sub-commands" actually generate
|
||||
several similar formats; for instance, the :command:`bdist_dumb` command
|
||||
generates all the "dumb" archive formats (``tar``, ``ztar``, ``gztar``, and
|
||||
generates all the "dumb" archive formats (``tar``, ``gztar``, and
|
||||
``zip``). The :command:`bdist` sub-commands, and the formats generated by
|
||||
each, are:
|
||||
|
||||
+--------------------------+-----------------------+
|
||||
| Command | Formats |
|
||||
+==========================+=======================+
|
||||
| :command:`bdist_dumb` | tar, ztar, gztar, zip |
|
||||
| :command:`bdist_dumb` | tar, gztar, zip |
|
||||
+--------------------------+-----------------------+
|
||||
| :command:`bdist_wininst` | wininst |
|
||||
+--------------------------+-----------------------+
|
||||
|
|
|
@ -32,9 +32,6 @@ to create a gzipped tarball and a zip file. The available formats are:
|
|||
| ``bztar`` | bzip2'ed tar file | |
|
||||
| | (:file:`.tar.bz2`) | |
|
||||
+-----------+-------------------------+---------+
|
||||
| ``ztar`` | compressed tar file | \(4) |
|
||||
| | (:file:`.tar.Z`) | |
|
||||
+-----------+-------------------------+---------+
|
||||
| ``tar`` | tar file (:file:`.tar`) | |
|
||||
+-----------+-------------------------+---------+
|
||||
|
||||
|
@ -50,11 +47,7 @@ Notes:
|
|||
requires either external :program:`zip` utility or :mod:`zipfile` module (part
|
||||
of the standard Python library since Python 1.6)
|
||||
|
||||
(4)
|
||||
requires the :program:`compress` program. Notice that this format is now
|
||||
pending for deprecation and will be removed in the future versions of Python.
|
||||
|
||||
When using any ``tar`` format (``gztar``, ``bztar``, ``ztar`` or
|
||||
When using any ``tar`` format (``gztar``, ``bztar`` or
|
||||
``tar``) under Unix, you can specify the ``owner`` and ``group`` names
|
||||
that will be set for each member of the archive.
|
||||
|
||||
|
|
|
@ -91,6 +91,13 @@ versions.
|
|||
|
||||
(:issue:`12100`)
|
||||
|
||||
crypt
|
||||
-----
|
||||
|
||||
Addition of salf and modular crypt format to the :mod:`crypt` module.
|
||||
|
||||
(:issue:`10924`)
|
||||
|
||||
curses
|
||||
------
|
||||
|
||||
|
@ -184,7 +191,7 @@ in Python 3.2.
|
|||
sys
|
||||
---
|
||||
|
||||
* The :mod:`sys` module has a new :func:`~sys.thread_info` :term:`struct
|
||||
* The :mod:`sys` module has a new :data:`~sys.thread_info` :term:`struct
|
||||
sequence` holding informations about the thread implementation.
|
||||
|
||||
(:issue:`11223`)
|
||||
|
|
|
@ -47,7 +47,7 @@ class bdist_dumb(Command):
|
|||
self.format = None
|
||||
self.keep_temp = 0
|
||||
self.dist_dir = None
|
||||
self.skip_build = 0
|
||||
self.skip_build = None
|
||||
self.relative = 0
|
||||
|
||||
def finalize_options(self):
|
||||
|
@ -65,7 +65,8 @@ class bdist_dumb(Command):
|
|||
|
||||
self.set_undefined_options('bdist',
|
||||
('dist_dir', 'dist_dir'),
|
||||
('plat_name', 'plat_name'))
|
||||
('plat_name', 'plat_name'),
|
||||
('skip_build', 'skip_build'))
|
||||
|
||||
def run(self):
|
||||
if not self.skip_build:
|
||||
|
|
|
@ -130,18 +130,22 @@ class bdist_msi(Command):
|
|||
self.no_target_optimize = 0
|
||||
self.target_version = None
|
||||
self.dist_dir = None
|
||||
self.skip_build = 0
|
||||
self.skip_build = None
|
||||
self.install_script = None
|
||||
self.pre_install_script = None
|
||||
self.versions = None
|
||||
|
||||
def finalize_options(self):
|
||||
self.set_undefined_options('bdist', ('skip_build', 'skip_build'))
|
||||
|
||||
if self.bdist_dir is None:
|
||||
bdist_base = self.get_finalized_command('bdist').bdist_base
|
||||
self.bdist_dir = os.path.join(bdist_base, 'msi')
|
||||
|
||||
short_version = get_python_version()
|
||||
if (not self.target_version) and self.distribution.has_ext_modules():
|
||||
self.target_version = short_version
|
||||
|
||||
if self.target_version:
|
||||
self.versions = [self.target_version]
|
||||
if not self.skip_build and self.distribution.has_ext_modules()\
|
||||
|
|
|
@ -65,13 +65,15 @@ class bdist_wininst(Command):
|
|||
self.dist_dir = None
|
||||
self.bitmap = None
|
||||
self.title = None
|
||||
self.skip_build = 0
|
||||
self.skip_build = None
|
||||
self.install_script = None
|
||||
self.pre_install_script = None
|
||||
self.user_access_control = None
|
||||
|
||||
|
||||
def finalize_options(self):
|
||||
self.set_undefined_options('bdist', ('skip_build', 'skip_build'))
|
||||
|
||||
if self.bdist_dir is None:
|
||||
if self.skip_build and self.plat_name:
|
||||
# If build is skipped and plat_name is overridden, bdist will
|
||||
|
@ -81,8 +83,10 @@ class bdist_wininst(Command):
|
|||
# next the command will be initialized using that name
|
||||
bdist_base = self.get_finalized_command('bdist').bdist_base
|
||||
self.bdist_dir = os.path.join(bdist_base, 'wininst')
|
||||
|
||||
if not self.target_version:
|
||||
self.target_version = ""
|
||||
|
||||
if not self.skip_build and self.distribution.has_ext_modules():
|
||||
short_version = get_python_version()
|
||||
if self.target_version and self.target_version != short_version:
|
||||
|
|
|
@ -1,41 +1,47 @@
|
|||
"""Tests for distutils.command.bdist."""
|
||||
import unittest
|
||||
import sys
|
||||
import os
|
||||
import tempfile
|
||||
import shutil
|
||||
import unittest
|
||||
from test.support import run_unittest
|
||||
|
||||
from distutils.core import Distribution
|
||||
from distutils.command.bdist import bdist
|
||||
from distutils.tests import support
|
||||
from distutils.spawn import find_executable
|
||||
from distutils import spawn
|
||||
from distutils.errors import DistutilsExecError
|
||||
|
||||
|
||||
class BuildTestCase(support.TempdirManager,
|
||||
unittest.TestCase):
|
||||
|
||||
def test_formats(self):
|
||||
|
||||
# let's create a command and make sure
|
||||
# we can fix the format
|
||||
pkg_pth, dist = self.create_dist()
|
||||
# we can set the format
|
||||
dist = self.create_dist()[1]
|
||||
cmd = bdist(dist)
|
||||
cmd.formats = ['msi']
|
||||
cmd.ensure_finalized()
|
||||
self.assertEqual(cmd.formats, ['msi'])
|
||||
|
||||
# what format bdist offers ?
|
||||
# XXX an explicit list in bdist is
|
||||
# not the best way to bdist_* commands
|
||||
# we should add a registry
|
||||
formats = ['rpm', 'zip', 'gztar', 'bztar', 'ztar',
|
||||
'tar', 'wininst', 'msi']
|
||||
formats.sort()
|
||||
founded = list(cmd.format_command.keys())
|
||||
founded.sort()
|
||||
self.assertEqual(founded, formats)
|
||||
# what formats does bdist offer?
|
||||
formats = ['bztar', 'gztar', 'msi', 'rpm', 'tar',
|
||||
'wininst', 'zip', 'ztar']
|
||||
found = sorted(cmd.format_command)
|
||||
self.assertEqual(found, formats)
|
||||
|
||||
def test_skip_build(self):
|
||||
# bug #10946: bdist --skip-build should trickle down to subcommands
|
||||
dist = self.create_dist()[1]
|
||||
cmd = bdist(dist)
|
||||
cmd.skip_build = 1
|
||||
cmd.ensure_finalized()
|
||||
dist.command_obj['bdist'] = cmd
|
||||
|
||||
names = ['bdist_dumb', 'bdist_wininst'] # bdist_rpm does not support --skip-build
|
||||
if os.name == 'nt':
|
||||
names.append('bdist_msi')
|
||||
|
||||
for name in names:
|
||||
subcmd = cmd.get_finalized_command(name)
|
||||
self.assertTrue(subcmd.skip_build,
|
||||
'%s should take --skip-build from bdist' % name)
|
||||
|
||||
|
||||
def test_suite():
|
||||
return unittest.makeSuite(BuildTestCase)
|
||||
|
|
|
@ -30,6 +30,8 @@ _COMMANDS = {
|
|||
'upload': 'packaging.command.upload.upload',
|
||||
'upload_docs': 'packaging.command.upload_docs.upload_docs'}
|
||||
|
||||
# XXX use OrderedDict to preserve the grouping (build-related, install-related,
|
||||
# distribution-related)
|
||||
STANDARD_COMMANDS = set(_COMMANDS)
|
||||
|
||||
|
||||
|
@ -48,9 +50,9 @@ def get_command_class(name):
|
|||
"""Return the registered command"""
|
||||
try:
|
||||
cls = _COMMANDS[name]
|
||||
except KeyError:
|
||||
raise PackagingModuleError("Invalid command %s" % name)
|
||||
if isinstance(cls, str):
|
||||
cls = resolve_name(cls)
|
||||
_COMMANDS[name] = cls
|
||||
return cls
|
||||
except KeyError:
|
||||
raise PackagingModuleError("Invalid command %s" % name)
|
||||
|
|
|
@ -64,21 +64,19 @@ class bdist(Command):
|
|||
'os2': 'zip'}
|
||||
|
||||
# Establish the preferred order (for the --help-formats option).
|
||||
format_commands = ['gztar', 'bztar', 'ztar', 'tar',
|
||||
format_commands = ['gztar', 'bztar', 'tar',
|
||||
'wininst', 'zip', 'msi']
|
||||
|
||||
# And the real information.
|
||||
format_command = {'gztar': ('bdist_dumb', "gzip'ed tar file"),
|
||||
'bztar': ('bdist_dumb', "bzip2'ed tar file"),
|
||||
'ztar': ('bdist_dumb', "compressed tar file"),
|
||||
'tar': ('bdist_dumb', "tar file"),
|
||||
'wininst': ('bdist_wininst',
|
||||
"Windows executable installer"),
|
||||
'zip': ('bdist_dumb', "ZIP file"),
|
||||
'msi': ('bdist_msi', "Microsoft Installer")
|
||||
'msi': ('bdist_msi', "Microsoft Installer"),
|
||||
}
|
||||
|
||||
|
||||
def initialize_options(self):
|
||||
self.bdist_base = None
|
||||
self.plat_name = None
|
||||
|
@ -109,7 +107,8 @@ class bdist(Command):
|
|||
try:
|
||||
self.formats = [self.default_format[os.name]]
|
||||
except KeyError:
|
||||
raise PackagingPlatformError("don't know how to create built distributions " + \
|
||||
raise PackagingPlatformError(
|
||||
"don't know how to create built distributions "
|
||||
"on platform %s" % os.name)
|
||||
|
||||
if self.dist_dir is None:
|
||||
|
|
|
@ -13,6 +13,7 @@ from packaging.command.cmd import Command
|
|||
from packaging.errors import PackagingPlatformError
|
||||
from packaging import logger
|
||||
|
||||
|
||||
class bdist_dumb(Command):
|
||||
|
||||
description = 'create a "dumb" built distribution'
|
||||
|
@ -23,7 +24,7 @@ class bdist_dumb(Command):
|
|||
"platform name to embed in generated filenames "
|
||||
"(default: %s)" % get_platform()),
|
||||
('format=', 'f',
|
||||
"archive format to create (tar, ztar, gztar, zip)"),
|
||||
"archive format to create (tar, gztar, zip)"),
|
||||
('keep-temp', 'k',
|
||||
"keep the pseudo-installation tree around after " +
|
||||
"creating the distribution archive"),
|
||||
|
@ -44,10 +45,9 @@ class bdist_dumb(Command):
|
|||
|
||||
boolean_options = ['keep-temp', 'skip-build', 'relative']
|
||||
|
||||
default_format = { 'posix': 'gztar',
|
||||
default_format = {'posix': 'gztar',
|
||||
'nt': 'zip',
|
||||
'os2': 'zip' }
|
||||
|
||||
'os2': 'zip'}
|
||||
|
||||
def initialize_options(self):
|
||||
self.bdist_dir = None
|
||||
|
@ -55,7 +55,7 @@ class bdist_dumb(Command):
|
|||
self.format = None
|
||||
self.keep_temp = False
|
||||
self.dist_dir = None
|
||||
self.skip_build = False
|
||||
self.skip_build = None
|
||||
self.relative = False
|
||||
self.owner = None
|
||||
self.group = None
|
||||
|
@ -69,10 +69,12 @@ class bdist_dumb(Command):
|
|||
try:
|
||||
self.format = self.default_format[os.name]
|
||||
except KeyError:
|
||||
raise PackagingPlatformError(("don't know how to create dumb built distributions " +
|
||||
"on platform %s") % os.name)
|
||||
raise PackagingPlatformError(
|
||||
"don't know how to create dumb built distributions "
|
||||
"on platform %s" % os.name)
|
||||
|
||||
self.set_undefined_options('bdist', 'dist_dir', 'plat_name')
|
||||
self.set_undefined_options('bdist',
|
||||
'dist_dir', 'plat_name', 'skip_build')
|
||||
|
||||
def run(self):
|
||||
if not self.skip_build:
|
||||
|
|
|
@ -139,18 +139,22 @@ class bdist_msi(Command):
|
|||
self.no_target_optimize = False
|
||||
self.target_version = None
|
||||
self.dist_dir = None
|
||||
self.skip_build = False
|
||||
self.skip_build = None
|
||||
self.install_script = None
|
||||
self.pre_install_script = None
|
||||
self.versions = None
|
||||
|
||||
def finalize_options(self):
|
||||
self.set_undefined_options('bdist', 'skip_build')
|
||||
|
||||
if self.bdist_dir is None:
|
||||
bdist_base = self.get_finalized_command('bdist').bdist_base
|
||||
self.bdist_dir = os.path.join(bdist_base, 'msi')
|
||||
|
||||
short_version = get_python_version()
|
||||
if (not self.target_version) and self.distribution.has_ext_modules():
|
||||
self.target_version = short_version
|
||||
|
||||
if self.target_version:
|
||||
self.versions = [self.target_version]
|
||||
if not self.skip_build and self.distribution.has_ext_modules()\
|
||||
|
|
|
@ -67,13 +67,15 @@ class bdist_wininst(Command):
|
|||
self.dist_dir = None
|
||||
self.bitmap = None
|
||||
self.title = None
|
||||
self.skip_build = False
|
||||
self.skip_build = None
|
||||
self.install_script = None
|
||||
self.pre_install_script = None
|
||||
self.user_access_control = None
|
||||
|
||||
|
||||
def finalize_options(self):
|
||||
self.set_undefined_options('bdist', 'skip_build')
|
||||
|
||||
if self.bdist_dir is None:
|
||||
if self.skip_build and self.plat_name:
|
||||
# If build is skipped and plat_name is overridden, bdist will
|
||||
|
@ -83,8 +85,10 @@ class bdist_wininst(Command):
|
|||
# next the command will be initialized using that name
|
||||
bdist_base = self.get_finalized_command('bdist').bdist_base
|
||||
self.bdist_dir = os.path.join(bdist_base, 'wininst')
|
||||
|
||||
if not self.target_version:
|
||||
self.target_version = ""
|
||||
|
||||
if not self.skip_build and self.distribution.has_ext_modules():
|
||||
short_version = get_python_version()
|
||||
if self.target_version and self.target_version != short_version:
|
||||
|
|
|
@ -606,8 +606,7 @@ class build_ext(Command):
|
|||
template = "python%d%d"
|
||||
if self.debug:
|
||||
template = template + '_d'
|
||||
pythonlib = (template %
|
||||
(sys.hexversion >> 24, (sys.hexversion >> 16) & 0xff))
|
||||
pythonlib = template % sys.version_info[:2]
|
||||
# don't extend ext.libraries, it may be shared with other
|
||||
# extensions, it is a reference to the original list
|
||||
return ext.libraries + [pythonlib]
|
||||
|
@ -621,22 +620,19 @@ class build_ext(Command):
|
|||
# not at this time - AIM Apr01
|
||||
#if self.debug:
|
||||
# template = template + '_d'
|
||||
pythonlib = (template %
|
||||
(sys.hexversion >> 24, (sys.hexversion >> 16) & 0xff))
|
||||
pythonlib = template % sys.version_info[:2]
|
||||
# don't extend ext.libraries, it may be shared with other
|
||||
# extensions, it is a reference to the original list
|
||||
return ext.libraries + [pythonlib]
|
||||
elif sys.platform[:6] == "cygwin":
|
||||
template = "python%d.%d"
|
||||
pythonlib = (template %
|
||||
(sys.hexversion >> 24, (sys.hexversion >> 16) & 0xff))
|
||||
pythonlib = template % sys.version_info[:2]
|
||||
# don't extend ext.libraries, it may be shared with other
|
||||
# extensions, it is a reference to the original list
|
||||
return ext.libraries + [pythonlib]
|
||||
elif sys.platform[:6] == "atheos":
|
||||
template = "python%d.%d"
|
||||
pythonlib = (template %
|
||||
(sys.hexversion >> 24, (sys.hexversion >> 16) & 0xff))
|
||||
pythonlib = template % sys.version_info[:2]
|
||||
# Get SHLIBS from Makefile
|
||||
extra = []
|
||||
for lib in sysconfig.get_config_var('SHLIBS').split():
|
||||
|
@ -654,9 +650,8 @@ class build_ext(Command):
|
|||
|
||||
else:
|
||||
if sysconfig.get_config_var('Py_ENABLE_SHARED'):
|
||||
pythonlib = 'python{}.{}{}'.format(
|
||||
sys.hexversion >> 24, (sys.hexversion >> 16) & 0xff,
|
||||
sys.abiflags)
|
||||
template = 'python%d%d' + sys.abiflags
|
||||
pythonlib = template % sys.version_info[:2]
|
||||
return ext.libraries + [pythonlib]
|
||||
else:
|
||||
return ext.libraries
|
||||
|
|
|
@ -1,20 +1,21 @@
|
|||
"""Class representing the distribution being built/installed/etc."""
|
||||
"""Class representing the project being built/installed/etc."""
|
||||
|
||||
import os
|
||||
import re
|
||||
|
||||
from packaging import logger
|
||||
from packaging.util import strtobool, resolve_name
|
||||
from packaging.config import Config
|
||||
from packaging.errors import (PackagingOptionError, PackagingArgError,
|
||||
PackagingModuleError, PackagingClassError)
|
||||
from packaging.fancy_getopt import FancyGetopt
|
||||
from packaging.util import strtobool, resolve_name
|
||||
from packaging import logger
|
||||
from packaging.metadata import Metadata
|
||||
from packaging.config import Config
|
||||
from packaging.command import get_command_class, STANDARD_COMMANDS
|
||||
from packaging.command.cmd import Command
|
||||
from packaging.metadata import Metadata
|
||||
from packaging.fancy_getopt import FancyGetopt
|
||||
|
||||
# Regex to define acceptable Packaging command names. This is not *quite*
|
||||
# the same as a Python NAME -- I don't allow leading underscores. The fact
|
||||
# that they're very similar is no coincidence; the default naming scheme is
|
||||
# the same as a Python name -- leading underscores are not allowed. The fact
|
||||
# that they're very similar is no coincidence: the default naming scheme is
|
||||
# to look for a Python module named after the command.
|
||||
command_re = re.compile(r'^[a-zA-Z]([a-zA-Z0-9_]*)$')
|
||||
|
||||
|
@ -32,22 +33,16 @@ def gen_usage(script_name):
|
|||
|
||||
|
||||
class Distribution:
|
||||
"""The core of the Packaging. Most of the work hiding behind 'setup'
|
||||
is really done within a Distribution instance, which farms the work out
|
||||
to the Packaging commands specified on the command line.
|
||||
"""Class used to represent a project and work with it.
|
||||
|
||||
Setup scripts will almost never instantiate Distribution directly,
|
||||
unless the 'setup()' function is totally inadequate to their needs.
|
||||
However, it is conceivable that a setup script might wish to subclass
|
||||
Distribution for some specialized purpose, and then pass the subclass
|
||||
to 'setup()' as the 'distclass' keyword argument. If so, it is
|
||||
necessary to respect the expectations that 'setup' has of Distribution.
|
||||
See the code for 'setup()', in run.py, for details.
|
||||
Most of the work hiding behind 'pysetup run' is really done within a
|
||||
Distribution instance, which farms the work out to the commands
|
||||
specified on the command line.
|
||||
"""
|
||||
|
||||
# 'global_options' describes the command-line options that may be
|
||||
# supplied to the setup script prior to any actual commands.
|
||||
# Eg. "pysetup -n" or "pysetup --dry-run" both take advantage of
|
||||
# Eg. "pysetup run -n" or "pysetup run --dry-run" both take advantage of
|
||||
# these global options. This list should be kept to a bare minimum,
|
||||
# since every global option is also valid as a command option -- and we
|
||||
# don't want to pollute the commands with too many options that they
|
||||
|
@ -63,55 +58,14 @@ class Distribution:
|
|||
common_usage = """\
|
||||
Common commands: (see '--help-commands' for more)
|
||||
|
||||
pysetup run build will build the package underneath 'build/'
|
||||
pysetup run install will install the package
|
||||
pysetup run build will build the project underneath 'build/'
|
||||
pysetup run install will install the project
|
||||
"""
|
||||
|
||||
# options that are not propagated to the commands
|
||||
display_options = [
|
||||
('help-commands', None,
|
||||
"list all available commands"),
|
||||
# XXX this is obsoleted by the pysetup metadata action
|
||||
('name', None,
|
||||
"print package name"),
|
||||
('version', 'V',
|
||||
"print package version"),
|
||||
('fullname', None,
|
||||
"print <package name>-<version>"),
|
||||
('author', None,
|
||||
"print the author's name"),
|
||||
('author-email', None,
|
||||
"print the author's email address"),
|
||||
('maintainer', None,
|
||||
"print the maintainer's name"),
|
||||
('maintainer-email', None,
|
||||
"print the maintainer's email address"),
|
||||
('contact', None,
|
||||
"print the maintainer's name if known, else the author's"),
|
||||
('contact-email', None,
|
||||
"print the maintainer's email address if known, else the author's"),
|
||||
('url', None,
|
||||
"print the URL for this package"),
|
||||
('license', None,
|
||||
"print the license of the package"),
|
||||
('licence', None,
|
||||
"alias for --license"),
|
||||
('description', None,
|
||||
"print the package description"),
|
||||
('long-description', None,
|
||||
"print the long package description"),
|
||||
('platforms', None,
|
||||
"print the list of platforms"),
|
||||
('classifier', None,
|
||||
"print the list of classifiers"),
|
||||
('keywords', None,
|
||||
"print the list of keywords"),
|
||||
('provides', None,
|
||||
"print the list of packages/modules provided"),
|
||||
('requires', None,
|
||||
"print the list of packages/modules required"),
|
||||
('obsoletes', None,
|
||||
"print the list of packages/modules made obsolete"),
|
||||
('use-2to3', None,
|
||||
"use 2to3 to make source python 3.x compatible"),
|
||||
('convert-2to3-doctests', None,
|
||||
|
@ -347,7 +301,6 @@ Common commands: (see '--help-commands' for more)
|
|||
self.commands = []
|
||||
parser = FancyGetopt(toplevel_options + self.display_options)
|
||||
parser.set_negative_aliases(self.negative_opt)
|
||||
parser.set_aliases({'licence': 'license'})
|
||||
args = parser.getopt(args=self.script_args, object=self)
|
||||
option_order = parser.get_option_order()
|
||||
|
||||
|
@ -372,7 +325,7 @@ Common commands: (see '--help-commands' for more)
|
|||
commands=self.commands)
|
||||
return
|
||||
|
||||
return 1
|
||||
return True
|
||||
|
||||
def _get_toplevel_options(self):
|
||||
"""Return the non-display options recognized at the top level.
|
||||
|
@ -496,13 +449,10 @@ Common commands: (see '--help-commands' for more)
|
|||
|
||||
If 'global_options' is true, lists the global options:
|
||||
--dry-run, etc. If 'display_options' is true, lists
|
||||
the "display-only" options: --name, --version, etc. Finally,
|
||||
the "display-only" options: --help-commands. Finally,
|
||||
lists per-command help for every command name or command class
|
||||
in 'commands'.
|
||||
"""
|
||||
# late import because of mutual dependence between these modules
|
||||
from packaging.command.cmd import Command
|
||||
|
||||
if global_options:
|
||||
if display_options:
|
||||
options = self._get_toplevel_options()
|
||||
|
@ -536,9 +486,8 @@ Common commands: (see '--help-commands' for more)
|
|||
|
||||
def handle_display_options(self, option_order):
|
||||
"""If there were any non-global "display-only" options
|
||||
(--help-commands or the metadata display options) on the command
|
||||
line, display the requested info and return true; else return
|
||||
false.
|
||||
(--help-commands) on the command line, display the requested info and
|
||||
return true; else return false.
|
||||
"""
|
||||
# User just wants a list of commands -- we'll print it out and stop
|
||||
# processing now (ie. if they ran "setup --help-commands foo bar",
|
||||
|
@ -547,7 +496,7 @@ Common commands: (see '--help-commands' for more)
|
|||
self.print_commands()
|
||||
print()
|
||||
print(gen_usage(self.script_name))
|
||||
return 1
|
||||
return True
|
||||
|
||||
# If user supplied any of the "display metadata" options, then
|
||||
# display that metadata in the order in which the user supplied the
|
||||
|
@ -628,18 +577,17 @@ Common commands: (see '--help-commands' for more)
|
|||
"""
|
||||
cmd_obj = self.command_obj.get(command)
|
||||
if not cmd_obj and create:
|
||||
logger.debug("Distribution.get_command_obj(): " \
|
||||
logger.debug("Distribution.get_command_obj(): "
|
||||
"creating %r command object", command)
|
||||
|
||||
cls = get_command_class(command)
|
||||
cmd_obj = self.command_obj[command] = cls(self)
|
||||
self.have_run[command] = 0
|
||||
|
||||
# Set any options that were supplied in config files
|
||||
# or on the command line. (NB. support for error
|
||||
# reporting is lame here: any errors aren't reported
|
||||
# until 'finalize_options()' is called, which means
|
||||
# we won't report the source of the error.)
|
||||
# Set any options that were supplied in config files or on the
|
||||
# command line. (XXX support for error reporting is suboptimal
|
||||
# here: errors aren't reported until finalize_options is called,
|
||||
# which means we won't report the source of the error.)
|
||||
options = self.command_options.get(command)
|
||||
if options:
|
||||
self._set_command_options(cmd_obj, options)
|
||||
|
@ -707,7 +655,6 @@ Common commands: (see '--help-commands' for more)
|
|||
|
||||
Returns the reinitialized command object.
|
||||
"""
|
||||
from packaging.command.cmd import Command
|
||||
if not isinstance(command, Command):
|
||||
command_name = command
|
||||
command = self.get_command_obj(command_name)
|
||||
|
@ -716,6 +663,7 @@ Common commands: (see '--help-commands' for more)
|
|||
|
||||
if not command.finalized:
|
||||
return command
|
||||
|
||||
command.initialize_options()
|
||||
self.have_run[command_name] = 0
|
||||
command.finalized = False
|
||||
|
|
|
@ -71,8 +71,8 @@ positional arguments:
|
|||
"""
|
||||
|
||||
metadata_usage = """\
|
||||
Usage: pysetup metadata [dist] [-f field ...]
|
||||
or: pysetup metadata [dist] [--all]
|
||||
Usage: pysetup metadata [dist]
|
||||
or: pysetup metadata [dist] [-f field ...]
|
||||
or: pysetup metadata --help
|
||||
|
||||
Print metadata for the distribution.
|
||||
|
@ -81,8 +81,7 @@ positional arguments:
|
|||
dist installed distribution name
|
||||
|
||||
optional arguments:
|
||||
-f metadata field to print
|
||||
--all print all metadata fields
|
||||
-f metadata field to print; omit to get all fields
|
||||
"""
|
||||
|
||||
remove_usage = """\
|
||||
|
@ -252,7 +251,7 @@ def _install(dispatcher, args, **kw):
|
|||
|
||||
@action_help(metadata_usage)
|
||||
def _metadata(dispatcher, args, **kw):
|
||||
opts = _parse_args(args[1:], 'f:', ['all'])
|
||||
opts = _parse_args(args[1:], 'f:', [])
|
||||
if opts['args']:
|
||||
name = opts['args'][0]
|
||||
dist = get_distribution(name, use_egg_info=True)
|
||||
|
@ -269,13 +268,10 @@ def _metadata(dispatcher, args, **kw):
|
|||
|
||||
metadata = dist.metadata
|
||||
|
||||
if 'all' in opts:
|
||||
keys = metadata.keys()
|
||||
else:
|
||||
if 'f' in opts:
|
||||
keys = (k for k in opts['f'] if k in metadata)
|
||||
else:
|
||||
keys = ()
|
||||
keys = metadata.keys()
|
||||
|
||||
for key in keys:
|
||||
if key in metadata:
|
||||
|
|
|
@ -1,8 +1,6 @@
|
|||
"""Tests for distutils.command.bdist."""
|
||||
|
||||
from packaging import util
|
||||
import os
|
||||
from packaging.command.bdist import bdist, show_formats
|
||||
|
||||
from packaging.tests import unittest, support, captured_stdout
|
||||
|
||||
|
||||
|
@ -10,55 +8,38 @@ class BuildTestCase(support.TempdirManager,
|
|||
support.LoggingCatcher,
|
||||
unittest.TestCase):
|
||||
|
||||
def _mock_get_platform(self):
|
||||
self._get_platform_called = True
|
||||
return self._get_platform()
|
||||
|
||||
def setUp(self):
|
||||
super(BuildTestCase, self).setUp()
|
||||
|
||||
# mock util.get_platform
|
||||
self._get_platform_called = False
|
||||
self._get_platform = util.get_platform
|
||||
util.get_platform = self._mock_get_platform
|
||||
|
||||
def tearDown(self):
|
||||
super(BuildTestCase, self).tearDown()
|
||||
util.get_platform = self._get_platform
|
||||
|
||||
def test_formats(self):
|
||||
|
||||
# let's create a command and make sure
|
||||
# we can fix the format
|
||||
pkg_pth, dist = self.create_dist()
|
||||
# we can set the format
|
||||
dist = self.create_dist()[1]
|
||||
cmd = bdist(dist)
|
||||
cmd.formats = ['msi']
|
||||
cmd.ensure_finalized()
|
||||
self.assertEqual(cmd.formats, ['msi'])
|
||||
|
||||
# what format bdist offers ?
|
||||
# XXX an explicit list in bdist is
|
||||
# not the best way to bdist_* commands
|
||||
# we should add a registry
|
||||
formats = sorted(('zip', 'gztar', 'bztar', 'ztar',
|
||||
'tar', 'wininst', 'msi'))
|
||||
# what formats does bdist offer?
|
||||
# XXX hard-coded lists are not the best way to find available bdist_*
|
||||
# commands; we should add a registry
|
||||
formats = ['bztar', 'gztar', 'msi', 'tar', 'wininst', 'zip']
|
||||
found = sorted(cmd.format_command)
|
||||
self.assertEqual(found, formats)
|
||||
|
||||
def test_skip_build(self):
|
||||
pkg_pth, dist = self.create_dist()
|
||||
cmd = bdist(dist)
|
||||
cmd.skip_build = False
|
||||
cmd.formats = ['ztar']
|
||||
cmd.ensure_finalized()
|
||||
self.assertFalse(self._get_platform_called)
|
||||
|
||||
pkg_pth, dist = self.create_dist()
|
||||
# bug #10946: bdist --skip-build should trickle down to subcommands
|
||||
dist = self.create_dist()[1]
|
||||
cmd = bdist(dist)
|
||||
cmd.skip_build = True
|
||||
cmd.formats = ['ztar']
|
||||
cmd.ensure_finalized()
|
||||
self.assertTrue(self._get_platform_called)
|
||||
dist.command_obj['bdist'] = cmd
|
||||
|
||||
names = ['bdist_dumb', 'bdist_wininst']
|
||||
if os.name == 'nt':
|
||||
names.append('bdist_msi')
|
||||
|
||||
for name in names:
|
||||
subcmd = cmd.get_finalized_command(name)
|
||||
self.assertTrue(subcmd.skip_build,
|
||||
'%s should take --skip-build from bdist' % name)
|
||||
|
||||
def test_show_formats(self):
|
||||
__, stdout = captured_stdout(show_formats)
|
||||
|
|
|
@ -35,7 +35,7 @@ class BuildDumbTestCase(support.TempdirManager,
|
|||
|
||||
dist = Distribution({'name': 'foo', 'version': '0.1',
|
||||
'py_modules': ['foo'],
|
||||
'url': 'xxx', 'author': 'xxx',
|
||||
'home-page': 'xxx', 'author': 'xxx',
|
||||
'author_email': 'xxx'})
|
||||
os.chdir(pkg_dir)
|
||||
cmd = bdist_dumb(dist)
|
||||
|
|
|
@ -99,7 +99,7 @@ class RegisterTestCase(support.TempdirManager,
|
|||
|
||||
def _get_cmd(self, metadata=None):
|
||||
if metadata is None:
|
||||
metadata = {'url': 'xxx', 'author': 'xxx',
|
||||
metadata = {'home-page': 'xxx', 'author': 'xxx',
|
||||
'author_email': 'xxx',
|
||||
'name': 'xxx', 'version': 'xxx'}
|
||||
pkg_info, dist = self.create_dist(**metadata)
|
||||
|
|
|
@ -72,7 +72,7 @@ class SDistTestCase(support.TempdirManager,
|
|||
"""Returns a cmd"""
|
||||
if metadata is None:
|
||||
metadata = {'name': 'fake', 'version': '1.0',
|
||||
'url': 'xxx', 'author': 'xxx',
|
||||
'home_page': 'xxx', 'author': 'xxx',
|
||||
'author_email': 'xxx'}
|
||||
dist = Distribution(metadata)
|
||||
dist.packages = ['somecode']
|
||||
|
|
|
@ -98,7 +98,7 @@ class DistributionTestCase(support.TempdirManager,
|
|||
Distribution(attrs={'author': 'xxx',
|
||||
'name': 'xxx',
|
||||
'version': '1.2',
|
||||
'url': 'xxxx',
|
||||
'home-page': 'xxxx',
|
||||
'badoptname': 'xxx'})
|
||||
logs = self.get_logs(logging.WARNING)
|
||||
self.assertEqual(1, len(logs))
|
||||
|
@ -108,7 +108,7 @@ class DistributionTestCase(support.TempdirManager,
|
|||
Distribution(attrs={'author': 'xxx',
|
||||
'name': 'xxx',
|
||||
'version': 'xxx',
|
||||
'url': 'xxxx'})
|
||||
'home-page': 'xxxx'})
|
||||
logs = self.get_logs(logging.WARNING)
|
||||
self.assertEqual(1, len(logs))
|
||||
self.assertIn('not a valid version', logs[0])
|
||||
|
@ -119,7 +119,7 @@ class DistributionTestCase(support.TempdirManager,
|
|||
Distribution(attrs={'author': 'xxx',
|
||||
'name': 'xxx',
|
||||
'version': '1.2',
|
||||
'url': 'xxxx',
|
||||
'home-page': 'xxxx',
|
||||
'options': {}})
|
||||
|
||||
self.assertEqual([], self.get_logs(logging.WARNING))
|
||||
|
@ -135,7 +135,7 @@ class DistributionTestCase(support.TempdirManager,
|
|||
dist = Distribution(attrs={'author': 'xxx',
|
||||
'name': 'xxx',
|
||||
'version': 'xxx',
|
||||
'url': 'xxxx',
|
||||
'home-page': 'xxxx',
|
||||
'options': {'sdist': {'owner': 'root'}}})
|
||||
|
||||
self.assertIn('owner', dist.get_option_dict('sdist'))
|
||||
|
|
|
@ -268,6 +268,10 @@ Core and Builtins
|
|||
Library
|
||||
-------
|
||||
|
||||
- Issue #10946: The distutils commands bdist_dumb, bdist_wininst and bdist_msi
|
||||
now respect a --skip-build option given to bdist. The packaging commands
|
||||
were fixed too.
|
||||
|
||||
- Issue #12847: Fix a crash with negative PUT and LONG_BINPUT arguments in
|
||||
the C pickle implementation.
|
||||
|
||||
|
|
Loading…
Reference in New Issue