mirror of
https://github.com/Mikaela/Limnoria.git
synced 2024-11-27 13:19:24 +01:00
Make the setup.py runnable by Python 3 and run 2to3 automatically.
Conflicts: sandbox/run_2to3.sh setup.py
This commit is contained in:
parent
9e5f7025d8
commit
cadf953e86
28
2to3/run.py
Normal file → Executable file
28
2to3/run.py
Normal file → Executable file
@ -1,6 +1,32 @@
|
|||||||
#! /usr/bin/python2.7
|
#!/usr/bin/env python
|
||||||
|
import os
|
||||||
import sys
|
import sys
|
||||||
|
import shutil
|
||||||
|
from glob import glob
|
||||||
|
try:
|
||||||
from lib2to3.main import main
|
from lib2to3.main import main
|
||||||
|
except ImportError:
|
||||||
|
print('Error: you need the 2to3 tool to run this script.')
|
||||||
|
os.chdir(os.path.join(os.path.dirname(__file__), '..'))
|
||||||
|
try:
|
||||||
|
os.unlink('src/version.py')
|
||||||
|
except OSError:
|
||||||
|
pass
|
||||||
|
try:
|
||||||
|
shutil.rmtree('py3k')
|
||||||
|
except OSError:
|
||||||
|
pass
|
||||||
|
os.mkdir('py3k')
|
||||||
|
for dirname in ('locales', 'docs', 'plugins'):
|
||||||
|
shutil.copytree(dirname, os.path.join('py3k', dirname))
|
||||||
|
|
||||||
|
files = ['run.py', 'src', 'plugins', 'test', 'setup.py'] + glob('scripts/*')
|
||||||
|
args = ['-wWno', 'py3k']
|
||||||
|
fixers = []
|
||||||
|
for fix in ['all', 'def_iteritems', 'def_itervalues', 'def_iterkeys', 'reload']:
|
||||||
|
fixers += ['-f', fix]
|
||||||
|
sys.argv = files + args + fixers + sys.argv
|
||||||
|
sys.argc = len(sys.argv)
|
||||||
|
|
||||||
import fix_def_iteritems, fix_def_itervalues, fix_def_iterkeys, fix_reload
|
import fix_def_iteritems, fix_def_itervalues, fix_def_iterkeys, fix_reload
|
||||||
|
|
||||||
|
@ -1,5 +0,0 @@
|
|||||||
rm -f src/version.py # Prevent 2to3 from copying it, since py3k/src/version.py was probably written by root.
|
|
||||||
cp locale/ py3k/ -R
|
|
||||||
cp docs/ py3k/ -R
|
|
||||||
cp plugins/ py3k/ -R # copy plugins data
|
|
||||||
python 2to3/run.py src/ plugins/ test/ scripts/* setup.py -wWno py3k -f all -f def_iteritems -f def_itervalues -f def_iterkeys -f reload "$@"
|
|
55
setup.py
55
setup.py
@ -31,27 +31,8 @@
|
|||||||
###
|
###
|
||||||
|
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
if sys.version_info < (2, 6, 0):
|
|
||||||
sys.stderr.write("Supybot requires Python 2.6 or newer.\n")
|
|
||||||
sys.exit(-1)
|
|
||||||
|
|
||||||
import textwrap
|
|
||||||
|
|
||||||
clean = False
|
|
||||||
while '--clean' in sys.argv:
|
|
||||||
clean = True
|
|
||||||
sys.argv.remove('--clean')
|
|
||||||
|
|
||||||
import glob
|
|
||||||
import shutil
|
|
||||||
import os
|
|
||||||
import subprocess
|
import subprocess
|
||||||
|
|
||||||
|
|
||||||
plugins = [s for s in os.listdir('plugins') if
|
|
||||||
os.path.exists(os.path.join('plugins', s, 'plugin.py'))]
|
|
||||||
|
|
||||||
version = None
|
version = None
|
||||||
try:
|
try:
|
||||||
proc = subprocess.Popen('git show HEAD --format=%ci', shell=True,
|
proc = subprocess.Popen('git show HEAD --format=%ci', shell=True,
|
||||||
@ -60,7 +41,6 @@ try:
|
|||||||
.strip() \
|
.strip() \
|
||||||
.replace(' +', '+') \
|
.replace(' +', '+') \
|
||||||
.replace(' ', 'T')
|
.replace(' ', 'T')
|
||||||
|
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
if not version:
|
if not version:
|
||||||
@ -75,13 +55,40 @@ open(os.path.join('src', 'version.py'), 'a').write(
|
|||||||
|
|
||||||
from src.version import version
|
from src.version import version
|
||||||
|
|
||||||
|
if sys.version_info < (2, 6, 0):
|
||||||
|
sys.stderr.write("Supybot requires Python 2.6 or newer.")
|
||||||
|
sys.stderr.write(os.linesep)
|
||||||
|
sys.exit(-1)
|
||||||
|
elif sys.version_info[0] >= 3 and \
|
||||||
|
not os.path.split(os.path.abspath(os.path.dirname(__file__)))[-1] == 'py3k':
|
||||||
|
# The second condition is used to prevent this script to run recursively
|
||||||
|
subprocess.Popen([sys.executable, os.path.join('2to3', 'run.py')]).wait()
|
||||||
|
os.chdir('py3k')
|
||||||
|
subprocess.Popen([sys.executable] + sys.argv).wait()
|
||||||
|
|
||||||
|
|
||||||
|
import textwrap
|
||||||
|
|
||||||
|
clean = False
|
||||||
|
while '--clean' in sys.argv:
|
||||||
|
clean = True
|
||||||
|
sys.argv.remove('--clean')
|
||||||
|
|
||||||
|
import glob
|
||||||
|
import shutil
|
||||||
|
import os
|
||||||
|
|
||||||
|
|
||||||
|
plugins = [s for s in os.listdir('plugins') if
|
||||||
|
os.path.exists(os.path.join('plugins', s, 'plugin.py'))]
|
||||||
|
|
||||||
def normalizeWhitespace(s):
|
def normalizeWhitespace(s):
|
||||||
return ' '.join(s.split())
|
return ' '.join(s.split())
|
||||||
|
|
||||||
try:
|
try:
|
||||||
from distutils.core import setup
|
from distutils.core import setup
|
||||||
from distutils.sysconfig import get_python_lib
|
from distutils.sysconfig import get_python_lib
|
||||||
except ImportError, e:
|
except ImportError as e:
|
||||||
s = normalizeWhitespace("""Supybot requires the distutils package to
|
s = normalizeWhitespace("""Supybot requires the distutils package to
|
||||||
install. This package is normally included with Python, but for some
|
install. This package is normally included with Python, but for some
|
||||||
unfathomable reason, many distributions to take it out of standard Python
|
unfathomable reason, many distributions to take it out of standard Python
|
||||||
@ -102,10 +109,10 @@ if clean:
|
|||||||
previousInstall = os.path.join(get_python_lib(), 'supybot')
|
previousInstall = os.path.join(get_python_lib(), 'supybot')
|
||||||
if os.path.exists(previousInstall):
|
if os.path.exists(previousInstall):
|
||||||
try:
|
try:
|
||||||
print 'Removing current installation.'
|
print('Removing current installation.')
|
||||||
shutil.rmtree(previousInstall)
|
shutil.rmtree(previousInstall)
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
print 'Couldn\'t remove former installation: %s' % e
|
print('Couldn\'t remove former installation: %s' % e)
|
||||||
sys.exit(-1)
|
sys.exit(-1)
|
||||||
|
|
||||||
packages = ['supybot',
|
packages = ['supybot',
|
||||||
|
Loading…
Reference in New Issue
Block a user