certbot/tests/letstest/scripts/test_sdists.sh
Brad Warren c102ca66c3
Write a replacement for pipstrap (#8401)
* Add a new, simplified version of pipstrap.

* Use tools/pipstrap.py

* Uncomment code

* Refactor pip_install.py and provide hashes.

* Fix test_sdists.sh.

* Make code work on Python 2.

* Call strip_hashes.py using Python 3.

* Pin the oldest version of httplib2 used in distros

* Strip enum34 dependency.

* Remove pip pinnings from dev_constraints.txt

* Correct pipstrap docstring.

* Don't set working_dir twice.

* Add comments
2020-11-06 11:17:41 +01:00

55 lines
1.8 KiB
Bash
Executable file

#!/bin/sh -xe
cd letsencrypt
BOOTSTRAP_SCRIPT="tests/letstest/scripts/bootstrap_os_packages.sh"
VENV_PATH=venv3
# install OS packages
sudo $BOOTSTRAP_SCRIPT
if command -v python && [ $(python -V 2>&1 | cut -d" " -f 2 | cut -d. -f1,2 | sed 's/\.//') -eq 26 ]; then
# RHEL/CentOS 6 will need a special treatment, so we need to detect that environment
# Enable the SCL Python 3.6 installed by letsencrypt-auto bootstrap
PATH="/opt/rh/rh-python36/root/usr/bin:$PATH"
fi
# setup venv
# We strip the hashes because the venv creation script includes unhashed
# constraints in the commands given to pip and the mix of hashed and unhashed
# packages makes pip error out.
python3 tools/strip_hashes.py letsencrypt-auto-source/pieces/dependency-requirements.txt > requirements.txt
# We also strip out the requirement for enum34 because it cannot be installed
# in newer versions of Python 3, tools/strip_hashes.py removes the environment
# marker that'd normally prevent it from being installed, and this package is
# not needed for any OS tested here.
sed -i '/enum34/d' requirements.txt
CERTBOT_PIP_NO_BINARY=:all: tools/venv3.py --requirement requirements.txt
. "$VENV_PATH/bin/activate"
# pytest is needed to run tests on some of our packages so we install a pinned version here.
tools/pip_install.py pytest
PLUGINS="certbot-apache certbot-nginx"
TEMP_DIR=$(mktemp -d)
# build sdists
for pkg_dir in acme certbot $PLUGINS; do
cd $pkg_dir
python setup.py clean
rm -rf build dist
python setup.py sdist
mv dist/* $TEMP_DIR
cd -
done
VERSION=$(python letsencrypt-auto-source/version.py)
# test sdists
cd $TEMP_DIR
for pkg in acme certbot $PLUGINS; do
tar -xvf "$pkg-$VERSION.tar.gz"
cd "$pkg-$VERSION"
python setup.py build
python -m pytest
python setup.py install
cd -
done