diff options
| author | Éric Araujo <merwok@netwok.org> | 2011-06-06 17:12:29 +0200 |
|---|---|---|
| committer | Éric Araujo <merwok@netwok.org> | 2011-06-06 17:12:29 +0200 |
| commit | e77535c90b0483d8cec913cca4b0628974a9f06e (patch) | |
| tree | 538e352f514aacce0793ac3cc14ff49301f3acdc /Lib | |
| parent | 9f0df8bdb8497674709f1e0494dbb885b898d7ee (diff) | |
| parent | a69ade81be00270bd613f7e5e4f999f5d7bc304b (diff) | |
| download | cpython-git-e77535c90b0483d8cec913cca4b0628974a9f06e.tar.gz | |
Branch merge
Diffstat (limited to 'Lib')
| -rw-r--r--[-rwxr-xr-x] | Lib/distutils/tests/Setup.sample | 0 | ||||
| -rw-r--r--[-rwxr-xr-x] | Lib/distutils/tests/test_extension.py | 0 | ||||
| -rw-r--r-- | Lib/packaging/compiler/cygwinccompiler.py | 7 | ||||
| -rw-r--r-- | Lib/packaging/create.py | 59 | ||||
| -rw-r--r-- | Lib/packaging/pypi/dist.py | 2 | ||||
| -rw-r--r-- | Lib/packaging/pypi/simple.py | 2 | ||||
| -rw-r--r-- | Lib/packaging/run.py | 18 | ||||
| -rw-r--r-- | Lib/packaging/tests/test_uninstall.py | 2 | ||||
| -rw-r--r-- | Lib/packaging/util.py | 20 |
9 files changed, 52 insertions, 58 deletions
diff --git a/Lib/distutils/tests/Setup.sample b/Lib/distutils/tests/Setup.sample index 36c4290d8f..36c4290d8f 100755..100644 --- a/Lib/distutils/tests/Setup.sample +++ b/Lib/distutils/tests/Setup.sample diff --git a/Lib/distutils/tests/test_extension.py b/Lib/distutils/tests/test_extension.py index e35f2738b6..e35f2738b6 100755..100644 --- a/Lib/distutils/tests/test_extension.py +++ b/Lib/distutils/tests/test_extension.py diff --git a/Lib/packaging/compiler/cygwinccompiler.py b/Lib/packaging/compiler/cygwinccompiler.py index 7bfa611ea5..348dbe782f 100644 --- a/Lib/packaging/compiler/cygwinccompiler.py +++ b/Lib/packaging/compiler/cygwinccompiler.py @@ -48,7 +48,6 @@ of GCC (same as cygwin in no-cygwin mode). import os import sys -import copy from packaging import logger from packaging.compiler.unixccompiler import UnixCCompiler @@ -172,9 +171,9 @@ class CygwinCCompiler(UnixCCompiler): extra_postargs=None, build_temp=None, target_lang=None): """Link the objects.""" # use separate copies, so we can modify the lists - extra_preargs = copy.copy(extra_preargs or []) - libraries = copy.copy(libraries or []) - objects = copy.copy(objects or []) + extra_preargs = list(extra_preargs or []) + libraries = list(libraries or []) + objects = list(objects or []) # Additional libraries libraries.extend(self.dll_libraries) diff --git a/Lib/packaging/create.py b/Lib/packaging/create.py index b96aef0fe7..c18d42fb02 100644 --- a/Lib/packaging/create.py +++ b/Lib/packaging/create.py @@ -1,15 +1,8 @@ -#!/usr/bin/env python """Interactive helper used to create a setup.cfg file. This script will generate a packaging configuration file by looking at the current directory and asking the user questions. It is intended to -be called as - - pysetup create - -or - - python3.3 -m packaging.create +be called as *pysetup create*. """ # Original code by Sean Reifschneider <jafo@tummy.com> @@ -26,17 +19,17 @@ or # Detect scripts (not sure how. #! outside of package?) import os +import re import imp import sys import glob -import re import shutil import sysconfig import tokenize -from configparser import RawConfigParser -from textwrap import dedent from hashlib import md5 +from textwrap import dedent from functools import cmp_to_key +from configparser import RawConfigParser # importing this with an underscore as it should be replaced by the # dict form or another structures for all purposes from packaging._trove import all_classifiers as _CLASSIFIERS_LIST @@ -68,7 +61,7 @@ E-mail address of the project author (typically you). 'do_classifier': ''' Trove classifiers are optional identifiers that allow you to specify the intended audience by saying things like "Beta software with a text UI -for Linux under the PSF license. However, this can be a somewhat involved +for Linux under the PSF license". However, this can be a somewhat involved process. ''', 'packages': ''' @@ -95,7 +88,7 @@ human language, programming language, user interface, etc... ''', 'setup.py found': ''' The setup.py script will be executed to retrieve the metadata. -A wizard will be run if you answer "n", +An interactive helper will be run if you answer "n", ''', } @@ -230,7 +223,7 @@ class MainProgram: self._write_cfg() def has_setup_py(self): - """Test for the existance of a setup.py file.""" + """Test for the existence of a setup.py file.""" return os.path.exists('setup.py') def define_cfg_values(self): @@ -281,9 +274,13 @@ class MainProgram: with open(_FILENAME, 'w', encoding='utf-8') as fp: fp.write('[metadata]\n') + # TODO use metadata module instead of hard-coding field-specific + # behavior here + # simple string entries for name in ('name', 'version', 'summary', 'download_url'): fp.write('%s = %s\n' % (name, self.data.get(name, 'UNKNOWN'))) + # optional string entries if 'keywords' in self.data and self.data['keywords']: fp.write('keywords = %s\n' % ' '.join(self.data['keywords'])) @@ -295,6 +292,7 @@ class MainProgram: fp.write( 'description = %s\n' % '\n |'.join(self.data['description'].split('\n'))) + # multiple use string entries for name in ('platform', 'supported-platform', 'classifier', 'requires-dist', 'provides-dist', 'obsoletes-dist', @@ -329,8 +327,8 @@ class MainProgram: def setup_mock(**attrs): """Mock the setup(**attrs) in order to retrieve metadata.""" - # use the distutils v1 processings to correctly parse metadata. - #XXX we could also use the setuptools distibution ??? + + # TODO use config and metadata instead of Distribution from distutils.dist import Distribution dist = Distribution(attrs) dist.parse_config_files() @@ -362,13 +360,14 @@ class MainProgram: data['modules'].extend(dist.py_modules or []) # 2.1 data_files -> resources if dist.data_files: - if len(dist.data_files) < 2 or \ - isinstance(dist.data_files[1], str): + if (len(dist.data_files) < 2 or + isinstance(dist.data_files[1], str)): dist.data_files = [('', dist.data_files)] # add tokens in the destination paths vars = {'distribution.name': data['name']} path_tokens = list(sysconfig.get_paths(vars=vars).items()) + # TODO replace this with a key function def length_comparison(x, y): len_x = len(x[1]) len_y = len(y[1]) @@ -391,12 +390,12 @@ class MainProgram: dest = ('{%s}' % tok) + dest[len(path):] files = [('/ '.join(src.rsplit('/', 1)), dest) - for src in srcs] + for src in srcs] data['resources'].extend(files) # 2.2 package_data -> extra_files package_dirs = dist.package_dir or {} - for package, extras in iter(dist.package_data.items()) or []: + for package, extras in dist.package_data.items() or []: package_dir = package_dirs.get(package, package) for file_ in extras: if package_dir: @@ -458,10 +457,10 @@ class MainProgram: if match: self.data['name'] = match.group(1) self.data['version'] = match.group(2) - # TODO Needs tested! + # TODO needs testing! if not is_valid_version(self.data['version']): msg = "Invalid version discovered: %s" % self.data['version'] - raise RuntimeError(msg) + raise ValueError(msg) def query_user(self): self.data['name'] = ask('Project name', self.data['name'], @@ -476,25 +475,25 @@ class MainProgram: self.data.get('author'), _helptext['author']) self.data['author_email'] = ask('Author e-mail address', self.data.get('author_email'), _helptext['author_email']) - self.data['home_page'] = ask('Project Home Page', + self.data['home_page'] = ask('Project home page', self.data.get('home_page'), _helptext['home_page'], required=False) if ask_yn('Do you want me to automatically build the file list ' - 'with everything I can find in the current directory ? ' + 'with everything I can find in the current directory? ' 'If you say no, you will have to define them manually.') == 'y': self._find_files() else: - while ask_yn('Do you want to add a single module ?' + while ask_yn('Do you want to add a single module?' ' (you will be able to add full packages next)', helptext=_helptext['modules']) == 'y': self._set_multi('Module name', 'modules') - while ask_yn('Do you want to add a package ?', + while ask_yn('Do you want to add a package?', helptext=_helptext['packages']) == 'y': self._set_multi('Package name', 'packages') - while ask_yn('Do you want to add an extra file ?', + while ask_yn('Do you want to add an extra file?', helptext=_helptext['extra_files']) == 'y': self._set_multi('Extra file/dir name', 'extra_files') @@ -582,7 +581,7 @@ class MainProgram: self.set_other_classifier(self.classifiers) def set_other_classifier(self, classifiers): - if ask_yn('Do you want to set other trove identifiers', 'n', + if ask_yn('Do you want to set other trove identifiers?', 'n', _helptext['trove_generic']) != 'y': return self.walk_classifiers(classifiers, [CLASSIFIERS], '') @@ -599,7 +598,7 @@ class MainProgram: classifiers.add(desc[4:] + ' :: ' + key) continue - if ask_yn('Do you want to set items under\n "%s" (%d sub-items)' + if ask_yn('Do you want to set items under\n "%s" (%d sub-items)?' % (key, len(trove[key])), 'n', _helptext['trove_generic']) == 'y': self.walk_classifiers(classifiers, trovepath + [trove[key]], @@ -607,7 +606,7 @@ class MainProgram: def set_license(self, classifiers): while True: - license = ask('What license do you use', + license = ask('What license do you use?', helptext=_helptext['trove_license'], required=False) if not license: return diff --git a/Lib/packaging/pypi/dist.py b/Lib/packaging/pypi/dist.py index 16510dffd8..db04cdaa70 100644 --- a/Lib/packaging/pypi/dist.py +++ b/Lib/packaging/pypi/dist.py @@ -135,7 +135,7 @@ class ReleaseInfo(IndexReference): not return one existing distribution. """ if len(self.dists) == 0: - raise LookupError() + raise LookupError if dist_type: return self[dist_type] if prefer_source: diff --git a/Lib/packaging/pypi/simple.py b/Lib/packaging/pypi/simple.py index c492179874..c372c6fe3e 100644 --- a/Lib/packaging/pypi/simple.py +++ b/Lib/packaging/pypi/simple.py @@ -189,7 +189,7 @@ class Crawler(BaseClient): self._process_index_page(predicate.name) if predicate.name.lower() not in self._projects: - raise ProjectNotFound() + raise ProjectNotFound releases = self._projects.get(predicate.name.lower()) releases.sort_releases(prefer_final=prefer_final) diff --git a/Lib/packaging/run.py b/Lib/packaging/run.py index de9dd13fe9..c17ccfdf4b 100644 --- a/Lib/packaging/run.py +++ b/Lib/packaging/run.py @@ -5,7 +5,6 @@ import re import sys import getopt import logging -from copy import copy from packaging import logger from packaging.dist import Distribution @@ -35,14 +34,14 @@ create_usage = """\ Usage: pysetup create or: pysetup create --help -Create a new Python package. +Create a new Python project. """ generate_usage = """\ Usage: pysetup generate-setup or: pysetup generate-setup --help -Generates a setup.py script for backward-compatibility purposes. +Generate a setup.py script for backward-compatibility purposes. """ @@ -96,7 +95,7 @@ positional arguments: dist installed distribution name optional arguments: - -y auto confirm package removal + -y auto confirm distribution removal """ run_usage = """\ @@ -218,7 +217,6 @@ def _generate(distpatcher, args, **kw): print('The setup.py was generated') - @action_help(graph_usage) def _graph(dispatcher, args, **kw): name = args[1] @@ -384,7 +382,7 @@ def _search(dispatcher, args, **kw): """ #opts = _parse_args(args[1:], '', ['simple', 'xmlrpc']) # 1. what kind of index is requested ? (xmlrpc / simple) - raise NotImplementedError() + raise NotImplementedError actions = [ @@ -393,10 +391,10 @@ actions = [ ('install', 'Install a project', _install), ('remove', 'Remove a project', _remove), ('search', 'Search for a project in the indexes', _search), - ('list', 'Search for local projects', _list), + ('list', 'List installed releases', _list), ('graph', 'Display a graph', _graph), - ('create', 'Create a Project', _create), - ('generate-setup', 'Generates a backward-comptatible setup.py', _generate) + ('create', 'Create a project', _create), + ('generate-setup', 'Generate a backward-comptatible setup.py', _generate), ] @@ -673,7 +671,7 @@ class Dispatcher: def main(args=None): old_level = logger.level - old_handlers = copy(logger.handlers) + old_handlers = list(logger.handlers) try: dispatcher = Dispatcher(args) if dispatcher.action is None: diff --git a/Lib/packaging/tests/test_uninstall.py b/Lib/packaging/tests/test_uninstall.py index 4b37286059..00e97e4c70 100644 --- a/Lib/packaging/tests/test_uninstall.py +++ b/Lib/packaging/tests/test_uninstall.py @@ -111,7 +111,7 @@ class UninstallTestCase(support.TempdirManager, old = os.rename def _rename(source, target): - raise OSError() + raise OSError os.rename = _rename try: diff --git a/Lib/packaging/util.py b/Lib/packaging/util.py index 4e5bd2c202..d4aae418dd 100644 --- a/Lib/packaging/util.py +++ b/Lib/packaging/util.py @@ -1,20 +1,18 @@ -"""packaging.util -Miscellaneous utility functions. -""" -import errno -import csv -import hashlib +"""Miscellaneous utility functions.""" + import os -import sys import re +import csv +import sys +import errno import shutil import string +import hashlib import tarfile import zipfile import posixpath -import sysconfig import subprocess -from copy import copy +import sysconfig from glob import iglob as std_iglob from fnmatch import fnmatchcase from inspect import getsource @@ -273,7 +271,7 @@ def execute(func, args, msg=None, verbose=0, dry_run=False): def strtobool(val): - """Convert a string representation of truth to true (1) or false (0). + """Convert a string representation of truth to a boolean. True values are 'y', 'yes', 't', 'true', 'on', and '1'; false values are 'n', 'no', 'f', 'false', 'off', and '0'. Raises ValueError if @@ -384,7 +382,7 @@ byte_compile(files, optimize=%r, force=%r, elif optimize == 2: cmd.insert(1, "-OO") - env = copy(os.environ) + env = os.environ.copy() env['PYTHONPATH'] = os.path.pathsep.join(sys.path) try: spawn(cmd, env=env) |
