Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Python: Checkins

cpython (merge default -> default): Branch merge

 

 

Python checkins RSS feed   Index | Next | Previous | View Threaded


python-checkins at python

Feb 5, 2012, 1:49 AM

Post #1 of 5 (41 views)
Permalink
cpython (merge default -> default): Branch merge

http://hg.python.org/cpython/rev/028e2ba85685
changeset: 74782:028e2ba85685
parent: 74778:ca8c2a185aa3
parent: 74781:edb6f9fb54ac
user: Éric Araujo <merwok [at] netwok>
date: Sun Feb 05 10:48:52 2012 +0100
summary:
Branch merge

files:
Lib/packaging/config.py | 25 ++++-
Lib/packaging/create.py | 36 +++++----
Lib/packaging/tests/test_command_build_py.py | 18 +++-
Lib/packaging/tests/test_command_sdist.py | 1 -
Lib/packaging/tests/test_config.py | 37 ++++++++-
Lib/packaging/tests/test_create.py | 25 +++---
Misc/NEWS | 4 +
7 files changed, 99 insertions(+), 47 deletions(-)


diff --git a/Lib/packaging/config.py b/Lib/packaging/config.py
--- a/Lib/packaging/config.py
+++ b/Lib/packaging/config.py
@@ -20,7 +20,6 @@
if '.' not in name:
return
parts = name.split('.')
- modname = parts[-1]
parent = '.'.join(parts[:-1])
if parent not in packages:
# we could log a warning instead of raising, but what's the use
@@ -227,13 +226,25 @@
self.dist.scripts = [self.dist.scripts]

self.dist.package_data = {}
+ # bookkeeping for the loop below
+ firstline = True
+ prev = None
+
for line in files.get('package_data', []):
- data = line.split('=')
- if len(data) != 2:
- raise ValueError('invalid line for package_data: %s '
- '(misses "=")' % line)
- key, value = data
- self.dist.package_data[key.strip()] = value.strip()
+ if '=' in line:
+ # package name -- file globs or specs
+ key, value = line.split('=')
+ prev = self.dist.package_data[key.strip()] = value.split()
+ elif firstline:
+ # invalid continuation on the first line
+ raise PackagingOptionError(
+ 'malformed package_data first line: %r (misses "=")' %
+ line)
+ else:
+ # continuation, add to last seen package name
+ prev.extend(line.split())
+
+ firstline = False

self.dist.data_files = []
for data in files.get('data_files', []):
diff --git a/Lib/packaging/create.py b/Lib/packaging/create.py
--- a/Lib/packaging/create.py
+++ b/Lib/packaging/create.py
@@ -287,6 +287,7 @@

# optional string entries
if 'keywords' in self.data and self.data['keywords']:
+ # XXX shoud use comma to separate, not space
fp.write('keywords = %s\n' % ' '.join(self.data['keywords']))
for name in ('home_page', 'author', 'author_email',
'maintainer', 'maintainer_email', 'description-file'):
@@ -306,17 +307,29 @@
fp.write('%s = ' % name)
fp.write(''.join(' %s\n' % val
for val in self.data[name]).lstrip())
+
fp.write('\n[files]\n')
- for name in ('packages', 'modules', 'scripts',
- 'package_data', 'extra_files'):
+
+ for name in ('packages', 'modules', 'scripts', 'extra_files'):
if not(name in self.data and self.data[name]):
continue
fp.write('%s = %s\n'
% (name, '\n '.join(self.data[name]).strip()))
- fp.write('\nresources =\n')
- for src, dest in self.data['resources']:
- fp.write(' %s = %s\n' % (src, dest))
- fp.write('\n')
+
+ if self.data.get('package_data'):
+ fp.write('package_data =\n')
+ for pkg, spec in sorted(self.data['package_data'].items()):
+ # put one spec per line, indented under the package name
+ indent = ' ' * (len(pkg) + 7)
+ spec = ('\n' + indent).join(spec)
+ fp.write(' %s = %s\n' % (pkg, spec))
+ fp.write('\n')
+
+ if self.data.get('resources'):
+ fp.write('resources =\n')
+ for src, dest in self.data['resources']:
+ fp.write(' %s = %s\n' % (src, dest))
+ fp.write('\n')

os.chmod(_FILENAME, 0o644)
logger.info('Wrote "%s".' % _FILENAME)
@@ -349,7 +362,6 @@
('long_description', 'description'),
('url', 'home_page'),
('platforms', 'platform'),
- # backport only for 2.5+
('provides', 'provides-dist'),
('obsoletes', 'obsoletes-dist'),
('requires', 'requires-dist'))
@@ -385,14 +397,8 @@
for src in srcs]
data['resources'].extend(files)

- # 2.2 package_data -> extra_files
- package_dirs = dist.package_dir or {}
- for package, extras in dist.package_data.items() or []:
- package_dir = package_dirs.get(package, package)
- for file_ in extras:
- if package_dir:
- file_ = package_dir + '/' + file_
- data['extra_files'].append(file_)
+ # 2.2 package_data
+ data['package_data'] = dist.package_data.copy()

