diff --git a/.flake8 b/.flake8 index 2ddf68b7..be4b41e7 100644 --- a/.flake8 +++ b/.flake8 @@ -1,5 +1,5 @@ [flake8] max-line-length = 120 exclude = - ./build/** - + sdk/python/src/zrok_api/* + sdk/python/src/test/* diff --git a/.github/workflows/build-wheels.yml b/.github/workflows/build-wheels.yml index 381e5d3b..3f7f537a 100644 --- a/.github/workflows/build-wheels.yml +++ b/.github/workflows/build-wheels.yml @@ -1,4 +1,4 @@ -name: build wheels +name: Publish Python Distributions on: release: @@ -23,83 +23,86 @@ jobs: exit 1 fi - build_wheels: + build_distributions: + name: Building Python Distributions needs: enforce_stable_semver + runs-on: ubuntu-24.04 defaults: run: working-directory: sdk/python/src - strategy: - fail-fast: false - matrix: - spec: - - { name: 'linux x86_64', runner: ubuntu-20.04, target: manylinux_2_27_x86_64 } - - { name: 'macOS x86_64', runner: macos-13, target: macosx_10_14_x86_64 } - - { name: 'Windows x86_64', runner: windows-2019, target: win_amd64 } - name: building ${{ matrix.spec.name }} - runs-on: ${{ matrix.spec.runner }} steps: - name: Checkout uses: actions/checkout@v4 - with: - fetch-depth: 0 - - name: Setup Python + - name: Set up Python uses: actions/setup-python@v5 with: python-version: '3.13' + cache: 'pip' - - name: Install Python Tools - run: python -m pip install -U pip setuptools - - - name: Build distro + - name: Build Python distributions env: ZROK_VERSION: ${{ github.event.release.tag_name }} ZROK_PY_NAME: ${{ vars.ZROK_PY_NAME || null }} + shell: bash run: | - python setup.py sdist + + set -o pipefail + set -o xtrace + + # Install build requirements + pip install --upgrade pip + pip install -r build-requirements.txt + + # Build source distribution and wheel + python -m build + + # List built distributions + ls -lAR ./dist - uses: actions/upload-artifact@v4 - if: startsWith(matrix.spec.name, 'linux') with: - name: zrok_sdk_${{ matrix.spec.target }} - path: dist/* + name: zrok_sdk_distributions + path: sdk/python/src/dist/* - publish-testpypi: - runs-on: ubuntu-20.04 - needs: [ build_wheels ] + publish_testpypi: + name: Publish TestPyPI + runs-on: ubuntu-24.04 + needs: [ build_distributions ] permissions: - id-token: write + id-token: write steps: - name: Download artifacts uses: actions/download-artifact@v4 with: - path: ./dist + path: sdk/python/src/dist merge-multiple: true - pattern: zrok_sdk_* + pattern: zrok_sdk_distributions - - name: Publish wheels (TestPYPI) + - name: Publish Distributions to TestPyPI uses: pypa/gh-action-pypi-publish@release/v1 with: repository-url: https://test.pypi.org/legacy/ - packages-dir: dist + packages-dir: sdk/python/src/dist skip-existing: true verbose: true - publish-pypi: - runs-on: ubuntu-20.04 - needs: [ publish-testpypi ] + publish_pypi: + name: Publish PyPI + runs-on: ubuntu-24.04 + needs: [ publish_testpypi ] permissions: - id-token: write + id-token: write steps: - name: Download artifacts uses: actions/download-artifact@v4 with: - path: ./dist + path: sdk/python/src/dist merge-multiple: true - pattern: zrok_sdk_* + pattern: zrok_sdk_distributions - - name: Publish wheels (PyPI) + - name: Publish Distributions to PyPI uses: pypa/gh-action-pypi-publish@release/v1 with: - packages-dir: dist + packages-dir: sdk/python/src/dist verbose: true diff --git a/.github/workflows/ci-build.yml b/.github/workflows/ci-build.yml index d947327a..62a75d2d 100644 --- a/.github/workflows/ci-build.yml +++ b/.github/workflows/ci-build.yml @@ -61,19 +61,6 @@ jobs: shell: bash run: go test -v ./... - - name: setup python - uses: actions/setup-python@v3 - with: - python-version: '3.13' - - - name: python deps - shell: bash - run: python -m pip install -U pip flake8 - - - name: python lint - shell: bash - run: flake8 sdk/python/src - - name: solve GOBIN id: solve_go_bin shell: bash @@ -89,14 +76,14 @@ jobs: if-no-files-found: error pytest: - + name: Test the Python SDK runs-on: ubuntu-24.04 - defaults: - run: - working-directory: sdk/python/src strategy: matrix: python-version: ["3.10", "3.11", "3.12", "3.13"] + defaults: + run: + working-directory: sdk/python steps: - uses: actions/checkout@v4 @@ -114,9 +101,10 @@ jobs: set -o xtrace python -m pip install --upgrade pip - pip install -e "$PWD" - pip install -r requirements.txt - pip install -r test-requirements.txt + pip install -r src/requirements.txt + pip install -r src/test-requirements.txt + pip install -r src/build-requirements.txt + pip install -e src/ - name: Test with pytest shell: bash @@ -125,7 +113,16 @@ jobs: set -o pipefail set -o xtrace - pytest --cov=zrok_api --verbose + pytest --cov=zrok_api --verbose src/ + + - name: Lint the Python SDK + shell: bash + run: | + + set -o pipefail + set -o xtrace + + flake8 . # build a release candidate container image for branches named "main" or like "v*" rc-container-build: diff --git a/sdk/python/src/build-requirements.txt b/sdk/python/src/build-requirements.txt new file mode 100644 index 00000000..9ae847b6 --- /dev/null +++ b/sdk/python/src/build-requirements.txt @@ -0,0 +1,3 @@ +build +wheel +versioneer diff --git a/sdk/python/src/pyproject.toml b/sdk/python/src/pyproject.toml new file mode 100644 index 00000000..28c36983 --- /dev/null +++ b/sdk/python/src/pyproject.toml @@ -0,0 +1,3 @@ +[build-system] +requires = ["setuptools>=42", "wheel", "versioneer>=0.28"] +build-backend = "setuptools.build_meta" diff --git a/sdk/python/src/setup.cfg b/sdk/python/src/setup.cfg index a23d00c4..94902a7d 100644 --- a/sdk/python/src/setup.cfg +++ b/sdk/python/src/setup.cfg @@ -1,5 +1,5 @@ [metadata] -name = zrok +# "name" property is determined by setup.py based on environment variable author = NetFoundry author_email = developers@openziti.org description = zrok Python SDK