From b31c25efefff47127872eac4cbf65bcc930e7f61 Mon Sep 17 00:00:00 2001 From: Gunnar Kreitz Date: Fri, 23 May 2025 12:05:53 +0200 Subject: [PATCH 1/3] Add marker to let mypy use our type annotations --- problemtools/py.typed | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 problemtools/py.typed diff --git a/problemtools/py.typed b/problemtools/py.typed new file mode 100644 index 00000000..e69de29b From 6e80dc69aa85ba005cf1e3c413a4dcd875f75b9c Mon Sep 17 00:00:00 2001 From: Gunnar Kreitz Date: Fri, 23 May 2025 13:11:03 +0200 Subject: [PATCH 2/3] Replace authors with Kattis AB (pypi only shows one). Set required python version --- pyproject.toml | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 7afdbff5..3a99cedc 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -5,16 +5,13 @@ build-backend = "setuptools.build_meta" [project] name = "problemtools" authors = [ - {name = "Fredrik Niemela", email = "niemela@kattis.com"}, - {name = "Gunnar Kreitz", email = "gkreitz@kattis.com"}, - {name = "Mikael Goldman", email = "migo@kattis.com"}, - {name = "Pehr Söderman", email = "pehrs@kattis.com"}, - {name = "Per Austrin", email = "austrin@kattis.com"}, + {name = "Kattis AB", email = "contact@kattis.com"}, ] description = "Kattis Problem Tools" readme = "README.md" license = "MIT" keywords = ["kattis", "problemtools", "icpc", "clics"] +requires-python = ">= 3.11" dependencies = [ "colorlog", @@ -44,6 +41,7 @@ include = ["problemtools", "problemtools.*"] [tool.setuptools_scm] version_file = "problemtools/_version.py" +local_scheme = "no-local-version" [tool.ruff] line-length = 130 From 8418e706afa3757114da1e5c8272f93216076841 Mon Sep 17 00:00:00 2001 From: Gunnar Kreitz Date: Fri, 23 May 2025 13:35:35 +0200 Subject: [PATCH 3/3] Add script to build packages for pypi --- admin/.gitignore | 1 + admin/build_pypi_packages.sh | 58 ++++++++++++++++++++++++++++++++++++ 2 files changed, 59 insertions(+) create mode 100644 admin/.gitignore create mode 100755 admin/build_pypi_packages.sh diff --git a/admin/.gitignore b/admin/.gitignore new file mode 100644 index 00000000..a4d089c1 --- /dev/null +++ b/admin/.gitignore @@ -0,0 +1 @@ +pypi_dist/ diff --git a/admin/build_pypi_packages.sh b/admin/build_pypi_packages.sh new file mode 100755 index 00000000..d29e0407 --- /dev/null +++ b/admin/build_pypi_packages.sh @@ -0,0 +1,58 @@ +#!/bin/bash +set -e + +TAG=develop +if [ "$1" != "" ]; then + TAG=$1 +fi + +cd $(dirname $(readlink -f $0)) + +if ! ../venv/bin/twine -h > /dev/null 2> /dev/null; then + echo "Did not find twine. Please run ../venv/bin/pip install twine" + exit 1 +fi + +if [[ -n $(git status -s) ]]; then + echo "Repository is dirty." + git status -s + exit 1 +fi + +if [[ $(git rev-parse --abbrev-ref HEAD) != ${TAG} && $(git describe --exact-match --tags 2>/dev/null) != ${TAG} ]]; then + echo "Repository is currently not on branch/tag ${TAG}." + exit 1 +fi + +echo "Building sdist and manylinux wheel" +sudo rm -rf ./pypi_dist +docker run --rm -v $(pwd)/..:/problemtools -v $(pwd)/pypi_dist:/dist quay.io/pypa/manylinux_2_28_x86_64 /bin/bash -c " + yum -y install boost-devel gmp-devel ; + mkdir /build ; + cd /build ; + git config --global --add safe.directory /problemtools/.git ; + git clone /problemtools ; + cd problemtools ; + git checkout ${TAG} ; + /opt/python/cp311-cp311/bin/python -m build ; + auditwheel repair dist/problemtools-*.whl ; + cp dist/*.tar.gz /dist ; + cp wheelhouse/*.whl /dist" +sudo chown -R $USER:$USER pypi_dist + +../venv/bin/twine check pypi_dist/* + +echo "Running verifyproblem from wheel on all examples" +TEMPDIR=$(mktemp -d) +python3 -m venv "${TEMPDIR}" +"${TEMPDIR}/bin/pip" install pypi_dist/problemtools*manylinux*whl +shopt -s extglob +if ! "${TEMPDIR}/bin/verifyproblem" ../examples/!(README.md); then + echo "Running verifyproblem on all examples failed. Please review output above to debug." + rm -rf "${TEMPDIR}" + exit 1 +fi +rm -rf "${TEMPDIR}" + +echo "Sucessfully built packages. If you're happy with them, upload:" +echo " ../venv/bin/twine upload --verbose pypi_dist/*"