# Use README file if its content is the desciption
if "description" in data:
diff --git a/Lib/packaging/tests/test_command_build_py.py b/Lib/packaging/tests/test_command_build_py.py
--- a/Lib/packaging/tests/test_command_build_py.py
+++ b/Lib/packaging/tests/test_command_build_py.py
@@ -24,11 +24,17 @@
f.write("# Pretend this is a package.")
finally:
f.close()
+ # let's have two files to make sure globbing works
f = open(os.path.join(pkg_dir, "README.txt"), "w")
try:
f.write("Info about this package")
finally:
f.close()
+ f = open(os.path.join(pkg_dir, "HACKING.txt"), "w")
+ try:
+ f.write("How to contribute")
+ finally:
+ f.close()

destination = self.mkdtemp()

@@ -42,7 +48,7 @@
convert_2to3_doctests=None,
use_2to3=False)
dist.packages = ["pkg"]
- dist.package_data = {"pkg": ["README.txt"]}
+ dist.package_data = {"pkg": ["*.txt"]}
dist.package_dir = sources

cmd = build_py(dist)
@@ -55,15 +61,19 @@
# This makes sure the list of outputs includes byte-compiled
# files for Python modules but not for package data files
# (there shouldn't *be* byte-code files for those!).
- #
- self.assertEqual(len(cmd.get_outputs()), 3)
+ # FIXME the test below is not doing what the comment above says, and
+ # if it did it would show a code bug: if we add a demo.py file to
+ # package_data, it gets byte-compiled!
+ outputs = cmd.get_outputs()
+ self.assertEqual(len(outputs), 4, outputs)
pkgdest = os.path.join(destination, "pkg")
files = os.listdir(pkgdest)
pycache_dir = os.path.join(pkgdest, "__pycache__")
self.assertIn("__init__.py", files)
self.assertIn("README.txt", files)
+ self.assertIn("HACKING.txt", files)
pyc_files = os.listdir(pycache_dir)
- self.assertIn("__init__.%s.pyc" % imp.get_tag(), pyc_files)
+ self.assertEqual(["__init__.%s.pyc" % imp.get_tag()], pyc_files)

def test_empty_package_dir(self):
# See SF 1668596/1720897.
diff --git a/Lib/packaging/tests/test_command_sdist.py b/Lib/packaging/tests/test_command_sdist.py
--- a/Lib/packaging/tests/test_command_sdist.py
+++ b/Lib/packaging/tests/test_command_sdist.py
@@ -73,7 +73,6 @@
'author_email': 'xxx'}
dist = Distribution(metadata)
dist.packages = ['somecode']
- dist.include_package_data = True
cmd = sdist(dist)
cmd.dist_dir = 'dist'
return dist, cmd
diff --git a/Lib/packaging/tests/test_config.py b/Lib/packaging/tests/test_config.py
--- a/Lib/packaging/tests/test_config.py
+++ b/Lib/packaging/tests/test_config.py
@@ -66,11 +66,15 @@
bin/taunt

