Add some scripts for fetching/building many Python versions and compiling
python sources to bytecode in each of them.
This commit is contained in:
4
scripts/.gitignore
vendored
Normal file
4
scripts/.gitignore
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
tarballs/
|
||||
Python-*/
|
||||
Python-*.conf.log
|
||||
Python-*.build.log
|
93
scripts/acquire_pythons
Executable file
93
scripts/acquire_pythons
Executable file
@@ -0,0 +1,93 @@
|
||||
#!/bin/bash
|
||||
|
||||
# NOTE: This script has only been tested on a Debian 9 x86_64 system -- it
|
||||
# is probably not as robust as it should be...
|
||||
|
||||
old_pythons=('1.0.1' '1.1' '1.2' '1.3' '1.4' '1.5.2')
|
||||
old_pyurl='https://legacy.python.org/download/releases/src'
|
||||
|
||||
pythons=('2.0.1' '2.1.3' '2.2.3' '2.3.7' '2.4.6' '2.5.6' '2.6.9' '2.7.14'
|
||||
'3.0.1' '3.1.5' '3.2.6' '3.3.7' '3.4.8' '3.5.5' '3.6.5')
|
||||
py_url='https://www.python.org/ftp/python'
|
||||
|
||||
|
||||
set -e
|
||||
|
||||
srcdir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
startdir="$(pwd)"
|
||||
|
||||
fetch_python() {
|
||||
local url="$1"
|
||||
local tarball="${url##*/}"
|
||||
local version="$2"
|
||||
|
||||
if [[ ! -d "Python-${version}" ]]; then
|
||||
local tarfile="${srcdir}/tarballs/${tarball}"
|
||||
if [[ ! -f "$tarfile" ]]; then
|
||||
if [[ "$version" == "1.6.1" ]]; then
|
||||
echo "Python 1.6.1 cannot be downloaded automatically due to a license agreement"
|
||||
echo "which must be manually accepted."
|
||||
echo "Please download it from https://www.python.org/download/releases/1.6.1/download/"
|
||||
echo "and place the tarball in ${srcdir}/tarballs"
|
||||
exit 1
|
||||
fi
|
||||
echo "Downloading Python-${version}..."
|
||||
( cd "${srcdir}/tarballs" && curl -LfO# "$url" )
|
||||
fi
|
||||
echo "Extracting Python-${version}..."
|
||||
tar xaf "${srcdir}/tarballs/${tarball}"
|
||||
[[ -d "python-${version}" ]] && mv "python-${version}" "Python-${version}"
|
||||
if [[ -f "${srcdir}/python-builds/Python-${version}.patch" ]]; then
|
||||
(
|
||||
cd "Python-${version}" &&
|
||||
patch -p1 -i "${srcdir}/python-builds/Python-${version}.patch"
|
||||
)
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
build_python() {
|
||||
local version="$1"
|
||||
|
||||
if [[ ! -x "Python-${version}/python" ]]; then
|
||||
echo "Configuring Python-${version}..."
|
||||
rm -f "${startdir}/Python-${version}.conf.log"
|
||||
(
|
||||
cd "Python-${version}"
|
||||
if ! ./configure > "${startdir}/Python-${version}.conf.log" 2>&1; then
|
||||
echo "... Configuration failed. See Python-${version}.conf.log for details"
|
||||
exit 1
|
||||
fi
|
||||
)
|
||||
|
||||
echo "Building Python-${version}..."
|
||||
rm -f "${startdir}/Python-${version}.build.log"
|
||||
(
|
||||
cd "Python-${version}"
|
||||
if ! make > "${startdir}/Python-${version}.build.log" 2>&1; then
|
||||
echo "... Configuration failed. See Python-${version}.build.log for details"
|
||||
exit 1
|
||||
fi
|
||||
)
|
||||
fi
|
||||
}
|
||||
|
||||
mkdir -p "${startdir}/tarballs"
|
||||
|
||||
for ver in ${old_pythons[@]:0:2}; do
|
||||
fetch_python "${old_pyurl}/python${ver}.tar.gz" "$ver"
|
||||
build_python "$ver"
|
||||
done
|
||||
for ver in ${old_pythons[@]:2}; do
|
||||
fetch_python "${old_pyurl}/python-${ver}.tar.gz" "$ver"
|
||||
build_python "$ver"
|
||||
done
|
||||
|
||||
# 1.6.1 must be downloaded manually
|
||||
fetch_python "https://INVALID_URL_FOR/Python-1.6.1.tar.gz" "1.6.1"
|
||||
build_python "1.6.1"
|
||||
|
||||
for ver in ${pythons[@]}; do
|
||||
fetch_python "${py_url}/${ver}/Python-${ver}.tgz" "$ver"
|
||||
build_python "$ver"
|
||||
done
|
122
scripts/pyparc
Executable file
122
scripts/pyparc
Executable file
@@ -0,0 +1,122 @@
|
||||
#!/usr/bin/env python3
|
||||
# PyParC - Python Parallel Compiler
|
||||
|
||||
import os
|
||||
import sys
|
||||
import subprocess
|
||||
import shutil
|
||||
|
||||
pythons1 = [
|
||||
'Python-1.0.1',
|
||||
'Python-1.1',
|
||||
'Python-1.2',
|
||||
'Python-1.3',
|
||||
'Python-1.4',
|
||||
'Python-1.5.2',
|
||||
'Python-1.6.1',
|
||||
]
|
||||
|
||||
pythons2 = [
|
||||
'Python-2.0.1',
|
||||
'Python-2.1.3',
|
||||
'Python-2.2.3',
|
||||
'Python-2.3.7',
|
||||
'Python-2.4.6',
|
||||
'Python-2.5.6',
|
||||
'Python-2.6.9',
|
||||
'Python-2.7.14',
|
||||
]
|
||||
|
||||
pythons3 = [
|
||||
'Python-3.0.1',
|
||||
'Python-3.1.5',
|
||||
'Python-3.2.6',
|
||||
'Python-3.3.7',
|
||||
'Python-3.4.8',
|
||||
'Python-3.5.5',
|
||||
'Python-3.6.5',
|
||||
]
|
||||
|
||||
if len(sys.argv) < 2:
|
||||
print('Usage: {} [options] input.py'.format(sys.argv[0]))
|
||||
print('Compile input.py for many pythons')
|
||||
print('Output is written to input.<version>.pyc for each version successfully compiled')
|
||||
print()
|
||||
print('Options:')
|
||||
print(' -1 Compile for Python 1.x only')
|
||||
print(' -2 Compile for Python 2.x only')
|
||||
print(' -12 Compile for Python 1.x and 2.x versions (default)')
|
||||
print(' -3 Compile for Python 3.x only')
|
||||
print(' -23 Compile for Python 2.x and 3.x versions')
|
||||
print(' -A Attempt to compile for all known python versions')
|
||||
sys.exit(1)
|
||||
|
||||
pythons = pythons1 + pythons2
|
||||
infile = None
|
||||
for arg in sys.argv[1:]:
|
||||
if arg == '-1':
|
||||
pythons = pythons1
|
||||
elif arg == '-2':
|
||||
pythons = pythons2
|
||||
elif arg == '-12':
|
||||
pythons = pythons1 + pythons2
|
||||
elif arg == '-3':
|
||||
pythons = pythons3
|
||||
elif arg == '-23':
|
||||
pythons = pythons2 + pythons3
|
||||
elif arg == '-A':
|
||||
pythons = pythons1 + pythons2 + pythons3
|
||||
else:
|
||||
infile = arg
|
||||
|
||||
if infile is None:
|
||||
print('No input file specified')
|
||||
sys.exit(1)
|
||||
elif not os.path.exists(infile):
|
||||
print('Error: Input file {} does not exist'.format(infile))
|
||||
sys.exit(1)
|
||||
|
||||
snekdir = os.path.dirname(os.path.realpath(__file__))
|
||||
for snek in pythons:
|
||||
pyexe = os.path.join(snekdir, snek, 'python')
|
||||
proc = subprocess.Popen([pyexe, '-c', 'import sys; print(sys.version)'],
|
||||
stdout=subprocess.PIPE)
|
||||
out, _ = proc.communicate()
|
||||
if proc.returncode != 0:
|
||||
print('Could not determine Python version for {}'.format(snek))
|
||||
continue
|
||||
|
||||
bcver = str(out[:3], 'iso-8859-1')
|
||||
if '.py' in infile:
|
||||
outfile = infile.replace('.py', '.{}.pyc'.format(bcver))
|
||||
else:
|
||||
outfile = infile + '.{}.pyc'.format(bcver)
|
||||
if os.path.exists(outfile):
|
||||
os.unlink(outfile)
|
||||
|
||||
print('*** Compiling for {}'.format(snek))
|
||||
if bcver in {'1.0', '1.1', '1.2', '1.3', '1.4'}:
|
||||
# The hard way -- hope your code is safe...
|
||||
srcdir = os.path.dirname(os.path.realpath(infile))
|
||||
comptmp = os.path.join(srcdir, 'pyparc_temp.py')
|
||||
if os.path.exists(comptmp):
|
||||
os.unlink(comptmp)
|
||||
shutil.copyfile(infile, comptmp)
|
||||
cwdsave = os.getcwd()
|
||||
os.chdir(srcdir)
|
||||
proc = subprocess.Popen([pyexe, '-c', 'import pyparc_temp'])
|
||||
proc.communicate()
|
||||
os.chdir(cwdsave)
|
||||
if os.path.exists(comptmp + 'o'):
|
||||
shutil.copyfile(comptmp + 'o', outfile)
|
||||
os.unlink(comptmp + 'o')
|
||||
elif os.path.exists(comptmp + 'c'):
|
||||
shutil.copyfile(comptmp + 'c', outfile)
|
||||
os.unlink(comptmp + 'c')
|
||||
os.unlink(comptmp)
|
||||
else:
|
||||
# The easy way
|
||||
proc = subprocess.Popen([pyexe, '-c',
|
||||
"import py_compile; py_compile.compile('{}', '{}')" \
|
||||
.format(infile, outfile)])
|
||||
proc.communicate()
|
40
scripts/python-builds/Python-1.0.1.patch
Normal file
40
scripts/python-builds/Python-1.0.1.patch
Normal file
@@ -0,0 +1,40 @@
|
||||
diff --git a/Objects/fileobject.c b/Objects/fileobject.c
|
||||
index e79a671..b1bd74e 100644
|
||||
--- a/Objects/fileobject.c
|
||||
+++ b/Objects/fileobject.c
|
||||
@@ -336,7 +336,7 @@ file_read(f, args)
|
||||
*/
|
||||
|
||||
static object *
|
||||
-getline(f, n)
|
||||
+_py_getline(f, n)
|
||||
fileobject *f;
|
||||
int n;
|
||||
{
|
||||
@@ -458,7 +458,7 @@ filegetline(f, n)
|
||||
}
|
||||
if (((fileobject*)f)->f_fp == NULL)
|
||||
return err_closed();
|
||||
- return getline((fileobject *)f, n);
|
||||
+ return _py_getline((fileobject *)f, n);
|
||||
}
|
||||
|
||||
/* Python method */
|
||||
@@ -483,7 +483,7 @@ file_readline(f, args)
|
||||
}
|
||||
}
|
||||
|
||||
- return getline(f, n);
|
||||
+ return _py_getline(f, n);
|
||||
}
|
||||
|
||||
static object *
|
||||
@@ -501,7 +501,7 @@ file_readlines(f, args)
|
||||
if ((list = newlistobject(0)) == NULL)
|
||||
return NULL;
|
||||
for (;;) {
|
||||
- line = getline(f, 0);
|
||||
+ line = _py_getline(f, 0);
|
||||
if (line != NULL && getstringsize(line) == 0) {
|
||||
DECREF(line);
|
||||
break;
|
8870
scripts/python-builds/Python-1.1.patch
Normal file
8870
scripts/python-builds/Python-1.1.patch
Normal file
File diff suppressed because it is too large
Load Diff
9008
scripts/python-builds/Python-1.2.patch
Normal file
9008
scripts/python-builds/Python-1.2.patch
Normal file
File diff suppressed because it is too large
Load Diff
8910
scripts/python-builds/Python-1.3.patch
Normal file
8910
scripts/python-builds/Python-1.3.patch
Normal file
File diff suppressed because it is too large
Load Diff
9594
scripts/python-builds/Python-1.4.patch
Normal file
9594
scripts/python-builds/Python-1.4.patch
Normal file
File diff suppressed because it is too large
Load Diff
40
scripts/python-builds/Python-1.5.2.patch
Normal file
40
scripts/python-builds/Python-1.5.2.patch
Normal file
@@ -0,0 +1,40 @@
|
||||
diff --git a/Objects/fileobject.c b/Objects/fileobject.c
|
||||
index b0eb332..e1aa559 100644
|
||||
--- a/Objects/fileobject.c
|
||||
+++ b/Objects/fileobject.c
|
||||
@@ -587,7 +587,7 @@ file_readinto(f, args)
|
||||
*/
|
||||
|
||||
static PyObject *
|
||||
-getline(f, n)
|
||||
+_py_getline(f, n)
|
||||
PyFileObject *f;
|
||||
int n;
|
||||
{
|
||||
@@ -709,7 +709,7 @@ PyFile_GetLine(f, n)
|
||||
}
|
||||
if (((PyFileObject*)f)->f_fp == NULL)
|
||||
return err_closed();
|
||||
- return getline((PyFileObject *)f, n);
|
||||
+ return _py_getline((PyFileObject *)f, n);
|
||||
}
|
||||
|
||||
/* Python method */
|
||||
@@ -729,7 +729,7 @@ file_readline(f, args)
|
||||
return PyString_FromString("");
|
||||
if (n < 0)
|
||||
n = 0;
|
||||
- return getline(f, n);
|
||||
+ return _py_getline(f, n);
|
||||
}
|
||||
|
||||
static PyObject *
|
||||
@@ -823,7 +823,7 @@ file_readlines(f, args)
|
||||
goto error;
|
||||
if (sizehint > 0) {
|
||||
/* Need to complete the last line */
|
||||
- PyObject *rest = getline(f, 0);
|
||||
+ PyObject *rest = _py_getline(f, 0);
|
||||
if (rest == NULL) {
|
||||
Py_DECREF(line);
|
||||
goto error;
|
51
scripts/python-builds/Python-2.5.6.patch
Normal file
51
scripts/python-builds/Python-2.5.6.patch
Normal file
@@ -0,0 +1,51 @@
|
||||
diff --git a/Makefile.pre.in b/Makefile.pre.in
|
||||
index 25a82af..9700faa 100644
|
||||
--- a/Makefile.pre.in
|
||||
+++ b/Makefile.pre.in
|
||||
@@ -458,7 +458,7 @@ Modules/getbuildinfo.o: $(PARSER_OBJS) \
|
||||
$(SIGNAL_OBJS) \
|
||||
$(MODOBJS) \
|
||||
$(srcdir)/Modules/getbuildinfo.c
|
||||
- $(CC) -c $(PY_CFLAGS) -DSVNVERSION=\"`LC_ALL=C $(SVNVERSION)`\" -o $@ $(srcdir)/Modules/getbuildinfo.c
|
||||
+ $(CC) -c $(PY_CFLAGS) -DSVNVERSION="\"`LC_ALL=C $(SVNVERSION)`\"" -o $@ $(srcdir)/Modules/getbuildinfo.c
|
||||
|
||||
Modules/getpath.o: $(srcdir)/Modules/getpath.c Makefile
|
||||
$(CC) -c $(PY_CFLAGS) -DPYTHONPATH='"$(PYTHONPATH)"' \
|
||||
diff --git a/setup.py b/setup.py
|
||||
index fbae8df..92a7a08 100644
|
||||
--- a/setup.py
|
||||
+++ b/setup.py
|
||||
@@ -296,7 +296,8 @@ class PyBuildExt(build_ext):
|
||||
# if a file is found in one of those directories, it can
|
||||
# be assumed that no additional -I,-L directives are needed.
|
||||
lib_dirs = self.compiler.library_dirs + [
|
||||
- '/lib64', '/usr/lib64',
|
||||
+ '/usr/lib/x86_64-linux-gnu',
|
||||
+ '/lib/x86_64-linux-gnu',
|
||||
'/lib', '/usr/lib',
|
||||
]
|
||||
inc_dirs = self.compiler.include_dirs + ['/usr/include']
|
||||
@@ -711,9 +712,9 @@ class PyBuildExt(build_ext):
|
||||
|
||||
# check lib directories parallel to the location of the header
|
||||
db_dirs_to_check = [
|
||||
- os.path.join(db_incdir, '..', 'lib64'),
|
||||
+ os.path.join(db_incdir, '..', 'lib/x86_64-linux-gnu'),
|
||||
os.path.join(db_incdir, '..', 'lib'),
|
||||
- os.path.join(db_incdir, '..', '..', 'lib64'),
|
||||
+ os.path.join(db_incdir, '..', '..', 'lib/x86_64-linux-gnu'),
|
||||
os.path.join(db_incdir, '..', '..', 'lib'),
|
||||
]
|
||||
db_dirs_to_check = filter(os.path.isdir, db_dirs_to_check)
|
||||
@@ -800,9 +801,9 @@ class PyBuildExt(build_ext):
|
||||
|
||||
if sqlite_incdir:
|
||||
sqlite_dirs_to_check = [
|
||||
- os.path.join(sqlite_incdir, '..', 'lib64'),
|
||||
+ os.path.join(sqlite_incdir, '..', 'lib/x86_64-linux-gnu'),
|
||||
os.path.join(sqlite_incdir, '..', 'lib'),
|
||||
- os.path.join(sqlite_incdir, '..', '..', 'lib64'),
|
||||
+ os.path.join(sqlite_incdir, '..', '..', 'lib/x86_64-linux-gnu'),
|
||||
os.path.join(sqlite_incdir, '..', '..', 'lib'),
|
||||
]
|
||||
sqlite_libfile = self.compiler.find_library_file(
|
35
scripts/python-builds/Python-2.6.9.patch
Normal file
35
scripts/python-builds/Python-2.6.9.patch
Normal file
@@ -0,0 +1,35 @@
|
||||
diff --git a/setup.py b/setup.py
|
||||
index 4fe1f45..d124268 100644
|
||||
--- a/setup.py
|
||||
+++ b/setup.py
|
||||
@@ -408,7 +408,8 @@ class PyBuildExt(build_ext):
|
||||
# if a file is found in one of those directories, it can
|
||||
# be assumed that no additional -I,-L directives are needed.
|
||||
lib_dirs = self.compiler.library_dirs + [
|
||||
- '/lib64', '/usr/lib64',
|
||||
+ '/usr/lib/x86_64-linux-gnu',
|
||||
+ '/lib/x86_64-linux-gnu',
|
||||
'/lib', '/usr/lib',
|
||||
]
|
||||
inc_dirs = self.compiler.include_dirs + ['/usr/include']
|
||||
@@ -922,7 +923,7 @@ class PyBuildExt(build_ext):
|
||||
|
||||
# check lib directories parallel to the location of the header
|
||||
db_dirs_to_check = [
|
||||
- db_incdir.replace("include", 'lib64'),
|
||||
+ db_incdir.replace("include", 'lib/x86_64-linux-gnu'),
|
||||
db_incdir.replace("include", 'lib'),
|
||||
]
|
||||
|
||||
@@ -1034,9 +1035,9 @@ class PyBuildExt(build_ext):
|
||||
|
||||
if sqlite_incdir:
|
||||
sqlite_dirs_to_check = [
|
||||
- os.path.join(sqlite_incdir, '..', 'lib64'),
|
||||
+ os.path.join(sqlite_incdir, '..', 'lib', 'x86_64-linux-gnu'),
|
||||
os.path.join(sqlite_incdir, '..', 'lib'),
|
||||
- os.path.join(sqlite_incdir, '..', '..', 'lib64'),
|
||||
+ os.path.join(sqlite_incdir, '..', '..', 'lib', 'x86_64-linux-gnu'),
|
||||
os.path.join(sqlite_incdir, '..', '..', 'lib'),
|
||||
]
|
||||
sqlite_libfile = self.compiler.find_library_file(
|
39
scripts/python-builds/Python-3.0.1.patch
Normal file
39
scripts/python-builds/Python-3.0.1.patch
Normal file
@@ -0,0 +1,39 @@
|
||||
diff --git a/Makefile.pre.in b/Makefile.pre.in
|
||||
index 4485a81..54a7e8d 100644
|
||||
--- a/Makefile.pre.in
|
||||
+++ b/Makefile.pre.in
|
||||
@@ -499,7 +499,7 @@ Modules/getbuildinfo.o: $(PARSER_OBJS) \
|
||||
$(SIGNAL_OBJS) \
|
||||
$(MODOBJS) \
|
||||
$(srcdir)/Modules/getbuildinfo.c
|
||||
- $(CC) -c $(PY_CFLAGS) -DSVNVERSION=\"`LC_ALL=C $(SVNVERSION)`\" -o $@ $(srcdir)/Modules/getbuildinfo.c
|
||||
+ $(CC) -c $(PY_CFLAGS) -DSVNVERSION="\"`LC_ALL=C $(SVNVERSION)`\"" -o $@ $(srcdir)/Modules/getbuildinfo.c
|
||||
|
||||
Modules/getpath.o: $(srcdir)/Modules/getpath.c Makefile
|
||||
$(CC) -c $(PY_CFLAGS) -DPYTHONPATH='"$(PYTHONPATH)"' \
|
||||
diff --git a/setup.py b/setup.py
|
||||
index e1d5984..9051d09 100644
|
||||
--- a/setup.py
|
||||
+++ b/setup.py
|
||||
@@ -357,7 +357,8 @@ class PyBuildExt(build_ext):
|
||||
# if a file is found in one of those directories, it can
|
||||
# be assumed that no additional -I,-L directives are needed.
|
||||
lib_dirs = self.compiler.library_dirs + [
|
||||
- '/lib64', '/usr/lib64',
|
||||
+ '/lib/x86_64-linux-gnu',
|
||||
+ '/usr/lib/x86_64-linux-gnu',
|
||||
'/lib', '/usr/lib',
|
||||
]
|
||||
inc_dirs = self.compiler.include_dirs + ['/usr/include']
|
||||
@@ -725,9 +726,9 @@ class PyBuildExt(build_ext):
|
||||
|
||||
if sqlite_incdir:
|
||||
sqlite_dirs_to_check = [
|
||||
- os.path.join(sqlite_incdir, '..', 'lib64'),
|
||||
+ os.path.join(sqlite_incdir, '..', 'lib', 'x86_64-linux-gnu'),
|
||||
os.path.join(sqlite_incdir, '..', 'lib'),
|
||||
- os.path.join(sqlite_incdir, '..', '..', 'lib64'),
|
||||
+ os.path.join(sqlite_incdir, '..', '..', 'lib', 'x86_64-linux-gnu'),
|
||||
os.path.join(sqlite_incdir, '..', '..', 'lib'),
|
||||
]
|
||||
sqlite_libfile = self.compiler.find_library_file(
|
Reference in New Issue
Block a user