Skip to content

Commit

Permalink
linux: Switch from pyinstaller root image to one built off manylinux
Browse files Browse the repository at this point in the history
Can't use the vanilla manylinux images because CPython isn't built as shared.
koordinates2/manylinux2014-pyshared images are a minor tweak.
See pypa/manylinux#1185 for details.

After that just install PyInstaller into the image before running.

Manylinux2014-derived libraries use libxcrypt to provide libcrypt.so.2, but that
doesn't seem to end up bundled. Do it manually. Probably goes away with a newer
PyInstaller.
  • Loading branch information
rcoup committed Sep 15, 2021
1 parent df4186a commit 806f179
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 10 deletions.
4 changes: 3 additions & 1 deletion kart.spec
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,6 @@ pyi_analysis = Analysis(
noarchive=False,
)

# Git
if is_win:
pyi_analysis.datas += Tree('vendor/dist/git', prefix='git')
# GDAL/osgeo hook doesn't include Proj
Expand All @@ -131,6 +130,9 @@ else:
libexec_root = 'vendor/dist/env/libexec'
pyi_analysis.datas += Tree('vendor/dist/env/share', prefix='share')

if is_linux:
pyi_analysis.binaries += [('libcrypt.so.2', '/usr/local/lib/libcrypt.so.2', 'BINARY')]

pyi_pyz = PYZ(pyi_analysis.pure, pyi_analysis.zipped_data, cipher=None)

if is_win:
Expand Down
5 changes: 2 additions & 3 deletions platforms/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,8 @@ pyapp-Linux: $(SRC)/vendor/dist/vendor-Linux.tar.gz
-v "$(SRC):/src" \
-w /src \
-v "$(abspath linux/.cache):/root/.cache" \
--entrypoint "/bin/bash" \
cdrx/pyinstaller-linux \
-i -c '/src/platforms/linux/pyinstaller.sh $(if $(MANYLINUX_DEBUG),|| bash)'
koordinates2/manylinux2014-pyshared:x86_64 \
bash -c '/src/platforms/linux/pyinstaller.sh $(if $(MANYLINUX_DEBUG),|| bash)'

$(pyapp-Darwin):
$(MAKE) pyapp-Darwin
Expand Down
19 changes: 13 additions & 6 deletions platforms/linux/pyinstaller.sh
Original file line number Diff line number Diff line change
@@ -1,18 +1,25 @@
#!/bin/bash
set -ex
set -e

source /root/.bashrc

PYENV_PREFIX=$(pyenv prefix)
set -xu

export PATH=/opt/python/cp37-cp37m-shared/bin:${PATH}

python3 --version
python3 -m venv /venv

export PATH=/venv/bin:${PATH}

{ echo ">> Configuring vendor dependencies..."; } 2> /dev/null
tar xvzf vendor/dist/vendor-Linux.tar.gz -C /tmp wheelhouse
rm -rf vendor/dist/env/
tar xzf vendor/dist/vendor-Linux.tar.gz -C vendor/dist/ env
tar xzf vendor/dist/vendor-Linux.tar.gz -C "$PYENV_PREFIX" --strip-components=1 env/lib/
tar xzf vendor/dist/vendor-Linux.tar.gz -C /venv --strip-components=1 env/lib/

# get the Rtree installer working successfully
export SPATIALINDEX_C_LIBRARY="$PYENV_PREFIX/lib/libspatialindex_c.so"
export SPATIALINDEX_C_LIBRARY="/venv/lib/libspatialindex_c.so"

pip install --no-deps --ignore-installed -r requirements.txt
pip install --no-deps \
Expand All @@ -21,10 +28,10 @@ pip install --no-deps \
{ echo ">> Downgrading PyInstaller (https://github.com/pyinstaller/pyinstaller/issues/4674) ..."; } 2> /dev/null
pip install "pyinstaller==3.5.*"

python setup.py install
python3 setup.py install

{ echo ">> Pre-bundle Smoke Test ..."; } 2> /dev/null
pyenv exec kart --version
kart --version

{ echo ">> Running PyInstaller ..."; } 2> /dev/null
pyinstaller \
Expand Down

0 comments on commit 806f179

Please sign in to comment.