Commit 6badc540 authored by Martin v. Löwis's avatar Martin v. Löwis

Add sdist3 command.

--HG--
branch : distribute
extra : rebase_source : 47f2fee9a8361cabc8160df8dd30dacc67f0f42b
parent b863dd62
[distutils.commands]
bdist_rpm = setuptools.command.bdist_rpm:bdist_rpm
install_scripts = setuptools.command.install_scripts:install_scripts
rotate = setuptools.command.rotate:rotate
develop = setuptools.command.develop:develop
setopt = setuptools.command.setopt:setopt
......@@ -10,11 +11,11 @@ register = setuptools.command.register:register
install_egg_info = setuptools.command.install_egg_info:install_egg_info
alias = setuptools.command.alias:alias
easy_install = setuptools.command.easy_install:easy_install
install_scripts = setuptools.command.install_scripts:install_scripts
test = setuptools.command.test:test
bdist_wininst = setuptools.command.bdist_wininst:bdist_wininst
bdist_egg = setuptools.command.bdist_egg:bdist_egg
install = setuptools.command.install:install
test = setuptools.command.test:test
sdist3 = setuptools.command.sdist3:sdist3
install_lib = setuptools.command.install_lib:install_lib
build_ext = setuptools.command.build_ext:build_ext
sdist = setuptools.command.sdist:sdist
......
__all__ = [
'alias', 'bdist_egg', 'bdist_rpm', 'build_ext', 'build_py', 'develop',
'easy_install', 'egg_info', 'install', 'install_lib', 'rotate', 'saveopts',
'sdist', 'setopt', 'test', 'upload', 'install_egg_info', 'install_scripts',
'sdist', 'sdist3', 'setopt', 'test', 'upload', 'install_egg_info', 'install_scripts',
'register', 'bdist_wininst',
]
......
from distutils import log
from sdist import sdist
from lib2to3.refactor import RefactoringTool, get_fixers_from_package
class _RefactoringTool(RefactoringTool):
def log_error(self, msg, *args, **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 sdist3(sdist):
description = "sdist version that runs 2to3 on all sources before packaging"
fixer_names = None
def copy_file(self, file, dest, link=None):
# We ignore the link parameter, always demanding a copy, so that
# 2to3 won't overwrite the original file.
sdist.copy_file(self, file, dest)
def make_release_tree(self, base_dir, files):
sdist.make_release_tree(self, base_dir, files)
# run 2to3 on all files
fixer_names = self.fixer_names
if fixer_names is None:
fixer_names = get_fixers_from_package('lib2to3.fixes')
r = _RefactoringTool(fixer_names)
r.refactor([f for f in files if f.endswith(".py")], write=True)
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment