diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml deleted file mode 100644 index 045b7bcc..00000000 --- a/.github/workflows/build.yml +++ /dev/null @@ -1,93 +0,0 @@ -name: Build -on: - push: - branches-ignore: gh-pages - tags-ignore: '*' - pull_request: null - -jobs: - linux: - runs-on: ubuntu-latest - strategy: - fail-fast: false - matrix: - name: - - debian-stable - - debian-heimdal - - centos-stream-8 - - fedora-latest - include: - - name: debian-stable - distro: debian:stable - - name: debian-heimdal - distro: debian:stable - krb5_ver: heimdal - - name: centos-stream-8 - distro: quay.io/centos/centos:stream8 - - name: fedora-latest - distro: fedora:latest - flake: 'yes' - - steps: - - name: Check out code - uses: actions/checkout@v2 - - - name: Build and test gssapi - run: ./ci/run-on-linux.sh ./ci/build.sh - env: - DISTRO: ${{ matrix.distro }} - KRB5_VER: ${{ matrix.krb5_ver }} - FLAKE: ${{ matrix.flake }} - - windows: - runs-on: windows-latest - strategy: - fail-fast: false - matrix: - name: - - win-py-3.10 - - win-py-3.9 - - win-py-3.8 - - win-py-3.7 - - win-py-3.6 - arch: - - x64 - - x86 - include: - - name: win-py-3.10 - pyenv: '3.10' - - name: win-py-3.9 - pyenv: '3.9' - - name: win-py-3.8 - pyenv: '3.8' - - name: win-py-3.7 - pyenv: '3.7' - - name: win-py-3.6 - pyenv: '3.6' - - steps: - - name: Check out code - uses: actions/checkout@v2 - - - name: Install the right python - uses: actions/setup-python@v2 - with: - python-version: ${{ matrix.pyenv }} - architecture: ${{ matrix.arch }} - - - name: Build and test gssapi - shell: bash - run: ./ci/build.sh - env: - OS_NAME: windows - - macos-heimdal: - runs-on: macos-latest - steps: - - name: Check out code - uses: actions/checkout@v2 - - - name: Build and test gssapi - run: ./ci/build.sh - env: - KRB5_VER: heimdal diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 00000000..90b47986 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,327 @@ +name: Build +on: + push: + branches-ignore: gh-pages + tags: v* + pull_request: null + +jobs: + build_sdist: + name: Build sdist + runs-on: ubuntu-latest + steps: + - name: Check out code + uses: actions/checkout@v2 + + - name: Select python + uses: actions/setup-python@v2 + with: + python-version: 3.9 + + - name: Build sdist + run: | + python -m pip install build + python -m build --sdist + env: + GSSAPI_SUPPORT_DETECT: false + GSSAPI_LINKER_ARGS: '' + GSSAPI_COMPILER_ARGS: '' + + - name: Upload sdist + uses: actions/upload-artifact@v2 + with: + name: artifact + path: ./dist/*.tar.gz + + build_wheels: + name: Build wheels + needs: + - build_sdist + + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + include: + - os: macOS-12 + version: cp310-macosx_x86_64 + - os: macOS-12 + version: cp310-macosx_arm64 + - os: macOS-12 + version: cp39-macosx_x86_64 + - os: macOS-12 + version: cp39-macosx_arm64 + - os: macOS-12 + version: cp38-macosx_x86_64 + - os: macOS-12 + version: cp38-macosx_arm64 + - os: macOS-12 + version: cp37-macosx_x86_64 + - os: macOS-12 + version: cp36-macosx_x86_64 + + - os: windows-2022 + version: cp310-win_amd64 + - os: windows-2022 + version: cp310-win32 + - os: windows-2022 + version: cp39-win_amd64 + - os: windows-2022 + version: cp39-win32 + - os: windows-2022 + version: cp38-win_amd64 + - os: windows-2022 + version: cp38-win32 + - os: windows-2022 + version: cp37-win_amd64 + - os: windows-2022 + version: cp37-win32 + - os: windows-2022 + version: cp36-win_amd64 + - os: windows-2022 + version: cp36-win32 + + steps: + - name: Set up environment + if: startsWith(matrix.os, 'windows-') + shell: bash + run: | + choco.exe install \ + --no-progress \ + --yes \ + --ignore-detected-reboot \ + --allow-downgrade \ + --install-arguments "'ADDLOCAL=ALL'" \ + ${{ endsWith(matrix.version, '-win32') && '--x86' || '' }} mitkerberos || true + + echo "C:\Program Files${{ endsWith(matrix.version, '-win32') && ' (x86)' || '' }}\MIT\Kerberos\bin;$PATH" >> $GITHUB_PATH + + - name: Download gssapi sdist + uses: actions/download-artifact@v2 + with: + name: artifact + path: ./ + + - name: Extract sdist + shell: bash + run: | + tar xf gssapi-*.tar.gz + mv gssapi-*/* . + rm -r gssapi-*/ + rm gssapi-*.tar.gz + + - name: Build wheel + uses: pypa/cibuildwheel@v2.8.1 + env: + CIBW_ARCHS: all + CIBW_TEST_SKIP: '*_arm64' + CIBW_BUILD: ${{ matrix.version }} + CIBW_BUILD_VERBOSITY: 1 + + - name: Upload wheel + uses: actions/upload-artifact@v2 + with: + path: ./wheelhouse/*.whl + name: artifact + + linux: + needs: + - build_sdist + - build_wheels + + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + name: + - debian-stable + - debian-heimdal + - centos-stream-8 + - fedora-latest + include: + - name: debian-stable + distro: debian:stable + - name: debian-heimdal + distro: debian:stable + krb5_ver: heimdal + - name: centos-stream-8 + distro: quay.io/centos/centos:stream8 + - name: fedora-latest + distro: fedora:latest + flake: 'yes' + + steps: + - name: Check out code + uses: actions/checkout@v2 + + - name: Download built project + uses: actions/download-artifact@v2 + with: + name: artifact + path: ./dist + + - name: Test gssapi + run: ./ci/run-on-linux.sh ./ci/test.sh + env: + DISTRO: ${{ matrix.distro }} + KRB5_VER: ${{ matrix.krb5_ver }} + FLAKE: ${{ matrix.flake }} + + windows: + needs: + - build_sdist + - build_wheels + + runs-on: windows-latest + strategy: + fail-fast: false + matrix: + name: + - win-py-3.10 + - win-py-3.9 + - win-py-3.8 + - win-py-3.7 + - win-py-3.6 + arch: + - x64 + - x86 + include: + - name: win-py-3.10 + pyenv: '3.10' + - name: win-py-3.9 + pyenv: '3.9' + - name: win-py-3.8 + pyenv: '3.8' + - name: win-py-3.7 + pyenv: '3.7' + - name: win-py-3.6 + pyenv: '3.6' + + steps: + - name: Check out code + uses: actions/checkout@v2 + + - name: Download built project + uses: actions/download-artifact@v2 + with: + name: artifact + path: ./dist + + - name: Install the right python + uses: actions/setup-python@v2 + with: + python-version: ${{ matrix.pyenv }} + architecture: ${{ matrix.arch }} + + - name: Test gssapi + shell: bash + run: ./ci/test.sh + env: + OS_NAME: windows + + macos: + needs: + - build_sdist + - build_wheels + + runs-on: macos-latest + steps: + - name: Check out code + uses: actions/checkout@v2 + + - name: Download built project + uses: actions/download-artifact@v2 + with: + name: artifact + path: ./dist + + - name: Test gssapi + run: ./ci/test.sh + env: + KRB5_VER: heimdal + + publish: + name: publish + + needs: + - linux + - macos + - windows + + runs-on: ubuntu-latest + steps: + - name: Check out code + uses: actions/checkout@v2 + + - name: Download built project + uses: actions/download-artifact@v2 + with: + name: artifact + path: ./dist + + - name: Create GitHub release artifact + run: ./ci/run-on-linux.sh ./ci/create-release-tar.sh + env: + DISTRO: fedora:latest + + - name: Get tarball path + id: tarball + run: echo "::set-output name=tarball::`ls tag_build/*.tar.gz | awk -F/ '{print $2}'`" + + - name: Get release checksum path + id: checksum + run: echo "::set-output name=checksum::`ls tag_build/*.sha512sum | awk -F/ '{print $2}'`" + + - name: Upload tagged build artifact + uses: actions/upload-artifact@v2 + with: + path: tag_build/${{ steps.tarball.outputs.tarball }} + name: artifact + + - name: Deploy stable docs + if: startsWith(github.ref, 'refs/tags/v') + uses: JamesIves/github-pages-deploy-action@3.7.1 + with: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + BRANCH: gh-pages + FOLDER: ci_docs_build/html + TARGET_FOLDER: stable + + - name: Create release + if: startsWith(github.ref, 'refs/tags/v') + uses: actions/create-release@v1 + id: cr + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + tag_name: ${{ github.ref }} + release_name: ${{ github.ref }} + + - name: Upload release tarball + if: startsWith(github.ref, 'refs/tags/v') + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ steps.cr.outputs.upload_url }} + asset_path: tag_build/${{ steps.tarball.outputs.tarball }} + asset_name: ${{ steps.tarball.outputs.tarball }} + asset_content_type: application/octet-stream + + - name: Upload release checksum + if: startsWith(github.ref, 'refs/tags/v') + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ steps.cr.outputs.upload_url }} + asset_path: tag_build/${{ steps.checksum.outputs.checksum }} + asset_name: ${{ steps.checksum.outputs.checksum }} + asset_content_type: text/plain + + - name: Deploy to PyPI + if: startsWith(github.ref, 'refs/tags/v') + uses: pypa/gh-action-pypi-publish@v1.1.0 + with: + user: __token__ + password: ${{ secrets.pypi_password }} diff --git a/.github/workflows/deploy-docs.yml b/.github/workflows/deploy-docs.yml index 32021ce5..e17737cb 100644 --- a/.github/workflows/deploy-docs.yml +++ b/.github/workflows/deploy-docs.yml @@ -10,12 +10,27 @@ jobs: - name: Check out code uses: actions/checkout@v2 + - name: Select python + uses: actions/setup-python@v2 + with: + python-version: 3.9 + + - name: Build sdist + run: | + python -m pip install build + python -m build --sdist + env: + GSSAPI_SUPPORT_DETECT: false + GSSAPI_LINKER_ARGS: '' + GSSAPI_COMPILER_ARGS: '' + - name: Build docs run: ./ci/run-on-linux.sh ./ci/before-docs-deploy.sh env: DISTRO: fedora:latest - name: Deploy latest docs + if: false uses: JamesIves/github-pages-deploy-action@3.7.1 with: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml deleted file mode 100644 index 226253a6..00000000 --- a/.github/workflows/release.yml +++ /dev/null @@ -1,174 +0,0 @@ -name: Release -on: - push: - tags: v* - -jobs: - sdist-release: - runs-on: ubuntu-latest - - steps: - - name: Check out code - uses: actions/checkout@v2 - - - name: Set things up - run: ./ci/run-on-linux.sh ./ci/before-deploy.sh - env: - DISTRO: fedora:latest - - - name: Upload sdist - uses: actions/upload-artifact@v2 - with: - path: ./dist/*.tar.gz - name: artifact - - - name: Deploy stable docs - uses: JamesIves/github-pages-deploy-action@3.7.1 - with: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - BRANCH: gh-pages - FOLDER: ci_docs_build/html - TARGET_FOLDER: stable - - - name: Create release - uses: actions/create-release@v1 - id: cr - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - tag_name: ${{ github.ref }} - release_name: ${{ github.ref }} - - - id: tarball - run: echo "::set-output name=tarball::`ls tag_build/*.tar.gz | awk -F/ '{print $2}'`" - - - id: checksum - run: echo "::set-output name=checksum::`ls tag_build/*.sha512sum | awk -F/ '{print $2}'`" - - - name: Upload release tarball - uses: actions/upload-release-asset@v1 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - upload_url: ${{ steps.cr.outputs.upload_url }} - asset_path: tag_build/${{ steps.tarball.outputs.tarball }} - asset_name: ${{ steps.tarball.outputs.tarball }} - asset_content_type: application/octet-stream - - - name: Upload release checksum - uses: actions/upload-release-asset@v1 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - upload_url: ${{ steps.cr.outputs.upload_url }} - asset_path: tag_build/${{ steps.checksum.outputs.checksum }} - asset_name: ${{ steps.checksum.outputs.checksum }} - asset_content_type: text/plain - - wheel: - needs: - - sdist-release - - runs-on: ${{ matrix.os }} - strategy: - matrix: - include: - - os: macOS-10.15 - version: cp310-macosx_x86_64 - - os: macOS-10.15 - version: cp310-macosx_arm64 - - os: macOS-10.15 - version: cp39-macosx_x86_64 - - os: macOS-10.15 - version: cp39-macosx_arm64 - - os: macOS-10.15 - version: cp38-macosx_x86_64 - - os: macOS-10.15 - version: cp38-macosx_arm64 - - os: macOS-10.15 - version: cp37-macosx_x86_64 - - os: macOS-10.15 - version: cp36-macosx_x86_64 - - - os: windows-2019 - version: cp310-win_amd64 - - os: windows-2019 - version: cp310-win32 - - os: windows-2019 - version: cp39-win_amd64 - - os: windows-2019 - version: cp39-win32 - - os: windows-2019 - version: cp38-win_amd64 - - os: windows-2019 - version: cp38-win32 - - os: windows-2019 - version: cp37-win_amd64 - - os: windows-2019 - version: cp37-win32 - - os: windows-2019 - version: cp36-win_amd64 - - os: windows-2019 - version: cp36-win32 - - steps: - - name: Set up environment - if: startsWith(matrix.os, 'windows-') - shell: bash - run: | - choco.exe install \ - --no-progress \ - --yes \ - --ignore-detected-reboot \ - --allow-downgrade \ - --install-arguments "'ADDLOCAL=ALL'" \ - ${{ endsWith(matrix.version, '-win32') && '--x86' || '' }} mitkerberos || true - - echo "C:\Program Files${{ endsWith(matrix.version, '-win32') && ' (x86)' || '' }}\MIT\Kerberos\bin;$PATH" >> $GITHUB_PATH - - - name: Download sdist - uses: actions/download-artifact@v2 - with: - name: artifact - path: ./ - - - name: Extract sdist - shell: bash - run: | - tar xf gssapi-*.tar.gz - mv gssapi-*/* . - rm -r gssapi-*/ - rm gssapi-*.tar.gz - - - name: Build wheel - uses: pypa/cibuildwheel@v2.1.2 - env: - CIBW_ARCHS: all - CIBW_TEST_SKIP: '*_arm64' - CIBW_BUILD: ${{ matrix.version }} - CIBW_BUILD_VERBOSITY: 1 - - - name: Upload wheel - uses: actions/upload-artifact@v2 - with: - path: ./wheelhouse/*.whl - name: artifact - - pypi: - needs: - - wheel - - runs-on: ubuntu-latest - - steps: - - name: Download sdist and wheels - uses: actions/download-artifact@v2 - with: - name: artifact - path: ./dist - - - name: Deploy to PyPI - uses: pypa/gh-action-pypi-publish@v1.1.0 - with: - user: __token__ - password: ${{ secrets.pypi_password }} diff --git a/MANIFEST.in b/MANIFEST.in index 67cc2bbc..c9ba29f4 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -1,5 +1,6 @@ include *.txt recursive-include docs *.txt recursive-include gssapi *.pxd -recursive-include gssapi *.c +recursive-include gssapi *.pyx recursive-include gssapi *.h +recursive-exclude gssapi *.c diff --git a/README.txt b/README.txt index 9154f7b0..69a34f90 100644 --- a/README.txt +++ b/README.txt @@ -74,8 +74,7 @@ After being sure to install all the requirements, .. code-block:: bash $ git clone https://github.com/pythongssapi/python-gssapi.git - $ python setup.py build - $ python setup.py install + $ pip install . Tests ===== diff --git a/ci/before-docs-deploy.sh b/ci/before-docs-deploy.sh index a6bb1eb1..d7c719ed 100755 --- a/ci/before-docs-deploy.sh +++ b/ci/before-docs-deploy.sh @@ -1,12 +1,7 @@ #!/bin/bash -ex -source ./ci/lib-setup.sh -source ./ci/lib-deploy.sh +source ./ci/lib.sh -# GitHub Actions doesn't have a good concept of connected pipelines here, so -# just rebuild rather than trying to figure it out. -./ci/build.sh +lib::setup::install -setup::activate - -deploy::build-docs +lib::deploy::build_docs diff --git a/ci/before-deploy.sh b/ci/create-release-tar.sh similarity index 72% rename from ci/before-deploy.sh rename to ci/create-release-tar.sh index 2f135a95..52410f04 100755 --- a/ci/before-deploy.sh +++ b/ci/create-release-tar.sh @@ -1,19 +1,21 @@ #!/bin/bash -ex -source ./ci/lib-setup.sh -source ./ci/lib-deploy.sh +source ./ci/lib.sh -./ci/build.sh - -setup::activate +lib::setup::install yum -y install tar git +# Git complains if this isn't owned by the user which is the case when running +# through the run-on-linux.sh +if [ -f /.dockerenv ]; then + git config --global --add safe.directory "${PWD}" +fi + # build the docs -deploy::build-docs +lib::deploy::build_docs -# build the sdist and save the dirs before the clean -python setup.py sdist +# Save the sdist and venv dirs before the clean mv dist dist_saved mv .venv /tmp/.venv @@ -31,7 +33,13 @@ mkdir ./tag_build # create and checksum the tarball +set +e tag=$(git describe --tags) +if [ "${?}" -ne 0 ]; then + tag=$(git rev-parse --short HEAD) +fi +set -e + if [ x"${tag#v[0-9]}" = "x${tag}" ]; then PYTHON_GSSAPI_VERSION=${tag} else @@ -44,7 +52,7 @@ tar -cvf ./tag_build/${PKG_NAME_VER}.tar \ --exclude='dist' \ --exclude='tag_build' \ --exclude='.git' \ - --exclude='travis_docs_build' \ + --exclude='ci_docs_build' \ --exclude='.venv' \ --exclude='README.rst' \ --transform="s,^\.,${PKG_NAME_VER}," . diff --git a/ci/lib-deploy.sh b/ci/lib-deploy.sh deleted file mode 100755 index 25c11309..00000000 --- a/ci/lib-deploy.sh +++ /dev/null @@ -1,13 +0,0 @@ -deploy::build-docs() { - # the first run is for the docs build, so don't clean up - pip install -r docs-requirements.txt - - # install dependencies so that sphinx doesn't have issues - # (this actually just installs the whole package in dev mode) - pip install -e . - - # place in a non-standard location so that they don't get cleaned up - python setup.py build_sphinx --build-dir ci_docs_build - - echo "docs_build" -} diff --git a/ci/lib-setup.sh b/ci/lib.sh similarity index 57% rename from ci/lib-setup.sh rename to ci/lib.sh index cf12856c..07408c8a 100755 --- a/ci/lib-setup.sh +++ b/ci/lib.sh @@ -1,9 +1,6 @@ #!/bin/bash -# We test Debian's cython. el7's cython is too old, and Rawhide's virtualenv -# doesn't work right (usrmerge bugs) so we can only test Debian's cython. - -setup::debian::install() { +lib::setup::debian_install() { export DEBIAN_FRONTEND=noninteractive apt-get update @@ -19,52 +16,47 @@ setup::debian::install() { export GSSAPI_KRB5_MAIN_LIB="/usr/lib/x86_64-linux-gnu/libkrb5.so" fi - apt-get -y install gcc virtualenv python3-{virtualenv,dev} cython3 + apt-get -y install gcc virtualenv python3-{venv,dev} - virtualenv --system-site-packages -p $(which python3) .venv + virtualenv -p $(which python3) .venv source ./.venv/bin/activate } -setup::rh::yuminst() { +lib::setup::rh_yuminst() { # yum has no update-only verb. Also: modularity just makes this slower. yum -y --nogpgcheck --disablerepo=\*modul\* install $@ } -setup::centos::install() { - # Cython on el7 is too old - downstream patches - setup::rh::yuminst python3-{virtualenv,devel} +lib::setup::centos_install() { + lib::setup::rh_yuminst python3-{virtualenv,devel} virtualenv -p $(which python3) .venv source ./.venv/bin/activate - pip install --upgrade pip # el7 pip doesn't quite work right - pip install --install-option='--no-cython-compile' cython } -setup::fedora::install() { +lib::setup::fedora_install() { # path to binary here in case Rawhide changes it - setup::rh::yuminst redhat-rpm-config \ + lib::setup::rh_yuminst redhat-rpm-config \ /usr/bin/virtualenv python3-{virtualenv,devel} virtualenv -p $(which python3) .venv source ./.venv/bin/activate - pip install --install-option='--no-cython-compile' cython } -setup::rh::install() { - setup::rh::yuminst krb5-{devel,libs,server,workstation} \ +lib::setup::rh_install() { + lib::setup::rh_yuminst krb5-{devel,libs,server,workstation} \ which gcc findutils gssntlmssp export GSSAPI_KRB5_MAIN_LIB="/usr/lib64/libkrb5.so" if [ -f /etc/fedora-release ]; then - setup::fedora::install + lib::setup::fedora_install else - setup::centos::install + lib::setup::centos_install fi } -setup::macos::install() { +lib::setup::macos_install() { sudo pip3 install virtualenv python3 -m virtualenv -p $(which python3) .venv source .venv/bin/activate - pip install --install-option='--no-cython-compile' cython export GSSAPI_KRB5_MAIN_LIB="/System/Library/PrivateFrameworks/Heimdal.framework/Heimdal" @@ -74,7 +66,7 @@ setup::macos::install() { export KRB5_KTNAME=initial } -setup::windows::install() { +lib::setup::windows_install() { CHINST="choco install --no-progress --yes --ignore-detected-reboot --allow-downgrade" # Install the 32bit version if Python is 32bit @@ -90,32 +82,52 @@ setup::windows::install() { # Update path to include it export PATH="/c/$PF/MIT/Kerberos/bin:$PATH" - - python -m pip install --upgrade pip } -setup::install() { +lib::setup::install() { if [ -f /etc/debian_version ]; then - setup::debian::install + lib::setup::debian_install elif [ -f /etc/redhat-release ]; then - setup::rh::install + lib::setup::rh_install elif [ "$(uname)" == "Darwin" ]; then - setup::macos::install + lib::setup::macos_install elif [ "$OS_NAME" == "windows" ]; then - setup::windows::install + lib::setup::windows_install else echo "Distro not found!" false fi - pip install -r test-requirements.txt + # Get the explicit version to force pip to install from our local dir in + # case this is a pre-release and/or PyPi has a later version + echo "Installing gssapi" + GSSAPI_VER="$( grep 'version=' setup.py | cut -d "'" -f2 )" + + if [ "$(expr substr $(uname -s) 1 5)" == "MINGW" ]; then + DIST_LINK_PATH="$( echo "${PWD}/dist" | sed -e 's/^\///' -e 's/\//\\/g' -e 's/^./\0:/' )" + else + DIST_LINK_PATH="${PWD}/dist" + fi + + python -m pip install gssapi=="${GSSAPI_VER}" \ + --find-links "file://${DIST_LINK_PATH}" \ + --verbose + + echo "Installing dev dependencies" + python -m pip install -r test-requirements.txt } -setup::activate() { - # remove (and restore) set -x to avoid log-spam the source - # script, which we don't care about - wastrace=${-//[^x]/} - set +x - source .venv/bin/activate - if [[ -n "$wastrace" ]]; then set -x; fi +lib::deploy::build_docs() { + # the first run is for the docs build, so don't clean up + pip install -r docs-requirements.txt + + # Don't run in root to make sure the local copies aren't imported + pushd docs + + # place in a non-standard location so that they don't get cleaned up + sphinx-build source ../ci_docs_build -a -W -n + + popd + + echo "docs_build" } diff --git a/ci/run-on-linux.sh b/ci/run-on-linux.sh index 96814721..272a9039 100755 --- a/ci/run-on-linux.sh +++ b/ci/run-on-linux.sh @@ -1,10 +1,10 @@ #!/bin/bash -ex -# If we try to use a normal Github Actions container with -# github-pages-deploy-action, it will fail due to inability to find git. - -docker run -h test.krbtest.com \ - -v `pwd`:/tmp/build -w /tmp/build \ - -e KRB5_VER=${KRB5_VER:-mit} \ - -e FLAKE=${FLAKE:no} \ - $DISTRO /bin/bash -ex $@ +docker run \ + --rm \ + --hostname test.krbtest.com \ + --volume "$( pwd )":/tmp/build:z \ + --workdir /tmp/build \ + --env KRB5_VER=${KRB5_VER:-mit} \ + --env FLAKE=${FLAKE:no} \ + ${DISTRO} /bin/bash -ex $@ diff --git a/ci/build.sh b/ci/test.sh similarity index 67% rename from ci/build.sh rename to ci/test.sh index 8b455d7d..c953f207 100755 --- a/ci/build.sh +++ b/ci/test.sh @@ -1,8 +1,18 @@ #!/bin/bash -ex # set up dependencies, etc -source ./ci/lib-setup.sh -setup::install +source ./ci/lib.sh + +if [ x"${GITHUB_ACTIONS}" = "xtrue" ]; then + echo "::group::Installing Requirements" +fi + +lib::setup::install + +if [ x"${GITHUB_ACTIONS}" = "xtrue" ]; then + echo "::endgroup::" + echo "::group::Running Sanity Checks" +fi if [ x"$FLAKE" = "xyes" ]; then flake8 setup.py @@ -32,15 +42,15 @@ if [ $MYPY_RES -ne 0 ]; then exit $MYPY_RES fi -# always build in-place so that Sphinx can find the modules -python setup.py build_ext --inplace $EXTRA_BUILDEXT -BUILD_RES=$? - -if [ $BUILD_RES -ne 0 ]; then - # if the build failed, don't run the tests - exit $BUILD_RES +if [ x"${GITHUB_ACTIONS}" = "xtrue" ]; then + echo "::endgroup::" + echo "::group::Running Tests" fi +# Ensure we don't run in the normal dir so that unittest imports our installed +# package and not the source code +pushd gssapi/tests + # Only call exit on failures so we can source this script if [ "$OS_NAME" = "windows" ]; then # Windows can't run the tests yet, so just make sure it imports and exit @@ -48,3 +58,9 @@ if [ "$OS_NAME" = "windows" ]; then else python -m unittest -v || exit $? fi + +popd + +if [ x"${GITHUB_ACTIONS}" = "xtrue" ]; then + echo "::endgroup::" +fi diff --git a/docs/source/conf.py b/docs/source/conf.py index 4688d998..1644b8cd 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -18,7 +18,6 @@ # documentation root, use os.path.abspath to make it absolute, like shown here. #sys.path.insert(0, os.path.abspath('.')) -sys.path.insert(0, os.path.abspath('../..')) sys.path.insert(0, os.path.abspath('../custom_extensions')) from custom_recommonmark import AllCodeCommonMarkParser diff --git a/mypy.ini b/mypy.ini deleted file mode 100644 index 71944250..00000000 --- a/mypy.ini +++ /dev/null @@ -1,31 +0,0 @@ -[mypy] -exclude = (?x)( - setup.py - | docs/ # doc files - | build/ # temp build folder - ) -show_error_codes = True -show_column_numbers = True -disallow_any_unimported = true -disallow_untyped_calls = true -disallow_untyped_defs = true -disallow_incomplete_defs = true -check_untyped_defs = true -disallow_untyped_decorators = true -warn_redundant_casts = true -warn_unused_ignores = true - -[mypy-gssapi.tests.*] -disallow_any_unimported = false -disallow_untyped_calls = false -disallow_untyped_defs = false -check_untyped_defs = false - -[mypy-k5test] -ignore_missing_imports = True - -[mypy-k5test.unit] -ignore_missing_imports = True - -[mypy-parameterized] -ignore_missing_imports = True diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 00000000..2f5c208c --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,58 @@ +[build-system] +requires = [ + "Cython >= 0.29.29, < 3.0.0", # 0.29.29 includes fixes for Python 3.11 + "setuptools >= 40.6.0", # Start of PEP 517 support for setuptools +] +build-backend = "setuptools.build_meta" + +[tool.mypy] +exclude = """ +(?x)( + setup.py + | docs/ + | build/ +) +""" +show_error_codes = true +show_column_numbers = true +disallow_any_unimported = true +disallow_untyped_calls = true +disallow_untyped_defs = true +disallow_incomplete_defs = true +check_untyped_defs = true +disallow_untyped_decorators = true +warn_redundant_casts = true +warn_unused_ignores = true + +[[tool.mypy.overrides]] +module = "gssapi.tests.*" +disallow_any_unimported = false +disallow_untyped_calls = false +disallow_untyped_defs = false +check_untyped_defs = false + +[[tool.mypy.overrides]] +module = "k5test" +ignore_missing_imports = true + +[[tool.mypy.overrides]] +module = "k5test.unit" +ignore_missing_imports = true + +[[tool.mypy.overrides]] +module = "parameterized" +ignore_missing_imports = true + +[tool.tox] +legacy_tox_ini = """ +[tox] +envlist = py36,py37,py38 + +[testenv] +whitelist_externals=bash +commands = + bash -c "source ./.travis/lib-verify.sh && verify::flake8" + python -m unittest + +deps = -r{toxinidir}/test-requirements.txt +""" diff --git a/setup.cfg b/setup.cfg deleted file mode 100644 index ce995309..00000000 --- a/setup.cfg +++ /dev/null @@ -1,9 +0,0 @@ -[build_sphinx] -source-dir=docs/source -build-dir=docs/build -all_files=1 -warning-is-error=1 -nitpicky=1 - -[upload_sphinx] -upload-dir = docs/build/html diff --git a/setup.py b/setup.py index 7d3eec60..75e71fc9 100755 --- a/setup.py +++ b/setup.py @@ -1,6 +1,4 @@ #!/usr/bin/env python -from __future__ import print_function - import subprocess import platform import re @@ -16,25 +14,8 @@ os.environ['SETUPTOOLS_USE_DISTUTILS'] = 'local' from setuptools import setup # noqa: E402 -from setuptools import Distribution # noqa: E402 -from setuptools.command.sdist import sdist # noqa: E402 from setuptools.extension import Extension # noqa: E402 - - -SKIP_CYTHON_FILE = '__dont_use_cython__.txt' - -if os.path.exists(SKIP_CYTHON_FILE): - print("In distributed package, building from C files...", file=sys.stderr) - SOURCE_EXT = 'c' -else: - try: - from Cython.Build import cythonize - print("Building from Cython files...", file=sys.stderr) - SOURCE_EXT = 'pyx' - except ImportError: - print("Cython not found, building from C files...", - file=sys.stderr) - SOURCE_EXT = 'c' +from Cython.Build import cythonize # noqa: E402 def get_output(*args, **kwargs): @@ -225,60 +206,9 @@ def get_output(*args, **kwargs): GSSAPI_LIB = ctypes.CDLL(os.path.join(main_path, main_lib)) -# add in the flag that causes us not to compile from Cython when -# installing from an sdist -class sdist_gssapi(sdist): - def run(self): - if not self.dry_run: - with open(SKIP_CYTHON_FILE, 'w') as flag_file: - flag_file.write('COMPILE_FROM_C_ONLY') - - sdist.run(self) - - os.remove(SKIP_CYTHON_FILE) - - -DONT_CYTHONIZE_FOR = ('clean',) - - -class GSSAPIDistribution(Distribution, object): - def run_command(self, command): - self._last_run_command = command - Distribution.run_command(self, command) - - @property - def ext_modules(self): - if SOURCE_EXT != 'pyx': - return getattr(self, '_ext_modules', None) - - if getattr(self, '_ext_modules', None) is None: - return None - - if getattr(self, '_last_run_command', None) in DONT_CYTHONIZE_FOR: - return self._ext_modules - - if getattr(self, '_cythonized_ext_modules', None) is None: - self._cythonized_ext_modules = cythonize( - self._ext_modules, - language_level=2, - ) - - return self._cythonized_ext_modules - - @ext_modules.setter - def ext_modules(self, mods): - self._cythonized_ext_modules = None - self._ext_modules = mods - - @ext_modules.deleter - def ext_modules(self): - del self._ext_modules - del self._cythonized_ext_modules - - def make_extension(name_fmt, module, **kwargs): """Helper method to remove the repetition in extension declarations.""" - source = name_fmt.replace('.', '/') % module + '.' + SOURCE_EXT + source = name_fmt.replace('.', '/') % module + '.pyx' if not os.path.exists(source): raise OSError(source) return Extension( @@ -330,7 +260,7 @@ def gssapi_modules(lst): # add in any present enum extension files res.extend(ENUM_EXTS) - return res + return cythonize(res, language_level=2) long_desc = re.sub(r'\.\. role:: \w+\(code\)\s*\n\s*.+', '', @@ -344,7 +274,7 @@ def gssapi_modules(lst): setup( name='gssapi', - version='1.7.3', + version='1.8.0', author='The Python GSSAPI Team', author_email='jborean93@gmail.com', packages=['gssapi', 'gssapi.raw', 'gssapi.raw._enum_extensions', @@ -374,8 +304,6 @@ def gssapi_modules(lst): 'Topic :: Security', 'Topic :: Software Development :: Libraries :: Python Modules' ], - distclass=GSSAPIDistribution, - cmdclass={'sdist': sdist_gssapi}, ext_modules=gssapi_modules([ main_file('misc'), main_file('exceptions'), diff --git a/test-requirements.txt b/test-requirements.txt index 1480519f..f612f153 100644 --- a/test-requirements.txt +++ b/test-requirements.txt @@ -1,6 +1,6 @@ +build flake8 parameterized -Cython k5test decorator mypy==0.971 diff --git a/tox.ini b/tox.ini deleted file mode 100644 index 7eeefc40..00000000 --- a/tox.ini +++ /dev/null @@ -1,15 +0,0 @@ -# Tox (http://tox.testrun.org/) is a tool for running tests -# in multiple virtualenvs. This configuration file will run the -# test suite on all supported python versions. To use it, "pip install tox" -# and then run "tox" from this directory. - -[tox] -envlist = py36,py37,py38 - -[testenv] -whitelist_externals=bash -commands = - bash -c "source ./.travis/lib-verify.sh && verify::flake8" - python -m unittest - -deps = -r{toxinidir}/test-requirements.txt