Skip to content

Commit 997916a

Browse files
dumoladiroiban
andauthored
Forward-ported fixes from python-package + other updates. (#32)
* Use latest pythia version. * Forward-port python-package brink.{conf,sh} updates. * Use latest zlib. * Use latest libffi. * Try using latest available Python 3.8.x packages. * Fixed downloading latest libffi. * Use latest OpenSSL when building. * Back to tried and true Python 3.8.6. This reverts commit ceb021b. * Use our own CentOS 5.11 Docker image. * Also install unzip on CentOS 5. * Updated condition to match CentOS 5 container name. * Grand rename of the brink and build scripts. * Updated GitHub workflows for the grand rename. * Move stray pkgconfig files to their place. * Back to manually installing libffi for CentOS 5. * Added strong Bash checks for building. * Removed scripted OS package management. * Try to fix fallout from removing scripted OS pkg mgmt. * Build xz for Python's lzma module. * Download xz from SourceForge to have it work on CentOS 5. * Try building xz only on generic Linux. * Updated deps checks. * Try building xz on Alpine. * Package management fixes. * More xz build tweaks. * Install required headers on Alpine. * Try building xz on macOS differently. * Accomodate stricter bash checks in functions.sh. * Disabled building shared xz libs. * Changes after own review. * Updated sqlite. * Updated pip and most Python modules. * Try latest cryptography not requiring Rust. * Change after review. Co-authored-by: Adi Roiban <adiroiban@gmail.com> * More changes related to PyPI's index_url. * Even more changes related to PyPI's index_url. * Build xz probably needs to be built on all BSD-derived OS'es. * One last change related to PyPI's index_url. Co-authored-by: Adi Roiban <adiroiban@gmail.com>
1 parent 3b1a8ba commit 997916a

30 files changed

+271
-243
lines changed

.github/workflows/bare.yaml

+11-9
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ jobs:
5454
# Workflow won't be cancelled at the first failed job.
5555
fail-fast: false
5656
matrix:
57-
runs-on: [ windows-2019, windows-2016 ]
57+
runs-on: [ windows-2022, windows-2019 ]
5858
timeout-minutes: 20
5959

6060
# Steps represent a sequence of tasks that will be executed as part of the job
@@ -66,10 +66,10 @@ jobs:
6666

6767
# Explicitly run our scripts with Bash, not PowerShell (GitHub's default).
6868
- name: Build Pythia
69-
run: bash ./pythia build
69+
run: bash ./build.sh build
7070

7171
- name: Test Pythia
72-
run: bash ./pythia test
72+
run: bash ./build.sh test
7373

7474
# To use an RSA key with SFTPPlus, install upstream OpenSSH package,
7575
# which is more finicky in regards to file permissions.
@@ -127,14 +127,16 @@ jobs:
127127
with:
128128
fetch-depth: 2
129129

130-
- name: Install required packages
131-
run: sudo apt-get install libncurses5-dev
130+
- name: Prepare OS
131+
run: |
132+
sudo apt install libncurses5-dev
133+
sudo apt purge uuid-dev
132134
133135
- name: Build Pythia
134-
run: ./pythia build
136+
run: ./build.sh build
135137

136138
- name: Test Pythia
137-
run: ./pythia test
139+
run: ./build.sh test
138140

139141
- name: Upload testing package
140142
run: |
@@ -173,10 +175,10 @@ jobs:
173175
sudo chmod -v a-r /usr/local/opt/gettext/lib/libintl.*
174176
175177
- name: Build Pythia
176-
run: ./pythia build
178+
run: ./build.sh build
177179

178180
- name: Test Pythia
179-
run: ./pythia test
181+
run: ./build.sh test
180182

181183
- name: Upload testing package
182184
run: |

.github/workflows/docker.yaml

+14-19
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,9 @@ jobs:
3030
strategy:
3131
fail-fast: false
3232
matrix:
33-
container: [ 'alpine:3.14', 'centos:8.2.2004', 'centos:5.11' ]
33+
# CentOS 5.11 setup was saved as an image pushed to Docker Hub. See the
34+
# Overview section at https://hub.docker.com/r/proatria/centos for details.
35+
container: [ 'alpine:3.14', 'centos:8.2.2004', 'proatria/centos:5.11-chevah1' ]
3436
timeout-minutes: 30
3537
steps:
3638

@@ -39,7 +41,8 @@ jobs:
3941
if: startsWith(matrix.container, 'alpine')
4042
run: |
4143
apk upgrade -U
42-
apk add git curl bash openssh-client paxctl
44+
apk add git curl bash gcc make m4 automake libtool patch zlib-dev openssl-dev musl-dev linux-headers lddtree shadow sudo openssh-client paxctl file unzip
45+
apk del util-linux-dev
4346
4447
# Stick to CentOS 8.2 as OpenSSL got updated in 8.3 from 1.1.1c to 1.1.1g.
4548
- name: CentOS 8.2 setup
@@ -48,24 +51,16 @@ jobs:
4851
sed -i s/^mirrorlist=/#mirrorlist=/ /etc/yum.repos.d/*.repo
4952
sed -i s@^#baseurl=http://mirror.centos.org/\$contentdir/\$releasever/@baseurl=https://vault.centos.org/8.2.2004/@ /etc/yum.repos.d/*.repo
5053
yum -y upgrade
51-
yum -y install git curl openssh-clients
54+
yum -y install git curl gcc make m4 automake libtool patch libffi-devel zlib-devel xz-devel ncurses-devel openssl-devel openssh-clients unzip
55+
yum remove -y e2fsprogs-devel libuuid-devel
5256
53-
# Final CentOS 5 version is used to build the generic Linux package.
57+
# Our Chevah Centos 5 image, built for python-package.
58+
# FIXME: Update it to include unzip.
5459
- name: CentOS 5.11 setup
55-
if: matrix.container == 'centos:5.11'
60+
if: matrix.container == 'proatria/centos:5.11-chevah1'
5661
run: |
57-
sed -i s/^mirrorlist=/#mirrorlist=/ /etc/yum.repos.d/*.repo
58-
sed -i s@^#baseurl=http://mirror.centos.org/centos/\$releasever/@baseurl=http://vault.centos.org/5.11/@ /etc/yum.repos.d/*.repo
59-
yum -y upgrade
60-
# Use http://bin.chevah.com:20443/third-party-stuff/centos5/tuxad/
61-
# when tuxad.de dissapears, it has the minimum required stuff.
62-
rpm -i http://www.tuxad.de/rpms/tuxad-release-5-1.noarch.rpm
63-
yum -y install curl openssh-clients gcc44 make m4 patch unzip wget
64-
ln -s /usr/bin/gcc44 /usr/local/bin/gcc
65-
wget --mirror --no-parent https://bin.chevah.com:20443/third-party-stuff/centos5/endpoint/
66-
cd bin.chevah.com:20443/third-party-stuff/centos5/endpoint/
67-
rpm -i local-perl-*.rpm
68-
rpm -i --nodeps git{-core,}-2.5.0-1.ep.x86_64.rpm
62+
wget https://vault.centos.org/5.11/os/x86_64/CentOS/unzip-5.52-3.el5.x86_64.rpm
63+
rpm -i unzip-5.52-3.el5.x86_64.rpm
6964
7065
- name: Clone repo independently
7166
run: |
@@ -76,12 +71,12 @@ jobs:
7671
- name: Build Pythia
7772
run: |
7873
cd pythia
79-
./pythia build
74+
./build.sh build
8075
8176
- name: Test Pythia
8277
run: |
8378
cd pythia
84-
./pythia test
79+
./build.sh test
8580
8681
# Using `~/` is problematic under Docker, use `/root/`.
8782
# Remove key in same step to avoid leaving it on disk if publishing fails.

README.rst

+5-5
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,16 @@ A derivative of https://github.com/chevah/python-package/.
66

77
Building:
88

9-
* ``./pythia build``
9+
* ``./build.sh build``
1010

1111
Testing:
1212

13-
* ``./pythia test``
14-
* ``./pythia compat``
13+
* ``./build.sh test``
14+
* ``./build.sh compat``
1515

16-
Use ``./pythia help`` to discover all available commands.
16+
Use ``./build.sh help`` to discover all available commands.
1717

18-
Note that compat tests are currently only working with the ``python2.7`` branch.
18+
Note that compat tests are currently only working on the ``python2.7`` branch.
1919

2020

2121
Supported platforms

brink.conf

-13
This file was deleted.

build.conf

+57
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
# Configuration file for building Pythia.
2+
3+
# Sub-directories for building from sources and for the final distributable.
4+
BUILD_DIR="build"
5+
DIST_DIR="dist"
6+
7+
# Python and lib versions.
8+
PYTHON_BUILD_VERSION="3.8.6"
9+
LIBFFI_VERSION="3.4.2"
10+
ZLIB_VERSION="1.2.12"
11+
BZIP2_VERSION="1.0.8"
12+
XZ_VERSION="5.2.5"
13+
# Statically build the BSD libedit on selected platforms to get the
14+
# readline module available without linking to the GPL-only readline libs.
15+
LIBEDIT_VERSION="20170329-3.1"
16+
OPENSSL_VERSION="1.1.1n"
17+
# To match the unusual naming scheme for SQLite downloads, eliminate dots from
18+
# the regular SQLite version, then add 3 zeros. E.g. "3.33.0" -> "3330000".
19+
# When updating this, also update the year in src/sqlite/chevahbs, if needed.
20+
SQLITE_VERSION="3380300"
21+
# These are used by get-pip.py.
22+
PIP_VERSION="22.0.4"
23+
SETUPTOOLS_VERSION="62.1.0"
24+
25+
# Python modules versions to be used everywhere possible.
26+
CFFI_VERSION="1.15.0"
27+
CRYPTOGRAPHY_VERSION="3.4.8"
28+
SUBPROCESS32_VERSION="3.5.4"
29+
BCRYPT_VERSION="3.2.2"
30+
PSUTIL_VERSION="5.9.0"
31+
SETPROCTITLE_VERSION="1.2.3"
32+
33+
# pycparser is explicitly installed to work around setuptools auto dependencies.
34+
PYCPARSER_VERSION="2.21"
35+
36+
# Global flags for building required libs.
37+
BUILD_LIBFFI="no"
38+
BUILD_ZLIB="no"
39+
BUILD_BZIP2="yes"
40+
BUILD_XZ="no"
41+
BUILD_LIBEDIT="yes"
42+
BUILD_OPENSSL="no"
43+
BUILD_SQLITE="yes"
44+
45+
# List of default Python modules installed using pip.
46+
PIP_LIBRARIES="\
47+
cffi==${CFFI_VERSION} \
48+
cryptography==${CRYPTOGRAPHY_VERSION} \
49+
subprocess32==${SUBPROCESS32_VERSION} \
50+
bcrypt==${BCRYPT_VERSION} \
51+
psutil==${PSUTIL_VERSION} \
52+
setproctitle==${SETPROCTITLE_VERSION}
53+
"
54+
PIP_ARGS="\
55+
--index-url=${PIP_INDEX_URL} \
56+
--no-warn-script-location \
57+
"

pythia build.sh

+24-15
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,20 @@
22
#
33
# Pythia's script for building Python.
44

5-
# Set versions for the software to be built and other defaults.
5+
# Script initialization.
6+
set -o nounset
7+
set -o errexit
8+
set -o pipefail
9+
10+
# Get PIP_INDEX_URL for PIP_ARGS in build.conf.
611
source pythia.conf
712

13+
# Set versions for the software to be built and other defaults.
14+
source build.conf
15+
816
# Import shared and specific code.
917
source ./functions.sh
10-
source ./functions_pythia.sh
18+
source ./functions_build.sh
1119

1220
# Git revision to inject into Python's sys.version string through chevahbs
1321
# on non-Windows platforms. Also used for compat tests and archived in the dist.
@@ -16,18 +24,18 @@ exit_on_error $? 250
1624

1725
# Export the variables needed by the chevahbs scripts and the test phase.
1826
export PYTHON_BUILD_VERSION PYTHIA_VERSION
19-
export BUILD_ZLIB BUILD_BZIP2 BUILD_LIBEDIT BUILD_LIBFFI BUILD_OPENSSL
27+
export BUILD_ZLIB BUILD_BZIP2 BUILD_XZ BUILD_LIBEDIT BUILD_LIBFFI BUILD_OPENSSL
2028

2129

2230
# OS detection is slow on Windows, only execute it when the file is missing.
2331
if [ ! -r ./BUILD_ENV_VARS ]; then
24-
execute ./brink.sh detect_os
32+
execute ./pythia.sh detect_os
2533
fi
26-
# Import build env vars as set by brink.sh.
34+
# Import build env vars as set by pythia.sh.
2735
source ./BUILD_ENV_VARS
2836

2937
# On Unix, use $ARCH to choose between 32bit or 64bit packages. It's possible
30-
# to force a 32bit build on a 64bit machine, e.g. by setting ARCH in brink.sh
38+
# to force a 32bit build on a 64bit machine, e.g. by setting ARCH in pythia.sh
3139
# as "x86" instead of "x64" for a certain platform.
3240
# $ARCH is also used when "building" Python on Windows and for testing.
3341
# $OS is used when patching/configuring/building/testing.
@@ -45,7 +53,7 @@ export CC="gcc"
4553
export MAKE="make"
4654
# $GET_CMD must save to custom filename, which must be appended before the link.
4755
# E.g., to use wget, GET_CMD should be "wget --quiet -O".
48-
export GET_CMD="curl --silent --output"
56+
export GET_CMD="curl --silent --location --output"
4957
export SHA_CMD="sha512sum --check --status --warn"
5058
export TAR_CMD="tar xfz"
5159
export ZIP_CMD="unzip -q"
@@ -87,12 +95,13 @@ command_build() {
8795
# following locations, making sure they are picked up when building Python.
8896
# $CFLAGS/$CPPFLAGS is another way to ensure this, but it's not as portable.
8997
execute mkdir -p "$INSTALL_DIR"/{include,lib}
90-
export LDFLAGS="-L${INSTALL_DIR}/lib/ ${LDFLAGS}"
91-
export PKG_CONFIG_PATH="${INSTALL_DIR}/lib/pkgconfig/:${PKG_CONFIG_PATH}"
98+
export LDFLAGS="-L${INSTALL_DIR}/lib/ ${LDFLAGS:-}"
99+
export PKG_CONFIG_PATH="${INSTALL_DIR}/lib/pkgconfig/:${PKG_CONFIG_PATH:-}"
92100

93101
build_dep $BUILD_LIBFFI libffi $LIBFFI_VERSION
94102
build_dep $BUILD_ZLIB zlib $ZLIB_VERSION
95103
build_dep $BUILD_BZIP2 bzip2 $BZIP2_VERSION
104+
build_dep $BUILD_XZ xz $XZ_VERSION
96105
build_dep $BUILD_LIBEDIT libedit $LIBEDIT_VERSION
97106
build_dep $BUILD_SQLITE sqlite-autoconf $SQLITE_VERSION
98107
build_dep $BUILD_OPENSSL openssl $OPENSSL_VERSION
@@ -130,7 +139,7 @@ build_dep() {
130139
export LDFLAGS="-Wl,-rpath,${INSTALL_DIR}/lib/ ${LDFLAGS}"
131140
fi
132141
# Still needed for building cryptography.
133-
export CPPFLAGS="$CPPFLAGS -I${INSTALL_DIR}/include"
142+
export CPPFLAGS="${CPPFLAGS:-} -I${INSTALL_DIR}/include"
134143
fi
135144
elif [ $dep_boolean = "no" ]; then
136145
(>&2 echo " Skip building $dep_name")
@@ -243,17 +252,17 @@ command_compat() {
243252
execute rm -rf compat/
244253
execute git clone https://github.com/chevah/compat.git --depth=1 -b master
245254
execute pushd compat
246-
# Copy over current brink stuff, as some changes might require it.
247-
execute cp ../../brink.{conf,sh} ./
255+
# Copy over current pythia stuff, as some changes might require it.
256+
execute cp ../../pythia.{conf,sh} ./
248257
# Patch compat to use the newly-built Python, then copy it to cache/.
249-
echo -e "\nPYTHON_CONFIGURATION=default@${new_python_conf}" >> brink.conf
258+
echo -e "\nPYTHON_CONFIGURATION=default@${new_python_conf}" >> pythia.conf
250259
execute mkdir cache
251260
execute cp -r ../"$PYTHON_BUILD_DIR" cache/
252261
# Make sure everything is done from scratch in the current dir.
253262
unset CHEVAH_CACHE CHEVAH_BUILD
254263
# Some tests might still fail due to causes not related to the new Python.
255-
execute ./brink.sh deps
256-
execute ./brink.sh test_ci
264+
execute ./pythia.sh deps
265+
execute ./pythia.sh test_ci
257266

258267
execute popd
259268
echo "::endgroup::"

functions.sh

+8-6
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,15 @@
44
#
55

66
# Check if debugging environment variable is set and initialize with 0 if not.
7-
if [ -z "$DEBUG" ] ; then
8-
DEBUG=0
9-
fi
7+
DEBUG=${DEBUG-0}
108

119
help_text_help=\
1210
"Show help for a command."
1311
command_help() {
14-
local command=$1
12+
local command=${1:-}
1513
local help_command="help_$command"
1614
# Test for a valid help method, otherwise call general help.
15+
set +o errexit
1716
type $help_command &> /dev/null
1817
if [ $? -eq 0 ]; then
1918
$help_command
@@ -25,6 +24,7 @@ command_help() {
2524
echo -e " $command_name\t${!help_text}"
2625
done
2726
fi
27+
set -o errexit
2828
}
2929

3030
#
@@ -33,16 +33,17 @@ command_help() {
3333
# Select fuctions which are made public.
3434
#
3535
select_command() {
36-
local command=$1
37-
shift
36+
local command=${1:-}
3837
case $command in
3938
"")
4039
command_help
4140
exit 99
4241
;;
4342
*)
43+
shift
4444
# Test for a valid command, otherwise call general help.
4545
call_command="command_$command"
46+
set +o errexit
4647
type $call_command &> /dev/null
4748
if [ $? -eq 0 ]; then
4849
$call_command $@
@@ -52,6 +53,7 @@ select_command() {
5253
(>&2 echo "Unknown command: ${command}.")
5354
exit 98
5455
fi
56+
set -o errexit
5557
;;
5658
esac
5759
}

0 commit comments

Comments
 (0)