Created
January 29, 2022 16:36
-
-
Save dwt/02d8a5c035e9cd3b1da8c55609d3f73b to your computer and use it in GitHub Desktop.
Build Scripts for multiple parallel python versions
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/configure b/configure | |
index c51f396824b63521034929cf98a37cee40b86254..5024860ca4395aa3a71de307a0e8335ceb2d77da 100755 | |
--- a/configure | |
+++ b/configure | |
@@ -3426,7 +3426,7 @@ $as_echo "#define _BSD_SOURCE 1" >>confdefs.h | |
# has no effect, don't bother defining them | |
Darwin/[6789].*) | |
define_xopen_source=no;; | |
- Darwin/1[0-9].*) | |
+ Darwin/[12][0-9].*) | |
define_xopen_source=no;; | |
# On AIX 4 and 5.1, mbstate_t is defined only when _XOPEN_SOURCE == 500 but | |
# used in wcsnrtombs() and mbsnrtowcs() even if _XOPEN_SOURCE is not defined | |
diff --git a/configure.ac b/configure.ac | |
index 70deefb6b9aea660350ee3c0a52c5e701037464b..5a3e340aa3e72b5effe0bc3b69690a828122b9dd 100644 | |
--- a/configure.ac | |
+++ b/configure.ac | |
@@ -510,7 +510,7 @@ case $ac_sys_system/$ac_sys_release in | |
# has no effect, don't bother defining them | |
Darwin/@<:@6789@:>@.*) | |
define_xopen_source=no;; | |
- Darwin/1@<:@0-9@:>@.*) | |
+ Darwin/@<:@[12]@:>@@<:@0-9@:>@.*) | |
define_xopen_source=no;; | |
# On AIX 4 and 5.1, mbstate_t is defined only when _XOPEN_SOURCE == 500 but | |
# used in wcsnrtombs() and mbsnrtowcs() even if _XOPEN_SOURCE is not defined |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/setup.py b/setup.py | |
index bf90600eaa..85c7ecaae6 100644 | |
--- a/setup.py | |
+++ b/setup.py | |
@@ -819,7 +819,8 @@ class PyBuildExt(build_ext): | |
libraries=['m']) ) | |
# readline | |
- do_readline = self.compiler.find_library_file(lib_dirs, 'readline') | |
+ # do_readline = self.compiler.find_library_file(lib_dirs, 'readline') | |
+ do_readline = "/Users/dwt/Library/Homebrew/opt/readline/lib/libhistory.dylib" | |
readline_termcap_library = "" | |
curses_library = "" | |
# Cannot use os.popen here in py3k. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/Python/random.c b/Python/random.c | |
index af3d0bd0d5..c8e9d275b0 100644 | |
--- a/Python/random.c | |
+++ b/Python/random.c | |
@@ -3,6 +3,9 @@ | |
#include <windows.h> | |
#else | |
#include <fcntl.h> | |
+#if defined(HAVE_GETRANDOM) || defined(HAVE_GETENTROPY) | |
+#include <sys/random.h> | |
+#endif | |
#ifdef HAVE_SYS_STAT_H | |
#include <sys/stat.h> | |
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh -e | |
build_python() { | |
local MAJOR_VERSION=$1 | |
local VERSION=$(latest_python $MAJOR_VERSION) | |
local PREFIX=$HOME/Library/Python/SelfBuilt | |
local BINDIR=$HOME/bin | |
git checkout $VERSION | |
# Need to apply the patch before calling ./configure as it patches exactly that | |
patch_if_neccessary $2 | |
patch_if_neccessary $3 | |
./configure --prefix=$PREFIX | |
make -j$(sysctl -n hw.ncpu) altinstall | |
# install | |
ln -fs $PREFIX/bin/python$MAJOR_VERSION $HOME/bin/ | |
clean | |
} | |
die () { | |
echo $1 | |
exit 1 | |
} | |
add_brew_library() { | |
local LIBRARY_NAME=$1 | |
local PREFIX=$(brew --prefix $LIBRARY_NAME) | |
test -d $PREFIX/lib/pkgconfig || die "pkg-config for $LIBRARY_NAME does not exist at $PREFIX/lib/pkgconfig" | |
export PKG_CONFIG_PATH="$PKG_CONFIG_PATH:$PREFIX/lib/pkgconfig" | |
export CPPFLAGS="$CPPFLAGS $(pkg-config $LIBRARY_NAME --cflags)" | |
export LDFLAGS="$LDFLAGS $(pkg-config $LIBRARY_NAME --libs)" | |
} | |
add_brew_libraries() { | |
# As this modifies the environment, need to do this only once | |
add_brew_library readline | |
add_brew_library openssl | |
add_brew_library zlib | |
add_brew_library sqlite3 | |
} | |
patch_if_neccessary() { | |
local PATCH=$1 | |
if [ ! -z "$PATCH" ] ; then | |
patch -p1 < $PATCH | |
fi | |
} | |
clean() { | |
make distclean | |
# remove any leftovers from patches | |
git clean --exclude local_build.sh --exclude local_patches -d --force | |
git checkout . | |
} | |
latest_python() { | |
local MAJOR_VERSION=$1 | |
echo $(git tag | grep $MAJOR_VERSION | grep -v rc | grep -v a | grep -v b | grep -v c | sort --version-sort | tail -n 1) | |
} | |
main() { | |
add_brew_libraries | |
git fetch | |
# show all released versions: | |
# git tag | grep -v rc|grep -v a|grep -v b|grep -v c|sort --version-sort | |
# build_python 3.4 local_patches/fix_configure_recognizes_mac_os_12.patch local_patches/fix_missing_random.patch | |
# build_python 3.5 local_patches/fix_configure_recognizes_mac_os_12.patch | |
# build_python 3.6 local_patches/fix_configure_recognizes_mac_os_12.patch | |
# these are installed via homebrew | |
# build_python 3.7 local_patches/fix_finding_readline.patch | |
# build_python 3.8 | |
# build_python 3.9 | |
build_python 3.10 | |
} | |
${1:-main} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment