Skip to content

Commit bb41ace

Browse files
authored
Python 3.12 update. (#58)
* Zlib 1.3.1 update. * Pip 24.0 update. * Debug outdated macOS Homebrew hacks. * No more Homebrew hacking on GitHub's macOS setups. * Make it possible to ignore preset Safety IDs. * Make it possible to ignore preset Safety IDs, take two. * Unified debugging for testing on GitHub's bare OS'es. * Update macOS setup for latest GitHub labels. * Shellcheck fixes. * Shellcheck fixes and more. * Put back Homebrew hacks for x86 macOS. * Do not install binary wheels. * Do not install binary wheels, take two. * Also ignore the jinja2 disputed safety issue. * Properly generate SAFETY_IGNORDE_OPTS for multiple Safety IDs to ignore. * Properly generate SAFETY_IGNORDE_OPTS for multiple Safety IDs to ignore, take two. * Try debugging safety opts. * Process Safety IDs the Bash way. * Make it possible to skip tests during build. * Switched to latest OpenSSL 3.0.x on non-Windows platforms. * More updated libs. * Latest versions for remaining Python modules. * Try building Python 3.13.0b2. * Try building Python 3.13.0b2, take two. * Python 3.13 deprecates `crypt` and `spwd`. * Try building Python 3.13.0b2, take three. * Get more Homebrew stuff out of the way. * Try building Python 3.13.0b2, take four. * Get more Homebrew stuff out of the way, take two. * Python builds with OS-provided libedit on macOS lately. * Python builds with OS-provided libedit on macOS lately, take two. * Python builds with OS-provided libedit on macOS lately, take three. * Python builds with OS-provided libedit on macOS lately, take four. * Python 3.13.0b3 update. * Python 3.13.0b3 update, take two. * Removed debugging spillover from package checks. * Removed safety, added requirements.txt. * Removed safety, added requirements.txt, take two. * Get generic Linux deps back to normal. * Get generic Linux deps back to normal, take two. * Install gdb on Amazon Linux 2 for improved Python tests. * Python 3.13.0b4 update. * Python modules update. * Amazon 2 has a gdb unusable for Python tests (built with Python 2). * Automatically regenerate requirements.txt when done building. * Include pip version in requirements.txt. * Fixed Windows package filename. * Try actions/checkout@v4. * Remove download cache instead of just purging. * Synced pythia.sh with server repo version. * Synced pythia.sh from server repo. * Allow building Python release candidate versions. * Also updated pythia.conf from server repo. * Fixed sha512.sum file for embedded Windows package. * Fixed sha512.sum file for embedded Windows package, take two * Try latest 3.12 Python release. * Shellcheck-related fixes. * Fixed Amazon Linux 2 build. * Try building musl package on Alpine 3.15. * Updated OpenSSL to version 3.0.15 on non-Windows platforms. * Updated pip and setuptools to latest versions. * Try latest 3.12 Python release, take two. * Updated OpenSSL version check. * Try auto-updating requirements.txt through the Windows build. * Try auto-updating requirements.txt through the Windows build, take 2. * Try auto-updating requirements.txt through the Windows build, take 3. * Try auto-updating requirements.txt through the Windows build, take 4. * Automated update of requirements.txt from Windows build. * Changes after a quick own review. * Do not copy xz binaries in dist packages. * Compress saved Makefiles. * Compress saved Makefiles, take 2. * Put back tests for crypt and spwd for now. * Also uninstall setuptools before packing the dist. * Automated update of requirements.txt from Windows build. * Use same setuptools version as server repo. * The unzip ersatz in Alpine Linux busybox is good enough. * Try gcc10 for building on Amazon Linux 2 through GHA. * Try gcc10 for building on Amazon Linux 2 through GHA, take 2. * Back to default gcc for building on Amazon Linux 2 through GHA. * Leave setuptools as-is. * Automated update of requirements.txt from Windows build. * Updated Python to version 3.12.7. * One more hack for not building a default Python module. * One more hack for not building a default Python module, take two. * Added a comment for psutil. * Changes after own review. --------- Co-authored-by: dumol <dumol@users.noreply.github.com>
1 parent ba80a30 commit bb41ace

18 files changed

+323
-282
lines changed

.github/workflows/bare.yaml

+20-4
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,14 @@ jobs:
2020
runs-on: windows-latest
2121
timeout-minutes: 45
2222

23+
permissions:
24+
# Give the default GITHUB_TOKEN write permission to commit requirements.txt
25+
contents: write
26+
2327
# Steps represent a sequence of tasks that will be executed as part of the job
2428
steps:
2529
# Checks-out the repository under $GITHUB_WORKSPACE, so the job can access it
26-
- uses: actions/checkout@v2
30+
- uses: actions/checkout@v4
2731
with:
2832
fetch-depth: 2
2933

@@ -36,6 +40,12 @@ jobs:
3640
timeout-minutes: 5
3741
run: bash ./build.sh test
3842

43+
# Commit changed requirements.txt back to the repository
44+
- uses: chevah/git-auto-commit-action@HEAD
45+
with:
46+
commit_message: Automated update of requirements.txt from Windows build.
47+
file_pattern: 'requirements.txt'
48+
3949
# To use an RSA key with SFTPPlus, install upstream OpenSSH package,
4050
# which is more finicky in regards to file permissions.
4151
# Beware the commands in this step run under PowerShell.
@@ -84,7 +94,7 @@ jobs:
8494
runs-on: macos-13
8595
timeout-minutes: 90
8696
steps:
87-
- uses: actions/checkout@v2
97+
- uses: actions/checkout@v4
8898
with:
8999
fetch-depth: 2
90100

@@ -94,7 +104,10 @@ jobs:
94104
run: |
95105
sudo mv -v /usr/local/bin/git{,.saved}
96106
sudo chmod -v a-r /usr/local/include/libintl.h
107+
sudo chmod -v a-r /usr/local/include/gdbm.h
97108
sudo chmod -v a-r /usr/local/opt/gettext/lib/libintl.*
109+
sudo chmod -v a-r /usr/local/opt/gdbm/lib/libgdbm*
110+
sudo chmod -v a-r /usr/local/opt/mpdecimal/lib/libmpdec*
98111
99112
- name: Build Pythia
100113
timeout-minutes: 30
@@ -103,8 +116,11 @@ jobs:
103116
# Fix back Homebrew, for working Shellcheck tests and tmate debugging.
104117
- name: Unhack Homebrew
105118
run: |
106-
sudo chmod -v a+r /usr/local/opt/gettext/lib/libintl*
107119
sudo chmod -v a+r /usr/local/include/libintl.h
120+
sudo chmod -v a-r /usr/local/include/gdbm.h
121+
sudo chmod -v a+r /usr/local/opt/gettext/lib/libintl*
122+
sudo chmod -v a+r /usr/local/opt/gdbm/lib/libgdbm*
123+
sudo chmod -v a+r /usr/local/opt/mpdecimal/lib/libmpdec*
108124
sudo mv -v /usr/local/bin/git{.saved,}
109125
110126
- name: Test Pythia
@@ -133,7 +149,7 @@ jobs:
133149
runs-on: macos-latest
134150
timeout-minutes: 60
135151
steps:
136-
- uses: actions/checkout@v2
152+
- uses: actions/checkout@v4
137153
with:
138154
fetch-depth: 2
139155

.github/workflows/docker.yaml

+9-3
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ jobs:
2525
strategy:
2626
fail-fast: false
2727
matrix:
28-
# Alpine 3.12 has musl 1.1.24, Amazon 2 has glibc 2.26.
29-
container: [ 'alpine:3.12', 'amazonlinux:2' ]
28+
# Alpine Linux 3.15 has musl 1.2.2, Amazon Linux 2 has glibc 2.26.
29+
container: [ 'alpine:3.15', 'amazonlinux:2' ]
3030
timeout-minutes: 60
3131
steps:
3232

@@ -44,7 +44,13 @@ jobs:
4444
if: startsWith(matrix.container, 'amazonlinux')
4545
run: |
4646
yum -y upgrade
47-
yum -y install git-core gcc make m4 patch tar unzip perl perl-Test-Simple perl-IPC-Cmd xz gcc-c++ dejagnu
47+
yum -y install git-core gcc make m4 patch tar unzip perl perl-Test-Simple perl-IPC-Cmd xz gcc-c++ dejagnu bzip2
48+
# To avoid linking against libdb and gdmb libraries on Amazon Linux 2.
49+
# Can't simply uninstall libdb-devel and gdmb-devel, they are required by perl-IPC-Cmd.
50+
rm -v /usr/include/libdb/db.h
51+
rm -v /usr/include/gdbm.h
52+
# This is for avoiding building the NIS module with Python 3.12.
53+
rm -v /usr/include/rpc/rpc.h
4854
4955
- name: Ubuntu setup
5056
if: startsWith(matrix.container, 'ubuntu')

.gitignore

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,5 @@
44
/src/*/*.tar.gz
55
/src/*/*.tgz
66
/src/*/*.zip
7-
/build-pythia/
7+
/build-py3/
88
/cache/

build.conf

+13-16
Original file line numberDiff line numberDiff line change
@@ -9,22 +9,24 @@ DIST_DIR="dist"
99
# Setting this as 0 disables tests during building (skips chevahbs_test phase).
1010
PYTHIA_BUILD_TESTS="${PYTHIA_BUILD_TESTS:-1}"
1111

12-
# Python and lib versions.
13-
PYTHON_BUILD_VERSION="3.11.9"
12+
# Set versions for Python and its libraries.
13+
# For major Python updates, e.g. 3.11->3.12, also update pythia.conf and
14+
# src/Python-Windows/chevahbs (e.g. "python311._pth"->"python312._pth").
15+
PYTHON_BUILD_VERSION="3.12.7"
1416
LIBFFI_VERSION="3.4.6"
1517
ZLIB_VERSION="1.3.1"
1618
BZIP2_VERSION="1.0.8"
1719
# To check the signature of the XZ download:
1820
# "gpg --keyserver-options auto-key-retrieve --verify xz-*.sig xz-*.gz".
1921
XZ_VERSION="5.6.2"
2022
# Statically build the BSD libedit on selected platforms to get the
21-
# readline module available without linking to the GPL-only readline libs.
23+
# readline module available without linking to the GPL-only readline libraries.
2224
# If there's a need to reenable this, our libedit patch for Python 3.9 was
2325
# https://github.com/chevah/pythia/pull/5/commits/09c128154d23feb6b1a7cb5a8d79.
2426
# A newer patch is available at https://github.com/python/cpython/issues/57710.
2527
LIBEDIT_VERSION="20170329-3.1"
26-
# Our OpenSSL libs are only used for Python's "ssl" module lately.
27-
OPENSSL_VERSION="3.0.14"
28+
# Our OpenSSL libraries are only used for Python's "ssl" module lately.
29+
OPENSSL_VERSION="3.0.15"
2830
# Use the version of the "sqlite-autoconf-VERSION.tar.gz" upstream download.
2931
# To get its SHA3-256 signature: "openssl dgst -sha3-256 sqlite-autoconf-*".
3032
# When updating this, also update the year in src/sqlite/chevahbs, if needed.
@@ -36,19 +38,18 @@ SQLITE_VERSION="3460000"
3638
BOOTSTRAP_GET_PIP="https://bootstrap.pypa.io/get-pip.py"
3739

3840
# Python modules installed after bootstraping pip.
39-
PIP_VERSION="24.0"
40-
SETUPTOOLS_VERSION="70.0.0"
41+
PIP_VERSION="24.2"
42+
SETUPTOOLS_VERSION="70.3.0"
4143
# pycparser is explicitly installed to work around setuptools auto dependencies.
4244
PYCPARSER_VERSION="2.22"
4345

4446
# Python modules that have to be built and/or installed in Pythia.
45-
PSUTIL_VERSION="5.9.8"
4647
PYWIN32_VERSION="306"
48+
# To be removed when upstream builds a musl wheel for psutil.
49+
# More at https://github.com/giampaolo/psutil/pull/2126.
50+
PSUTIL_VERSION="6.0.0"
4751

48-
# Pin safety to keep the deps of the test environment under control.
49-
SAFETY_VERSION="3.2.0"
50-
51-
# Global flags for building required libs.
52+
# Global flags for building required libraries.
5253
BUILD_LIBFFI="no"
5354
BUILD_ZLIB="no"
5455
BUILD_BZIP2="yes"
@@ -72,7 +73,3 @@ PIP_ARGS=(\
7273
--index-url="$PIP_INDEX_URL" \
7374
--no-warn-script-location \
7475
)
75-
# Array of safety IDs to ignore.
76-
# 67599: pip 24.0, https://data.safetycli.com/v/67599/f17/ (disputed).
77-
# 70612: jinja2 3.1.4, https://data.safetycli.com/v/70612/97c (disputed).
78-
SAFETY_IGNORED_IDS=(67599 70612)

build.sh

+7-18
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ set -o nounset # always check if variables exist
88
set -o errexit # always exit on error
99
set -o errtrace # trap errors in functions as well
1010
set -o pipefail # don't ignore exit codes when piping output
11+
set -o functrace # inherit DEBUG and RETURN traps
1112

1213
# Default PyPI server to use. Can be overwritten in build.conf.
1314
PIP_INDEX_URL="https://pypi.org/simple"
@@ -210,9 +211,12 @@ command_install_python_modules() {
210211
execute "$PYTHON_BIN" -m pip install "${PIP_ARGS[@]}" "$library"
211212
done
212213

213-
# When done, uninstall wheel.
214+
echo "# Uninstalling wheel... #"
214215
execute "$PYTHON_BIN" -m pip uninstall --yes wheel
215216

217+
echo "# Regenerating requirements.txt file... #"
218+
execute "$PYTHON_BIN" -m pip freeze --all > requirements.txt
219+
216220
echo "::endgroup::"
217221
}
218222

@@ -222,8 +226,6 @@ help_text_test="Run own tests for the newly-build Python distribution."
222226
command_test() {
223227
local test_file="test_python_binary_dist.py"
224228
local python_binary="$PYTHON_BIN"
225-
local safety_id_to_ignore
226-
declare -a safety_ignore_opts
227229

228230
echo "::group::Chevah tests"
229231
if [ ! -d "$BUILD_DIR" ]; then
@@ -240,25 +242,12 @@ command_test() {
240242
execute cp src/chevah-python-tests/get_binaries_deps.sh "$BUILD_DIR"
241243
execute pushd "$BUILD_DIR"
242244
execute "$python_binary" "$test_file"
245+
execute popd
243246
echo "::endgroup::"
244247

245248
echo "::group::Security tests"
246-
echo "## Testing for outdated packages and security issues... ##"
249+
echo "## Testing for outdated packages... ##"
247250
execute "$python_binary" -m pip list --outdated --format=columns
248-
execute "$python_binary" -m pip install "${PIP_ARGS[@]}" \
249-
safety=="$SAFETY_VERSION"
250-
251-
if (( ${#SAFETY_IGNORED_IDS[@]} != 0 )); then
252-
(>&2 echo "Following Safety DB IDs are excepted from checks:")
253-
(>&2 echo -e "\t${SAFETY_IGNORED_IDS[*]}")
254-
for safety_id_to_ignore in "${SAFETY_IGNORED_IDS[@]}"; do
255-
safety_ignore_opts+=("-i $safety_id_to_ignore")
256-
done
257-
fi
258-
259-
execute "$python_binary" -m safety check --full-report \
260-
"${safety_ignore_opts[@]}"
261-
execute popd
262251
echo "::endgroup::"
263252

264253
echo "::group::Shell tests"

functions_build.sh

+3-1
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ build() {
170170
# Put stuff where it's expected and remove some of the cruft.
171171
#
172172
cleanup_install_dir() {
173-
local python_lib_file="lib$PYTHON_VERSION.a"
173+
local python_lib_file="lib${PYTHON_VERSION}.a"
174174

175175
echo "::group::Clean up Python install dir"
176176
execute pushd "$BUILD_DIR/$PYTHON_BUILD_DIR"
@@ -243,6 +243,8 @@ cleanup_install_dir() {
243243
execute mv pkgconfig/* lib/pkgconfig/
244244
execute rmdir pkgconfig
245245
fi
246+
# Compress packaged Makefiles to save some space when unpacked.
247+
execute bzip2 lib/config/Makefile*
246248
;;
247249
esac
248250
# Test that only bin/ and lib/ sub-dirs are left.

os_quirks.sh

+5-3
Original file line numberDiff line numberDiff line change
@@ -101,9 +101,11 @@ case "$OS" in
101101
esac
102102

103103
# Use PIC (Position Independent Code) with GCC on 64-bit arches (currently all).
104-
if [ "$CC" = "gcc" ]; then
105-
export CFLAGS="${CFLAGS:-} -fPIC"
106-
fi
104+
case "$CC" in
105+
gcc*)
106+
export CFLAGS="${CFLAGS:-} -fPIC"
107+
;;
108+
esac
107109

108110
# Get number of useful CPUs, to enable parallel builds where applicable.
109111
case "$OS" in

pkg_checks.sh

+8-8
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,15 @@
1515
# On platforms with multiple C compilers, choose by setting CC in os_quirks.sh.
1616

1717
# List of OS packages required for building Python/pyOpenSSL/cryptography etc.
18-
BASE_PKGS="gcc make m4 patch unzip perl"
18+
BASE_PKGS="gcc make m4 patch perl"
1919
if [ "$BUILD_LIBEDIT" = "yes" ]; then
2020
BASE_PKGS="$BASE_PKGS automake libtool"
2121
fi
22-
APK_PKGS="$BASE_PKGS git curl bash musl-dev linux-headers lddtree shadow \
23-
openssh-client file unzip g++ musl-locales dejagnu"
24-
DEB_PKGS="$BASE_PKGS tar diffutils git curl \
22+
APK_PKGS="$BASE_PKGS git curl bash musl-dev linux-headers lddtree \
23+
openssh-client file g++ musl-locales dejagnu"
24+
DEB_PKGS="$BASE_PKGS unzip tar diffutils git curl \
2525
openssh-client libtest-simple-perl xz-utils g++ dejagnu"
26-
RPM_PKGS="$BASE_PKGS tar diffutils git-core curl \
26+
RPM_PKGS="$BASE_PKGS bzip2 unzip tar diffutils git-core curl \
2727
openssh-clients perl-Test-Simple perl-IPC-Cmd xz gcc-c++ dejagnu"
2828

2929
# Check for OS packages required for the build.
@@ -33,7 +33,7 @@ PACKAGES="$CC make m4 git patch curl sha512sum tar unzip"
3333
# This is defined as an array of commands and opts, to allow it to be quoted.
3434
CHECK_CMD=(command -v)
3535

36-
# $CHECK_CMD should exit with 0 only when checked packages is installed.
36+
# $CHECK_CMD should exit with 0 only when checked package is installed.
3737
case "$OS" in
3838
windows)
3939
# Nothing to actually build on Windows.
@@ -54,7 +54,7 @@ case "$OS" in
5454
;;
5555
linux*)
5656
if [ -x /sbin/apk ]; then
57-
# Assumes Alpine Linux 3.12.
57+
# Assumes Alpine Linux 3.15.
5858
CHECK_CMD=(apk info -q -e)
5959
PACKAGES="$APK_PKGS"
6060
elif [ -x /usr/bin/dpkg ]; then
@@ -74,7 +74,7 @@ esac
7474
# External checks with various exit codes are checked below.
7575
set +o errexit
7676

77-
# If $CHECK_CMD is still (command -v), it's only a check for needed commands.
77+
# If $CHECK_CMD is still "(command -v)", it's only a check for needed commands.
7878
if [ -n "$PACKAGES" ]; then
7979
for package in $PACKAGES ; do
8080
echo "Checking if $package is available..."

pythia.conf

+9-6
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
1-
PYTHON_CONFIGURATION="default@3.11.3.f9d9434"
1+
# When building a new major Python version, e.g. 3.11->3.12,
2+
# update this in advance (e.g. use "default@3.12.0.deadbeef"),
3+
# and remove BUILD_ENV_* files (e.g. with `./build.sh clean -a`).
4+
PYTHON_CONFIGURATION="default@3.12.7.ac6595f"
25
# This is defined as a Bash array of options to be passed to commands.
3-
BASE_REQUIREMENTS=("chevah-brink==1.0.13" "paver==1.3.4")
6+
BASE_REQUIREMENTS=("chevah-brink==1.0.15" "paver==1.3.4")
7+
# Use our private PyPi server instead of the default one set in pythia.sh.
8+
PIP_INDEX_URL="https://bin.chevah.com:20443/pypi/simple"
49
# Use our production server instead of the GitHub releases set by default.
510
BINARY_DIST_URI="https://bin.chevah.com:20443/production"
611
# For testing packages, make sure this one is the last uncommented instance:
7-
#BINARY_DIST_URI="https://bin.chevah.com:20443/testing"
8-
# Also overwrite the default pypi.org site set by default in pythia.sh.
9-
PIP_INDEX_URL="https://bin.chevah.com:20443/pypi/simple"
10-
# This is used by the Python runtime.
12+
BINARY_DIST_URI="https://bin.chevah.com:20443/testing"
13+
# This directory is used by the Python runtime.
1114
CHEVAH_BUILD_DIR="build-py3"

0 commit comments

Comments
 (0)