[Python-checkins] cpython: Final bag of small changes coming from distutils2.
eric.araujo
python-checkins at python.org
Mon Sep 19 16:11:00 CEST 2011
http://hg.python.org/cpython/rev/8aaf81d4ea66
changeset: 72409:8aaf81d4ea66
user: Éric Araujo <merwok at netwok.org>
date: Mon Sep 19 15:12:23 2011 +0200
summary:
Final bag of small changes coming from distutils2.
- minor cleanup in Metadata
- trigger creation of the sysconfig._CONFIG_VARS dict
- home_page is used over home-page: it’s not a compound word, it’s an
escaped space
Distutils2 is now synchronized with Packaging.
files:
Lib/packaging/command/bdist_dumb.py | 4 +-
Lib/packaging/compat.py | 8 +------
Lib/packaging/metadata.py | 7 +++--
Lib/packaging/pypi/simple.py | 7 ++---
Lib/packaging/tests/test_command_bdist_dumb.py | 2 +-
Lib/packaging/tests/test_command_build_ext.py | 11 ++++-----
Lib/packaging/tests/test_command_register.py | 2 +-
Lib/packaging/tests/test_dist.py | 6 ++--
Lib/packaging/tests/test_metadata.py | 4 +-
9 files changed, 22 insertions(+), 29 deletions(-)
diff --git a/Lib/packaging/command/bdist_dumb.py b/Lib/packaging/command/bdist_dumb.py
--- a/Lib/packaging/command/bdist_dumb.py
+++ b/Lib/packaging/command/bdist_dumb.py
@@ -5,9 +5,9 @@
"""
import os
-
from shutil import rmtree
from sysconfig import get_python_version
+
from packaging.util import get_platform
from packaging.command.cmd import Command
from packaging.errors import PackagingPlatformError
@@ -24,7 +24,7 @@
"platform name to embed in generated filenames "
"(default: %s)" % get_platform()),
('format=', 'f',
- "archive format to create (tar, gztar, zip)"),
+ "archive format to create (tar, gztar, bztar, zip)"),
('keep-temp', 'k',
"keep the pseudo-installation tree around after " +
"creating the distribution archive"),
diff --git a/Lib/packaging/compat.py b/Lib/packaging/compat.py
--- a/Lib/packaging/compat.py
+++ b/Lib/packaging/compat.py
@@ -1,8 +1,4 @@
-"""Compatibility helpers.
-
-This module provides classes, variables and imports which are used to
-support packaging across Python 2.x and 3.x.
-"""
+"""Compatibility helpers."""
from packaging import logger
@@ -10,8 +6,6 @@
# XXX Having two classes with the same name is not a good thing.
# XXX 2to3-related code should move from util to this module
-# TODO Move common code here: PY3 (bool indicating if we're on 3.x), any, etc.
-
try:
from packaging.util import Mixin2to3 as _Mixin2to3
_CONVERT = True
diff --git a/Lib/packaging/metadata.py b/Lib/packaging/metadata.py
--- a/Lib/packaging/metadata.py
+++ b/Lib/packaging/metadata.py
@@ -552,16 +552,17 @@
return data
# Mapping API
+ # XXX these methods should return views or sets in 3.x
def keys(self):
- return _version2fieldlist(self['Metadata-Version'])
+ return list(_version2fieldlist(self['Metadata-Version']))
def __iter__(self):
for key in self.keys():
yield key
def values(self):
- return [self[key] for key in list(self.keys())]
+ return [self[key] for key in self.keys()]
def items(self):
- return [(key, self[key]) for key in list(self.keys())]
+ return [(key, self[key]) for key in self.keys()]
diff --git a/Lib/packaging/pypi/simple.py b/Lib/packaging/pypi/simple.py
--- a/Lib/packaging/pypi/simple.py
+++ b/Lib/packaging/pypi/simple.py
@@ -23,12 +23,11 @@
from packaging import __version__ as packaging_version
from packaging.pypi.base import BaseClient
from packaging.pypi.dist import (ReleasesList, EXTENSIONS,
- get_infos_from_url, MD5_HASH)
+ get_infos_from_url, MD5_HASH)
from packaging.pypi.errors import (PackagingPyPIError, DownloadError,
- UnableToDownload, CantParseArchiveName,
- ReleaseNotFound, ProjectNotFound)
+ UnableToDownload, CantParseArchiveName,
+ ReleaseNotFound, ProjectNotFound)
from packaging.pypi.mirrors import get_mirrors
-from packaging.metadata import Metadata
__all__ = ['Crawler', 'DEFAULT_SIMPLE_INDEX_URL']
diff --git a/Lib/packaging/tests/test_command_bdist_dumb.py b/Lib/packaging/tests/test_command_bdist_dumb.py
--- a/Lib/packaging/tests/test_command_bdist_dumb.py
+++ b/Lib/packaging/tests/test_command_bdist_dumb.py
@@ -35,7 +35,7 @@
dist = Distribution({'name': 'foo', 'version': '0.1',
'py_modules': ['foo'],
- 'home-page': 'xxx', 'author': 'xxx',
+ 'home_page': 'xxx', 'author': 'xxx',
'author_email': 'xxx'})
os.chdir(pkg_dir)
cmd = bdist_dumb(dist)
diff --git a/Lib/packaging/tests/test_command_build_ext.py b/Lib/packaging/tests/test_command_build_ext.py
--- a/Lib/packaging/tests/test_command_build_ext.py
+++ b/Lib/packaging/tests/test_command_build_ext.py
@@ -4,14 +4,13 @@
import sysconfig
import textwrap
from io import StringIO
-from sysconfig import _CONFIG_VARS
from packaging.dist import Distribution
from packaging.errors import (UnknownFileError, CompileError,
PackagingPlatformError)
from packaging.command.build_ext import build_ext
from packaging.compiler.extension import Extension
+
from test.script_helper import assert_python_ok
-
from packaging.tests import support, unittest, verbose
@@ -75,16 +74,16 @@
sys.platform = 'sunos' # fooling finalize_options
- old_var = _CONFIG_VARS.get('Py_ENABLE_SHARED')
- _CONFIG_VARS['Py_ENABLE_SHARED'] = 1
+ old_var = sysconfig.get_config_var('Py_ENABLE_SHARED')
+ sysconfig._CONFIG_VARS['Py_ENABLE_SHARED'] = 1
try:
cmd.ensure_finalized()
finally:
sys.platform = old
if old_var is None:
- del _CONFIG_VARS['Py_ENABLE_SHARED']
+ del sysconfig._CONFIG_VARS['Py_ENABLE_SHARED']
else:
- _CONFIG_VARS['Py_ENABLE_SHARED'] = old_var
+ sysconfig._CONFIG_VARS['Py_ENABLE_SHARED'] = old_var
# make sure we get some library dirs under solaris
self.assertGreater(len(cmd.library_dirs), 0)
diff --git a/Lib/packaging/tests/test_command_register.py b/Lib/packaging/tests/test_command_register.py
--- a/Lib/packaging/tests/test_command_register.py
+++ b/Lib/packaging/tests/test_command_register.py
@@ -99,7 +99,7 @@
def _get_cmd(self, metadata=None):
if metadata is None:
- metadata = {'home-page': 'xxx', 'author': 'xxx',
+ metadata = {'home_page': 'xxx', 'author': 'xxx',
'author_email': 'xxx',
'name': 'xxx', 'version': 'xxx'}
pkg_info, dist = self.create_dist(**metadata)
diff --git a/Lib/packaging/tests/test_dist.py b/Lib/packaging/tests/test_dist.py
--- a/Lib/packaging/tests/test_dist.py
+++ b/Lib/packaging/tests/test_dist.py
@@ -72,7 +72,7 @@
Distribution(attrs={'author': 'xxx',
'name': 'xxx',
'version': '1.2',
- 'home-page': 'xxxx',
+ 'home_page': 'xxxx',
'badoptname': 'xxx'})
logs = self.get_logs(logging.WARNING)
self.assertEqual(len(logs), 1)
@@ -82,7 +82,7 @@
# an empty options dictionary should not stay in the
# list of attributes
dist = Distribution(attrs={'author': 'xxx', 'name': 'xxx',
- 'version': '1.2', 'home-page': 'xxxx',
+ 'version': '1.2', 'home_page': 'xxxx',
'options': {}})
self.assertEqual([], self.get_logs(logging.WARNING))
@@ -99,7 +99,7 @@
dist = Distribution(attrs={'author': 'xxx',
'name': 'xxx',
'version': 'xxx',
- 'home-page': 'xxxx',
+ 'home_page': 'xxxx',
'options': {'sdist': {'owner': 'root'}}})
self.assertIn('owner', dist.get_option_dict('sdist'))
diff --git a/Lib/packaging/tests/test_metadata.py b/Lib/packaging/tests/test_metadata.py
--- a/Lib/packaging/tests/test_metadata.py
+++ b/Lib/packaging/tests/test_metadata.py
@@ -101,7 +101,7 @@
# XXX caveat: the keys method and friends are not 3.x-style views
# should be changed or documented
- self.assertEqual(list(metadata), list(metadata.keys()))
+ self.assertEqual(list(metadata), metadata.keys())
def test_read_metadata(self):
fields = {'name': 'project',
@@ -301,7 +301,7 @@
Metadata(mapping={'author': 'xxx',
'name': 'xxx',
'version': 'xxx',
- 'home-page': 'xxxx'})
+ 'home_page': 'xxxx'})
logs = self.get_logs(logging.WARNING)
self.assertEqual(1, len(logs))
self.assertIn('not a valid version', logs[0])
--
Repository URL: http://hg.python.org/cpython
More information about the Python-checkins
mailing list