package_data =
- cheese = data/templates/*
+ cheese = data/templates/* doc/*
+ doc/images/*.png
+

extra_files = %(extra-files)s

# Replaces MANIFEST.in
+# FIXME no, it's extra_files
+# (but sdist_extra is a better name, should use it)
sdist_extra =
include THANKS HACKING
recursive-include examples *.txt *.py
@@ -96,6 +100,17 @@
sub_commands = foo
"""

+SETUP_CFG_PKGDATA_BUGGY_1 = """
+[files]
+package_data = foo.*
+"""
+
+SETUP_CFG_PKGDATA_BUGGY_2 = """
+[files]
+package_data =
+ foo.*
+"""
+
# Can not be merged with SETUP_CFG else install_dist
# command will fail when trying to compile C sources
# TODO use a DummyCommand to mock build_ext
@@ -276,13 +291,14 @@

self.assertEqual(dist.packages, ['one', 'two', 'three'])
self.assertEqual(dist.py_modules, ['haven'])
- self.assertEqual(dist.package_data, {'cheese': 'data/templates/*'})
- self.assertEqual(
+ self.assertEqual(dist.package_data,
+ {'cheese': ['data/templates/*', 'doc/*',
+ 'doc/images/*.png']})
+ self.assertEqual(dist.data_files,
{'bm/b1.gif': '{icon}/b1.gif',
'bm/b2.gif': '{icon}/b2.gif',
'Cfg/data.CFG': '{config}/baBar/data.CFG',
- 'init_script': '{script}/JunGle/init_script'},
- dist.data_files)
+ 'init_script': '{script}/JunGle/init_script'})

self.assertEqual(dist.package_dir, 'src')

@@ -293,8 +309,8 @@
# this file would be __main__.Foo when run as "python test_config.py".
# The name FooBarBazTest should be unique enough to prevent
# collisions.
- self.assertEqual('FooBarBazTest',
- dist.get_command_obj('foo').__class__.__name__)
+ self.assertEqual(dist.get_command_obj('foo').__class__.__name__,
+ 'FooBarBazTest')

# did the README got loaded ?
self.assertEqual(dist.metadata['description'], 'yeah')
@@ -304,6 +320,13 @@
d = new_compiler(compiler='d')
self.assertEqual(d.description, 'D Compiler')

+ # check error reporting for invalid package_data value
+ self.write_file('setup.cfg', SETUP_CFG_PKGDATA_BUGGY_1)
+ self.assertRaises(PackagingOptionError, self.get_dist)
+
+ self.write_file('setup.cfg', SETUP_CFG_PKGDATA_BUGGY_2)
+ self.assertRaises(PackagingOptionError, self.get_dist)
+
def test_multiple_description_file(self):
self.write_setup({'description-file': 'README CHANGES'})
self.write_file('README', 'yeah')
diff --git a/Lib/packaging/tests/test_create.py b/Lib/packaging/tests/test_create.py
--- a/Lib/packaging/tests/test_create.py
+++ b/Lib/packaging/tests/test_create.py
@@ -116,7 +116,6 @@
package_data={
'babar': ['Pom', 'Flora', 'Alexander'],
'me': ['dady', 'mumy', 'sys', 'bro'],
- '': ['setup.py', 'README'],
'pyxfoil': ['fengine.so'],
},
scripts=['my_script', 'bin/run'],
@@ -150,16 +149,15 @@
mymodule
scripts = my_script
bin/run
- extra_files = Martinique/Lamentin/dady
- Martinique/Lamentin/mumy
- Martinique/Lamentin/sys
- Martinique/Lamentin/bro
- setup.py
- README
- Pom
- Flora
- Alexander
- pyxfoil/fengine.so
+ package_data =
+ babar = Pom
+ Flora
+ Alexander
+ me = dady
+ mumy
+ sys
+ bro
+ pyxfoil = fengine.so

resources =
README.rst = {doc}
@@ -217,8 +215,9 @@

[files]
packages = pyxfoil
- extra_files = pyxfoil/fengine.so
- pyxfoil/babar.so
+ package_data =
+ pyxfoil = fengine.so
+ babar.so

resources =
README.rst = {doc}
diff --git a/Misc/NEWS b/Misc/NEWS
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -466,6 +466,10 @@
Library
-------

+- Issue #13712: pysetup create should not convert package_data to extra_files.
+
+- Issue #11805: package_data in setup.cfg should allow more than one value.
+
- Issue #13933: IDLE auto-complete did not work with some imported
module, like hashlib. (Patch by Roger Serwy)


--
Repository URL: http://hg.python.org/cpython


python-checkins at python

Feb 9, 2012, 8:13 PM

Post #2 of 5 (34 views)
Permalink
cpython (merge default -> default): Branch merge [In reply to]

http://hg.python.org/cpython/rev/d1f5eb429b25
changeset: 74856:d1f5eb429b25
parent: 74850:0fc10a33eb4c
parent: 74855:7243c3f18769
user: Éric Araujo <merwok [at] netwok>
date: Fri Feb 10 05:12:58 2012 +0100
summary:
Branch merge

files:
Lib/packaging/command/__init__.py | 48 +--
Lib/packaging/compat.py | 19 +-
Lib/packaging/run.py | 9 +-
Lib/packaging/tests/fixer/fix_echo.py | 16 +
Lib/packaging/tests/fixer/fix_echo2.py | 16 +
Lib/packaging/tests/fixer/fix_idioms.py | 134 ------------
Lib/packaging/tests/support.py | 41 +-
Lib/packaging/tests/test_markers.py | 10 +-
Lib/packaging/tests/test_mixin2to3.py | 92 ++++---
Lib/packaging/tests/test_run.py | 17 +
Lib/packaging/util.py | 20 +-
11 files changed, 168 insertions(+), 254 deletions(-)


diff --git a/Lib/packaging/command/__init__.py b/Lib/packaging/command/__init__.py
--- a/Lib/packaging/command/__init__.py
+++ b/Lib/packaging/command/__init__.py
@@ -6,38 +6,28 @@
__all__ = ['get_command_names', 'set_command', 'get_command_class',
'STANDARD_COMMANDS']

-_COMMANDS = {
- 'check': 'packaging.command.check.check',
- 'test': 'packaging.command.test.test',
- 'build': 'packaging.command.build.build',
- 'build_py': 'packaging.command.build_py.build_py',
- 'build_ext': 'packaging.command.build_ext.build_ext',
- 'build_clib': 'packaging.command.build_clib.build_clib',
- 'build_scripts': 'packaging.command.build_scripts.build_scripts',
- 'clean': 'packaging.command.clean.clean',
- 'install_dist': 'packaging.command.install_dist.install_dist',
- 'install_lib': 'packaging.command.install_lib.install_lib',
- 'install_headers': 'packaging.command.install_headers.install_headers',
- 'install_scripts': 'packaging.command.install_scripts.install_scripts',
- 'install_data': 'packaging.command.install_data.install_data',
- 'install_distinfo':
- 'packaging.command.install_distinfo.install_distinfo',
- 'sdist': 'packaging.command.sdist.sdist',
- 'bdist': 'packaging.command.bdist.bdist',
- 'bdist_dumb': 'packaging.command.bdist_dumb.bdist_dumb',
- 'bdist_wininst': 'packaging.command.bdist_wininst.bdist_wininst',
- 'register': 'packaging.command.register.register',
- 'upload': 'packaging.command.upload.upload',
- 'upload_docs': 'packaging.command.upload_docs.upload_docs',
-}

-# XXX this is crappy
+STANDARD_COMMANDS = [.
+ # packaging
+ 'check', 'test',
+ # building
+ 'build', 'build_py', 'build_ext', 'build_clib', 'build_scripts', 'clean',
+ # installing
+ 'install_dist', 'install_lib', 'install_headers', 'install_scripts',
+ 'install_data', 'install_distinfo',
+ # distributing
+ 'sdist', 'bdist', 'bdist_dumb', 'bdist_wininst',
+ 'register', 'upload', 'upload_docs',
+ ]
+
if os.name == 'nt':
- _COMMANDS['bdist_msi'] = 'packaging.command.bdist_msi.bdist_msi'
+ STANDARD_COMMANDS.insert(STANDARD_COMMANDS.index('bdist_wininst'),
+ 'bdist_msi')

-# XXX use OrderedDict to preserve the grouping (build-related, install-related,
-# distribution-related)
-STANDARD_COMMANDS = set(_COMMANDS)
+# XXX maybe we need more than one registry, so that --list-comands can display
+# standard, custom and overriden standard commands differently
+_COMMANDS = dict((name, 'packaging.command.%s.%s' % (name, name))
+ for name in STANDARD_COMMANDS)


def get_command_names():
diff --git a/Lib/packaging/compat.py b/Lib/packaging/compat.py
--- a/Lib/packaging/compat.py
+++ b/Lib/packaging/compat.py
@@ -1,4 +1,4 @@
-"""Compatibility helpers."""
+"""Support for build-time 2to3 conversion."""

from packaging import logger

@@ -25,7 +25,7 @@
"""
if _CONVERT:

- def _run_2to3(self, files, doctests=[], fixers=[]):
+ def _run_2to3(self, files=[], doctests=[], fixers=[]):
""" Takes a list of files and doctests, and performs conversion
on those.
- First, the files which contain the code(`files`) are converted.
@@ -35,17 +35,16 @@
if fixers:
self.fixer_names = fixers

- logger.info('converting Python code')
- _KLASS.run_2to3(self, files)
+ if files:
+ logger.info('converting Python code and doctests')
+ _KLASS.run_2to3(self, files)
+ _KLASS.run_2to3(self, files, doctests_only=True)

- logger.info('converting doctests in Python files')
- _KLASS.run_2to3(self, files, doctests_only=True)
-
- if doctests != []:
- logger.info('converting doctest in text files')
+ if doctests:
+ logger.info('converting doctests in text files')
_KLASS.run_2to3(self, doctests, doctests_only=True)
else:
# If run on Python 2.x, there is nothing to do.

- def _run_2to3(self, files, doctests=[], fixers=[]):
+ def _run_2to3(self, files=[], doctests=[], fixers=[]):
pass
diff --git a/Lib/packaging/run.py b/Lib/packaging/run.py
--- a/Lib/packaging/run.py
+++ b/Lib/packaging/run.py
@@ -254,16 +254,13 @@
parser = dispatcher.parser
args = args[1:]

- commands = STANDARD_COMMANDS # + extra commands
+ commands = STANDARD_COMMANDS # FIXME display extra commands

if args == ['--list-commands']:
print('List of available commands:')
- cmds = sorted(commands)
-
- for cmd in cmds:
+ for cmd in commands:
cls = dispatcher.cmdclass.get(cmd) or get_command_class(cmd)
- desc = getattr(cls, 'description',
- '(no description available)')
+ desc = getattr(cls, 'description', '(no description available)')
print(' %s: %s' % (cmd, desc))
return

diff --git a/Lib/packaging/tests/fixer/fix_echo.py b/Lib/packaging/tests/fixer/fix_echo.py
new file mode 100644
--- /dev/null
+++ b/Lib/packaging/tests/fixer/fix_echo.py
@@ -0,0 +1,16 @@
+# Example custom fixer, derived from fix_raw_input by Andre Roberge
+
+from lib2to3 import fixer_base
+from lib2to3.fixer_util import Name
+
+
+class FixEcho(fixer_base.BaseFix):
+
+ BM_compatible = True
+ PATTERN = """
+ power< name='echo' trailer< '(' [any] ')' > any* >
+ """
+
+ def transform(self, node, results):
+ name = results['name']
+ name.replace(Name('print', prefix=name.prefix))
diff --git a/Lib/packaging/tests/fixer/fix_echo2.py b/Lib/packaging/tests/fixer/fix_echo2.py
new file mode 100644
--- /dev/null
+++ b/Lib/packaging/tests/fixer/fix_echo2.py
@@ -0,0 +1,16 @@
+# Example custom fixer, derived from fix_raw_input by Andre Roberge
+
+from lib2to3 import fixer_base
+from lib2to3.fixer_util import Name
+
+
+class FixEcho2(fixer_base.BaseFix):
+
+ BM_compatible = True
+ PATTERN = """
+ power< name='echo2' trailer< '(' [any] ')' > any* >
+ """
+
+ def transform(self, node, results):
+ name = results['name']
+ name.replace(Name('print', prefix=name.prefix))
diff --git a/Lib/packaging/tests/fixer/fix_idioms.py b/Lib/packaging/tests/fixer/fix_idioms.py
deleted file mode 100644
--- a/Lib/packaging/tests/fixer/fix_idioms.py
+++ /dev/null
@@ -1,134 +0,0 @@
-"""Adjust some old Python 2 idioms to their modern counterparts.
-
-* Change some type comparisons to isinstance() calls:
- type(x) == T -> isinstance(x, T)
- type(x) is T -> isinstance(x, T)
- type(x) != T -> not isinstance(x, T)
- type(x) is not T -> not isinstance(x, T)
-
-* Change "while 1:" into "while True:".
-
-* Change both
-
- v = list(EXPR)
- v.sort()
- foo(v)
-
-and the more general
-
- v = EXPR
- v.sort()
- foo(v)
-
-into
-
- v = sorted(EXPR)
- foo(v)
-"""
-# Author: Jacques Frechet, Collin Winter
-
-# Local imports
-from lib2to3 import fixer_base
-from lib2to3.fixer_util import Call, Comma, Name, Node, syms
-
-CMP = "(n='!=' | '==' | 'is' | n=comp_op< 'is' 'not' >)"
-TYPE = "power< 'type' trailer< '(' x=any ')' > >"
-
-class FixIdioms(fixer_base.BaseFix):
-
- explicit = False # The user must ask for this fixer
-
- PATTERN = r"""
- isinstance=comparison< %s %s T=any >
- |
- isinstance=comparison< T=any %s %s >
- |
- while_stmt< 'while' while='1' ':' any+ >
- |
- sorted=any<
- any*
- simple_stmt<
- expr_stmt< id1=any '='
- power< list='list' trailer< '(' (not arglist<any+>) any ')' > >
- >
- '\n'
- >
- sort=
- simple_stmt<
- power< id2=any
- trailer< '.' 'sort' > trailer< '(' ')' >
- >
- '\n'
- >
- next=any*
- >
- |
- sorted=any<
- any*
- simple_stmt< expr_stmt< id1=any '=' expr=any > '\n' >
- sort=
- simple_stmt<
- power< id2=any
- trailer< '.' 'sort' > trailer< '(' ')' >
- >
- '\n'
- >
- next=any*
- >
- """ % (TYPE, CMP, CMP, TYPE)
-
- def match(self, node):
- r = super(FixIdioms, self).match(node)
- # If we've matched one of the sort/sorted subpatterns above, we
- # want to reject matches where the initial assignment and the
- # subsequent .sort() call involve different identifiers.
- if r and "sorted" in r:
- if r["id1"] == r["id2"]:
- return r
- return None
- return r
-
- def transform(self, node, results):
- if "isinstance" in results:
- return self.transform_isinstance(node, results)
- elif "while" in results:
- return self.transform_while(node, results)
- elif "sorted" in results:
- return self.transform_sort(node, results)
- else:
- raise RuntimeError("Invalid match")
-
- def transform_isinstance(self, node, results):
- x = results["x"].clone() # The thing inside of type()
- T = results["T"].clone() # The type being compared against
- x.prefix = ""
- T.prefix = " "
- test = Call(Name("isinstance"), [x, Comma(), T])
- if "n" in results:
- test.prefix = " "
- test = Node(syms.not_test, [Name("not"), test])
- test.prefix = node.prefix
- return test
-
- def transform_while(self, node, results):
- one = results["while"]
- one.replace(Name("True", prefix=one.prefix))
-
- def transform_sort(self, node, results):
- sort_stmt = results["sort"]
- next_stmt = results["next"]
- list_call = results.get("list")
- simple_expr = results.get("expr")
-
- if list_call:
- list_call.replace(Name("sorted", prefix=list_call.prefix))
- elif simple_expr:
- new = simple_expr.clone()
- new.prefix = ""
- simple_expr.replace(Call(Name("sorted"), [new],
- prefix=simple_expr.prefix))
- else:
- raise RuntimeError("should not have reached here")
- sort_stmt.remove()
- if next_stmt:
- next_stmt[0].prefix = sort_stmt._prefix
diff --git a/Lib/packaging/tests/support.py b/Lib/packaging/tests/support.py
--- a/Lib/packaging/tests/support.py
+++ b/Lib/packaging/tests/support.py
@@ -56,8 +56,9 @@
# misc. functions and decorators
'fake_dec', 'create_distribution', 'use_command',
'copy_xxmodule_c', 'fixup_build_ext',
+ 'skip_2to3_optimize',
# imported from this module for backport purposes
- 'unittest', 'requires_zlib', 'skip_2to3_optimize', 'skip_unless_symlink',
+ 'unittest', 'requires_zlib', 'skip_unless_symlink',
]


@@ -332,22 +333,18 @@
"""
filename = _get_xxmodule_path()
if filename is None:
- raise unittest.SkipTest('cannot find xxmodule.c (test must run in '
- 'the python build dir)')
+ raise unittest.SkipTest('cannot find xxmodule.c')
shutil.copy(filename, directory)


def _get_xxmodule_path():
- srcdir = sysconfig.get_config_var('srcdir')
- candidates = [.
- # use installed copy if available
- os.path.join(os.path.dirname(__file__), 'xxmodule.c'),
- # otherwise try using copy from build directory
- os.path.join(srcdir, 'Modules', 'xxmodule.c'),
- ]
- for path in candidates:
- if os.path.exists(path):
- return path
+ if sysconfig.is_python_build():
+ srcdir = sysconfig.get_config_var('projectbase')
+ path = os.path.join(os.getcwd(), srcdir, 'Modules', 'xxmodule.c')
+ else:
+ os.path.join(os.path.dirname(__file__), 'xxmodule.c')
+ if os.path.exists(path):
+ return path


def fixup_build_ext(cmd):
@@ -355,20 +352,21 @@

When Python was built with --enable-shared on Unix, -L. is not enough to
find libpython<blah>.so, because regrtest runs in a tempdir, not in the
- source directory where the .so lives.
+ source directory where the .so lives. (Mac OS X embeds absolute paths
+ to shared libraries into executables, so the fixup is a no-op on that
+ platform.)

When Python was built with in debug mode on Windows, build_ext commands
need their debug attribute set, and it is not done automatically for
some reason.

- This function handles both of these things. Example use:
+ This function handles both of these things, and also fixes
+ cmd.distribution.include_dirs if the running Python is an uninstalled
+ build. Example use:

cmd = build_ext(dist)
support.fixup_build_ext(cmd)
cmd.ensure_finalized()
-
- Unlike most other Unix platforms, Mac OS X embeds absolute paths
- to shared libraries into executables, so the fixup is not needed there.
"""
if os.name == 'nt':
cmd.debug = sys.executable.endswith('_d.exe')
@@ -386,12 +384,17 @@
name, equals, value = runshared.partition('=')
cmd.library_dirs = value.split(os.pathsep)

+ # Allow tests to run with an uninstalled Python
+ if sysconfig.is_python_build():
+ pysrcdir = sysconfig.get_config_var('projectbase')
+ cmd.distribution.include_dirs.append(os.path.join(pysrcdir, 'Include'))
+
+
try:
from test.support import skip_unless_symlink
except ImportError:
skip_unless_symlink = unittest.skip(
'requires test.support.skip_unless_symlink')

-
skip_2to3_optimize = unittest.skipIf(sys.flags.optimize,
"2to3 doesn't work under -O")
diff --git a/Lib/packaging/tests/test_markers.py b/Lib/packaging/tests/test_markers.py
--- a/Lib/packaging/tests/test_markers.py
+++ b/Lib/packaging/tests/test_markers.py
@@ -21,8 +21,6 @@

self.assertTrue(interpret("sys.platform == '%s'" % sys_platform))
self.assertTrue(interpret(
- "sys.platform == '%s' or python_version == '2.4'" % sys_platform))
- self.assertTrue(interpret(
"sys.platform == '%s' and python_full_version == '%s'" %
(sys_platform, version)))
self.assertTrue(interpret("'%s' == sys.platform" % sys_platform))
@@ -41,12 +39,18 @@

# combined operations
OP = 'os.name == "%s"' % os_name
+ FALSEOP = 'os.name == "buuuu"'
AND = ' and '
OR = ' or '
self.assertTrue(interpret(OP + AND + OP))
self.assertTrue(interpret(OP + AND + OP + AND + OP))
self.assertTrue(interpret(OP + OR + OP))
- self.assertTrue(interpret(OP + OR + OP + OR + OP))
+ self.assertTrue(interpret(OP + OR + FALSEOP))
+ self.assertTrue(interpret(OP + OR + OP + OR + FALSEOP))
+ self.assertTrue(interpret(OP + OR + FALSEOP + OR + FALSEOP))
+ self.assertTrue(interpret(FALSEOP + OR + OP))
+ self.assertFalse(interpret(FALSEOP + AND + FALSEOP))
+ self.assertFalse(interpret(FALSEOP + OR + FALSEOP))

# other operators
self.assertTrue(interpret("os.name != 'buuuu'"))
diff --git a/Lib/packaging/tests/test_mixin2to3.py b/Lib/packaging/tests/test_mixin2to3.py
--- a/Lib/packaging/tests/test_mixin2to3.py
+++ b/Lib/packaging/tests/test_mixin2to3.py
@@ -8,70 +8,76 @@
support.LoggingCatcher,
unittest.TestCase):

- @support.skip_2to3_optimize
- def test_convert_code_only(self):
- # used to check if code gets converted properly.
- code = "print 'test'"
+ def setUp(self):
+ super(Mixin2to3TestCase, self).setUp()
+ self.filename = self.mktempfile().name

- with self.mktempfile() as fp:
- fp.write(code)
+ def check(self, source, wanted, **kwargs):
+ source = textwrap.dedent(source)
+ with open(self.filename, 'w') as fp:
+ fp.write(source)

- mixin2to3 = Mixin2to3()
- mixin2to3._run_2to3([fp.name])
- expected = "print('test')"
+ Mixin2to3()._run_2to3(**kwargs)

- with open(fp.name) as fp:
+ wanted = textwrap.dedent(wanted)
+ with open(self.filename) as fp:
converted = fp.read()
+ self.assertMultiLineEqual(converted, wanted)

- self.assertEqual(expected, converted)
-
- def test_doctests_only(self):
- # used to check if doctests gets converted properly.
- doctest = textwrap.dedent('''\
+ def test_conversion(self):
+ # check that code and doctests get converted
+ self.check('''\
"""Example docstring.

>>> print test
test

It works.
- """''')
-
- with self.mktempfile() as fp:
- fp.write(doctest)
-
- mixin2to3 = Mixin2to3()
- mixin2to3._run_2to3([fp.name])
- expected = textwrap.dedent('''\
+ """
+ print 'test'
+ ''',
+ '''\
"""Example docstring.

>>> print(test)
test

It works.
- """\n''')
+ """
+ print('test')

- with open(fp.name) as fp:
- converted = fp.read()
+ ''', # 2to3 adds a newline here
+ files=[self.filename])

- self.assertEqual(expected, converted)
+ def test_doctests_conversion(self):
+ # check that doctest files are converted
+ self.check('''\
+ Welcome to the doc.
+
+ >>> print test
+ test
+ ''',
+ '''\
+ Welcome to the doc.
+
+ >>> print(test)
+ test
+
+ ''',
+ doctests=[self.filename])

def test_additional_fixers(self):
- # used to check if use_2to3_fixers works
- code = 'type(x) is not T'
-
- with self.mktempfile() as fp:
- fp.write(code)
-
- mixin2to3 = Mixin2to3()
- mixin2to3._run_2to3(files=[fp.name], doctests=[fp.name],
- fixers=['packaging.tests.fixer'])
-
- expected = 'not isinstance(x, T)'
-
- with open(fp.name) as fp:
- converted = fp.read()
-
- self.assertEqual(expected, converted)
+ # make sure the fixers argument works
+ self.check("""\
+ echo('42')
+ echo2('oh no')
+ """,
+ """\
+ print('42')
+ print('oh no')
+ """,
+ files=[self.filename],
+ fixers=['packaging.tests.fixer'])


def test_suite():
diff --git a/Lib/packaging/tests/test_run.py b/Lib/packaging/tests/test_run.py
--- a/Lib/packaging/tests/test_run.py
+++ b/Lib/packaging/tests/test_run.py
@@ -67,6 +67,23 @@
self.assertGreater(out, b'')
self.assertEqual(err, b'')

+ def test_list_commands(self):
+ status, out, err = assert_python_ok('-m', 'packaging.run', 'run',
+ '--list-commands')
+ # check that something is displayed
+ self.assertEqual(status, 0)
+ self.assertGreater(out, b'')
+ self.assertEqual(err, b'')
+
+ # make sure the manual grouping of commands is respected
+ check_position = out.find(b' check: ')
+ build_position = out.find(b' build: ')
+ self.assertTrue(check_position, out) # "out" printed as debugging aid
+ self.assertTrue(build_position, out)
+ self.assertLess(check_position, build_position, out)
+
+ # TODO test that custom commands don't break --list-commands
+

def test_suite():
return unittest.makeSuite(RunTestCase)
diff --git a/Lib/packaging/util.py b/Lib/packaging/util.py
--- a/Lib/packaging/util.py
+++ b/Lib/packaging/util.py
@@ -853,13 +853,11 @@

# Make this class local, to delay import of 2to3
from lib2to3.refactor import get_fixers_from_package, RefactoringTool
- fixers = []
fixers = get_fixers_from_package('lib2to3.fixes')

if fixer_names:
for fixername in fixer_names:
- fixers.extend(fixer for fixer in
- get_fixers_from_package(fixername))
+ fixers.extend(get_fixers_from_package(fixername))
r = RefactoringTool(fixers, options=options)
r.refactor(files, write=True, doctests_only=doctests_only)

@@ -870,21 +868,23 @@
the class variables, or inherit from this class
to override how 2to3 is invoked.
"""
- # provide list of fixers to run.
- # defaults to all from lib2to3.fixers
+ # list of fixers to run; defaults to all implicit from lib2to3.fixers
fixer_names = None
-
- # options dictionary
+ # dict of options
options = None
-
- # list of fixers to invoke even though they are marked as explicit
+ # list of extra fixers to invoke
explicit = None
+ # TODO need a better way to add just one fixer from a package
+ # TODO need a way to exclude individual fixers

def run_2to3(self, files, doctests_only=False):
""" Issues a call to util.run_2to3. """
return run_2to3(files, doctests_only, self.fixer_names,
self.options, self.explicit)

+ # TODO provide initialize/finalize_options
+
+
RICH_GLOB = re.compile(r'\{([^}]*)\}')
_CHECK_RECURSIVE_GLOB = re.compile(r'[^/\\,{]\*\*|\*\*[^/\\,}]')
_CHECK_MISMATCH_SET = re.compile(r'^[^{]*\}|\{[^}]*$')
@@ -1049,7 +1049,6 @@

SETUP_TEMPLATE = """\
# This script was automatically generated by packaging
-import os
import codecs
from distutils.core import setup
try:
@@ -1057,6 +1056,7 @@
except ImportError:
from configparser import RawConfigParser

+
%(split_multiline)s

%(cfg_to_args)s

--
Repository URL: http://hg.python.org/cpython


python-checkins at python

Feb 17, 2012, 9:14 AM

Post #3 of 5 (35 views)
Permalink
cpython (merge default -> default): Branch merge [In reply to]

http://hg.python.org/cpython/rev/269fde276d7a
changeset: 75004:269fde276d7a
parent: 75001:35c514368276
parent: 75003:697e934ade19
user: Éric Araujo <merwok [at] netwok>
date: Fri Feb 17 18:10:11 2012 +0100
summary:
Branch merge

files:
Lib/packaging/tests/support.py | 2 +-
Lib/packaging/tests/test_util.py | 5 +++++
2 files changed, 6 insertions(+), 1 deletions(-)


diff --git a/Lib/packaging/tests/support.py b/Lib/packaging/tests/support.py
--- a/Lib/packaging/tests/support.py
+++ b/Lib/packaging/tests/support.py
@@ -342,7 +342,7 @@
srcdir = sysconfig.get_config_var('projectbase')
path = os.path.join(os.getcwd(), srcdir, 'Modules', 'xxmodule.c')
else:
- os.path.join(os.path.dirname(__file__), 'xxmodule.c')
+ path = os.path.join(os.path.dirname(__file__), 'xxmodule.c')
if os.path.exists(path):
return path

diff --git a/Lib/packaging/tests/test_util.py b/Lib/packaging/tests/test_util.py
--- a/Lib/packaging/tests/test_util.py
+++ b/Lib/packaging/tests/test_util.py
@@ -173,6 +173,11 @@
sys.stdout = self.old_stdout
sys.stderr = self.old_stderr

+ def test_set_platform(self):
+ self.addCleanup(util.set_platform, util.get_platform())
+ util.set_platform("fake")
+ self.assertEqual("fake", util.get_platform())
+
def test_convert_path(self):
# linux/mac
os.sep = '/'

--
Repository URL: http://hg.python.org/cpython


python-checkins at python

Feb 25, 2012, 7:07 PM

Post #4 of 5 (30 views)
Permalink
cpython (merge default -> default): Branch merge [In reply to]

http://hg.python.org/cpython/rev/4ba743417053
changeset: 75289:4ba743417053
parent: 75287:937b1613d0e6
parent: 75262:39ddcc5c7fb9
user: Éric Araujo <merwok [at] netwok>
date: Sun Feb 26 04:01:54 2012 +0100
summary:
Branch merge

files:
Doc/tools/sphinxext/layout.html | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)


diff --git a/Doc/tools/sphinxext/layout.html b/Doc/tools/sphinxext/layout.html
--- a/Doc/tools/sphinxext/layout.html
+++ b/Doc/tools/sphinxext/layout.html
@@ -6,7 +6,7 @@
{% endblock %}
{% block extrahead %}
<link rel="shortcut icon" type="image/png" href="{{ pathto('_static/py.png', 1) }}" />
- <script type="text/javascript" src="{{ pathto('_static/copybutton.js', 1) }}"></script>
+ {% if not embedded %}<script type="text/javascript" src="{{ pathto('_static/copybutton.js', 1) }}"></script>{% endif %}
{{ super() }}
{% endblock %}
{% block footer %}

--
Repository URL: http://hg.python.org/cpython


python-checkins at python

Mar 5, 2012, 7:26 AM

Post #5 of 5 (29 views)
Permalink
cpython (merge default -> default): Branch merge [In reply to]

http://hg.python.org/cpython/rev/e12a65da2358
changeset: 75430:e12a65da2358
parent: 75429:561532103d74
parent: 75421:84620bca0e35
user: Éric Araujo <merwok [at] netwok>
date: Mon Mar 05 16:25:40 2012 +0100
summary:
Branch merge

files:
Objects/frameobject.c | 1 -
1 files changed, 0 insertions(+), 1 deletions(-)


diff --git a/Objects/frameobject.c b/Objects/frameobject.c
--- a/Objects/frameobject.c
+++ b/Objects/frameobject.c
@@ -20,7 +20,6 @@
{"f_builtins", T_OBJECT, OFF(f_builtins), READONLY},
{"f_globals", T_OBJECT, OFF(f_globals), READONLY},
{"f_lasti", T_INT, OFF(f_lasti), READONLY},
- {"f_yieldfrom", T_OBJECT, OFF(f_yieldfrom), READONLY},
{NULL} /* Sentinel */
};


--
Repository URL: http://hg.python.org/cpython

Python checkins RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact Gossamer Threads
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.