mirror of
https://github.com/python/cpython.git
synced 2025-07-25 20:24:11 +00:00
Issue #4072: Restore build_py_2to3. Add a distutils demo for
build_py_2to3.
This commit is contained in:
parent
aa3066925a
commit
33b6450d23
6 changed files with 52 additions and 12 deletions
3
Demo/distutils/test2to3/README
Normal file
3
Demo/distutils/test2to3/README
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
This project demonstrates how a distutils package
|
||||||
|
can support Python 2.x and Python 3.x from a single
|
||||||
|
source, using lib2to3.
|
18
Demo/distutils/test2to3/setup.py
Normal file
18
Demo/distutils/test2to3/setup.py
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
# -*- coding: iso-8859-1 -*-
|
||||||
|
from distutils.core import setup
|
||||||
|
|
||||||
|
try:
|
||||||
|
from distutils.command.build_py import build_py_2to3 as build_py
|
||||||
|
except ImportError:
|
||||||
|
from distutils.command.build_py import build_py
|
||||||
|
|
||||||
|
setup(
|
||||||
|
name = "test2to3",
|
||||||
|
version = "1.0",
|
||||||
|
description = "2to3 distutils test package",
|
||||||
|
author = "Martin v. Löwis",
|
||||||
|
author_email = "python-dev@python.org",
|
||||||
|
license = "PSF license",
|
||||||
|
packages = ["test2to3"],
|
||||||
|
cmdclass = {'build_py':build_py}
|
||||||
|
)
|
1
Demo/distutils/test2to3/test2to3/__init__.py
Normal file
1
Demo/distutils/test2to3/test2to3/__init__.py
Normal file
|
@ -0,0 +1 @@
|
||||||
|
# empty
|
5
Demo/distutils/test2to3/test2to3/hello.py
Normal file
5
Demo/distutils/test2to3/test2to3/hello.py
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
def hello():
|
||||||
|
try:
|
||||||
|
print "Hello, world"
|
||||||
|
except IOError, e:
|
||||||
|
print e.errno
|
|
@ -384,6 +384,18 @@ class build_py (Command):
|
||||||
byte_compile(files, optimize=self.optimize,
|
byte_compile(files, optimize=self.optimize,
|
||||||
force=self.force, prefix=prefix, dry_run=self.dry_run)
|
force=self.force, prefix=prefix, dry_run=self.dry_run)
|
||||||
|
|
||||||
|
from lib2to3.refactor import RefactoringTool, get_fixers_from_package
|
||||||
|
class DistutilsRefactoringTool(RefactoringTool):
|
||||||
|
def log_error(self, msg, *args, **kw):
|
||||||
|
# XXX ignores kw
|
||||||
|
log.error(msg, *args)
|
||||||
|
|
||||||
|
def log_message(self, msg, *args):
|
||||||
|
log.info(msg, *args)
|
||||||
|
|
||||||
|
def log_debug(self, msg, *args):
|
||||||
|
log.debug(msg, *args)
|
||||||
|
|
||||||
class build_py_2to3(build_py):
|
class build_py_2to3(build_py):
|
||||||
def run(self):
|
def run(self):
|
||||||
self.updated_files = []
|
self.updated_files = []
|
||||||
|
@ -396,18 +408,12 @@ class build_py_2to3(build_py):
|
||||||
self.build_package_data()
|
self.build_package_data()
|
||||||
|
|
||||||
# 2to3
|
# 2to3
|
||||||
from lib2to3.refactor import RefactoringTool
|
fixers = get_fixers_from_package('lib2to3.fixes')
|
||||||
class Options:
|
options = dict(fix=[], list_fixes=[],
|
||||||
pass
|
print_function=False, verbose=False,
|
||||||
o = Options()
|
write=True)
|
||||||
o.doctests_only = False
|
r = DistutilsRefactoringTool(fixers, options)
|
||||||
o.fix = []
|
r.refactor(self.updated_files, write=True)
|
||||||
o.list_fixes = []
|
|
||||||
o.print_function = False
|
|
||||||
o.verbose = False
|
|
||||||
o.write = True
|
|
||||||
r = RefactoringTool(o)
|
|
||||||
r.refactor_args(self.updated_files)
|
|
||||||
|
|
||||||
# Remaining base class code
|
# Remaining base class code
|
||||||
self.byte_compile(self.get_outputs(include_bytecode=0))
|
self.byte_compile(self.get_outputs(include_bytecode=0))
|
||||||
|
|
|
@ -31,6 +31,8 @@ Core and Builtins
|
||||||
Library
|
Library
|
||||||
-------
|
-------
|
||||||
|
|
||||||
|
- Issue #4072: Restore build_py_2to3.
|
||||||
|
|
||||||
- Issue #4014: Don't claim that Python has an Alpha release status, in addition
|
- Issue #4014: Don't claim that Python has an Alpha release status, in addition
|
||||||
to claiming it is Mature.
|
to claiming it is Mature.
|
||||||
|
|
||||||
|
@ -63,6 +65,11 @@ Build
|
||||||
|
|
||||||
- Issue #4018: Disable "for me" installations on Vista.
|
- Issue #4018: Disable "for me" installations on Vista.
|
||||||
|
|
||||||
|
Tools/Demos
|
||||||
|
-----------
|
||||||
|
|
||||||
|
- Issue #4072: Add a distutils demo for build_py_2to3.
|
||||||
|
|
||||||
|
|
||||||
What's New in Python 3.0 release candidate 1
|
What's New in Python 3.0 release candidate 1
|
||||||
============================================
|
============================================
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue