Skip to content

Commit

Permalink
Merge pull request #1519 from mayeut/minimal-tests
Browse files Browse the repository at this point in the history
Multiple small improvements
  • Loading branch information
mayeut authored Aug 15, 2023
2 parents d68f0ef + 7898f8a commit 4434c7d
Show file tree
Hide file tree
Showing 13 changed files with 77 additions and 8 deletions.
2 changes: 1 addition & 1 deletion docker/build_scripts/python-tag-abi-tag.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# See PEP 425 for exactly what these are, but an example would be:
# cp27-cp27mu

from wheel.vendored.packaging.tags import sys_tags
from packaging.tags import sys_tags


# first tag is always the more specific tag
Expand Down
4 changes: 3 additions & 1 deletion docker/build_scripts/requirements3.10.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ build==0.10.0 \
packaging==23.1 \
--hash=sha256:994793af429502c4ea2ebf6bf664629d07c1a9fe974af92966e4b8d2df7edc61 \
--hash=sha256:a392980d2b6cffa644431898be54b0045151319d1e7ec34f0cfed48767dd334f
# via build
# via
# -r requirements.in
# build
pyproject-hooks==1.0.0 \
--hash=sha256:283c11acd6b928d2f6a7c73fa0d01cb2bdc5f07c57a2eeb6e83d5e56b97976f8 \
--hash=sha256:f271b298b97f5955d53fb12b72c1fb1948c22c1a6b70b315c54cedaca0264ef5
Expand Down
4 changes: 3 additions & 1 deletion docker/build_scripts/requirements3.11.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ build==0.10.0 \
packaging==23.1 \
--hash=sha256:994793af429502c4ea2ebf6bf664629d07c1a9fe974af92966e4b8d2df7edc61 \
--hash=sha256:a392980d2b6cffa644431898be54b0045151319d1e7ec34f0cfed48767dd334f
# via build
# via
# -r requirements.in
# build
pyproject-hooks==1.0.0 \
--hash=sha256:283c11acd6b928d2f6a7c73fa0d01cb2bdc5f07c57a2eeb6e83d5e56b97976f8 \
--hash=sha256:f271b298b97f5955d53fb12b72c1fb1948c22c1a6b70b315c54cedaca0264ef5
Expand Down
4 changes: 3 additions & 1 deletion docker/build_scripts/requirements3.12.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ build==0.10.0 \
packaging==23.1 \
--hash=sha256:994793af429502c4ea2ebf6bf664629d07c1a9fe974af92966e4b8d2df7edc61 \
--hash=sha256:a392980d2b6cffa644431898be54b0045151319d1e7ec34f0cfed48767dd334f
# via build
# via
# -r requirements.in
# build
pyproject-hooks==1.0.0 \
--hash=sha256:283c11acd6b928d2f6a7c73fa0d01cb2bdc5f07c57a2eeb6e83d5e56b97976f8 \
--hash=sha256:f271b298b97f5955d53fb12b72c1fb1948c22c1a6b70b315c54cedaca0264ef5
Expand Down
4 changes: 3 additions & 1 deletion docker/build_scripts/requirements3.6.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ importlib-metadata==4.8.3 \
packaging==21.3 \
--hash=sha256:dd47c42927d89ab911e606518907cc2d3a1f38bbd026385970643f9c5b8ecfeb \
--hash=sha256:ef103e05f519cdc783ae24ea4e2e0f508a9c99b2d4969652eed6a2e1ea5bd522
# via build
# via
# -r requirements.in
# build
pep517==0.13.0 \
--hash=sha256:4ba4446d80aed5b5eac6509ade100bff3e7943a8489de249654a5ae9b33ee35b \
--hash=sha256:ae69927c5c172be1add9203726d4b84cf3ebad1edcd5f71fcdc746e66e829f59
Expand Down
4 changes: 3 additions & 1 deletion docker/build_scripts/requirements3.7.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@ importlib-metadata==6.7.0 \
packaging==23.1 \
--hash=sha256:994793af429502c4ea2ebf6bf664629d07c1a9fe974af92966e4b8d2df7edc61 \
--hash=sha256:a392980d2b6cffa644431898be54b0045151319d1e7ec34f0cfed48767dd334f
# via build
# via
# -r requirements.in
# build
pyproject-hooks==1.0.0 \
--hash=sha256:283c11acd6b928d2f6a7c73fa0d01cb2bdc5f07c57a2eeb6e83d5e56b97976f8 \
--hash=sha256:f271b298b97f5955d53fb12b72c1fb1948c22c1a6b70b315c54cedaca0264ef5
Expand Down
4 changes: 3 additions & 1 deletion docker/build_scripts/requirements3.8.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ build==0.10.0 \
packaging==23.1 \
--hash=sha256:994793af429502c4ea2ebf6bf664629d07c1a9fe974af92966e4b8d2df7edc61 \
--hash=sha256:a392980d2b6cffa644431898be54b0045151319d1e7ec34f0cfed48767dd334f
# via build
# via
# -r requirements.in
# build
pyproject-hooks==1.0.0 \
--hash=sha256:283c11acd6b928d2f6a7c73fa0d01cb2bdc5f07c57a2eeb6e83d5e56b97976f8 \
--hash=sha256:f271b298b97f5955d53fb12b72c1fb1948c22c1a6b70b315c54cedaca0264ef5
Expand Down
4 changes: 3 additions & 1 deletion docker/build_scripts/requirements3.9.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ build==0.10.0 \
packaging==23.1 \
--hash=sha256:994793af429502c4ea2ebf6bf664629d07c1a9fe974af92966e4b8d2df7edc61 \
--hash=sha256:a392980d2b6cffa644431898be54b0045151319d1e7ec34f0cfed48767dd334f
# via build
# via
# -r requirements.in
# build
pyproject-hooks==1.0.0 \
--hash=sha256:283c11acd6b928d2f6a7c73fa0d01cb2bdc5f07c57a2eeb6e83d5e56b97976f8 \
--hash=sha256:f271b298b97f5955d53fb12b72c1fb1948c22c1a6b70b315c54cedaca0264ef5
Expand Down
1 change: 1 addition & 0 deletions requirements.in
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ pip
setuptools
wheel
build
packaging
20 changes: 20 additions & 0 deletions tests/forty-two/forty-two.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#include <Python.h>

static PyObject * answer(PyObject *self, PyObject *args)
{
return PyLong_FromLong(42);
}

/* Module initialization */
static PyMethodDef module_methods[] = {
{"answer", (PyCFunction)answer, METH_NOARGS, "The answer."},
{NULL} /* Sentinel */
};

PyMODINIT_FUNC PyInit_forty_two(void)
{
static struct PyModuleDef moduledef = {
PyModuleDef_HEAD_INIT, "forty_two", "The answer module", -1, module_methods,
};
return PyModule_Create(&moduledef);
}
3 changes: 3 additions & 0 deletions tests/forty-two/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[build-system]
requires = ["setuptools"]
build-backend = "setuptools.build_meta"
8 changes: 8 additions & 0 deletions tests/forty-two/setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
from setuptools import setup, Extension

setup(
name="forty_two",
version="0.1.0",
python_requires=">=3.6",
ext_modules=[Extension("forty_two", sources=["forty-two.c"])],
)
23 changes: 23 additions & 0 deletions tests/run_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,29 @@ for PYTHON in /opt/python/*/bin/python; do
LINK_VERSION=$(${LINK_PREFIX}${PYVERS} -V)
REAL_VERSION=$(${PYTHON} -V)
test "${LINK_VERSION}" = "${REAL_VERSION}"

# check a simple project can be built
SRC_DIR=/tmp/forty-two-${IMPLEMENTATION}${PYVERS}
DIST_DIR=/tmp/dist-${IMPLEMENTATION}${PYVERS}
cp -rf ${MY_DIR}/forty-two ${SRC_DIR}
PY_ABI_TAGS=$(basename $(dirname $(dirname $PYTHON)))
EXPECTED_WHEEL_NAME=forty_two-0.1.0-${PY_ABI_TAGS}-linux_${AUDITWHEEL_ARCH}.whl
${PYTHON} -m build -w -o ${DIST_DIR} ${SRC_DIR}
if [ ! -f ${DIST_DIR}/${EXPECTED_WHEEL_NAME} ]; then
echo "unexcpected wheel built: '$(basename $(find ${DIST_DIR} -name '*.whl'))' instead of '${EXPECTED_WHEEL_NAME}'"
exit 1
fi
auditwheel repair --only-plat -w ${DIST_DIR} ${DIST_DIR}/${EXPECTED_WHEEL_NAME}
REPAIRED_WHEEL=$(find ${DIST_DIR} -name "forty_two-0.1.0-${PY_ABI_TAGS}-*${AUDITWHEEL_POLICY}_${AUDITWHEEL_ARCH}*.whl")
if [ ! -f "${REPAIRED_WHEEL}" ]; then
echo "invalid repaired wheel name"
exit 1
fi
${PYTHON} -m pip install ${REPAIRED_WHEEL}
if [ "$(${PYTHON} -c 'import forty_two; print(forty_two.answer())')" != "42" ]; then
echo "invalid answer, expecting 42"
exit 1
fi
done

# minimal tests for tools that should be present
Expand Down

0 comments on commit 4434c7d

Please sign in to comment.