Skip to content

Commit

Permalink
Merge pull request #462 from Backblaze/pdm-builds
Browse files Browse the repository at this point in the history
Build with pdm
  • Loading branch information
vbaltrusaitis-reef authored Jan 23, 2024
2 parents a6a7f21 + b775b87 commit f2ee664
Show file tree
Hide file tree
Showing 14 changed files with 1,444 additions and 272 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ on:
tags: 'v*' # push events to matching v*, i.e. v1.0, v20.15.10

env:
PYTHON_DEFAULT_VERSION: "3.11"
PYTHON_DEFAULT_VERSION: "3.12"

jobs:
deploy:
Expand All @@ -18,13 +18,13 @@ jobs:
with:
fetch-depth: 0
- name: Set up Python ${{ env.PYTHON_DEFAULT_VERSION }}
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: ${{ env.PYTHON_DEFAULT_VERSION }}
- name: Display Python version
run: python -c "import sys; print(sys.version)"
- name: Install dependencies
run: python -m pip install --upgrade nox pip setuptools
run: python -m pip install --upgrade nox pdm
- name: Build the distribution
id: build
run: nox -vs build
Expand Down
46 changes: 18 additions & 28 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ on:

env:
PYTHON_DEFAULT_VERSION: "3.12"
SKIP_COVERAGE_PYTHON_VERSION_PREFIX: "pypy"

jobs:
lint:
Expand All @@ -21,12 +20,12 @@ jobs:
with:
ignore_words_list: datas re-use
- name: Set up Python ${{ env.PYTHON_DEFAULT_VERSION }}
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: ${{ env.PYTHON_DEFAULT_VERSION }}
cache: "pip"
- name: Install dependencies
run: python -m pip install --upgrade nox pip setuptools
run: python -m pip install --upgrade nox pdm
- name: Run linters
run: nox -vs lint
- name: Validate new changelog entries
Expand All @@ -43,12 +42,12 @@ jobs:
with:
fetch-depth: 0
- name: Set up Python ${{ env.PYTHON_DEFAULT_VERSION }}
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: ${{ env.PYTHON_DEFAULT_VERSION }}
cache: "pip"
- name: Install dependencies
run: python -m pip install --upgrade nox pip setuptools
run: python -m pip install --upgrade nox pdm
- name: Build the distribution
run: nox -vs build
cleanup_buckets:
Expand All @@ -64,13 +63,13 @@ jobs:
fetch-depth: 0
- name: Set up Python ${{ env.PYTHON_DEFAULT_VERSION }}
if: ${{ env.B2_TEST_APPLICATION_KEY != '' && env.B2_TEST_APPLICATION_KEY_ID != '' }} # TODO: skip this whole job instead
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: ${{ env.PYTHON_DEFAULT_VERSION }}
cache: "pip"
- name: Install dependencies
if: ${{ env.B2_TEST_APPLICATION_KEY != '' && env.B2_TEST_APPLICATION_KEY_ID != '' }} # TODO: skip this whole job instead
run: python -m pip install --upgrade nox pip setuptools
run: python -m pip install --upgrade nox pdm
- name: Find and remove old buckets
if: ${{ env.B2_TEST_APPLICATION_KEY != '' && env.B2_TEST_APPLICATION_KEY_ID != '' }} # TODO: skip this whole job instead
run: nox -vs cleanup_old_buckets
Expand All @@ -84,41 +83,32 @@ jobs:
fail-fast: false
matrix:
os: ["ubuntu-latest", "macos-latest", "windows-latest"]
python-version: ["3.7", "3.8", "3.9", "3.10", "3.11", "3.12", "pypy-3.9", "pypy-3.9-nightly", "pypy-3.10"]
python-version: ["3.7", "3.8", "3.9", "3.10", "3.11", "3.12", "pypy3.9", "pypy3.10"]
exclude:
- os: "macos-latest"
python-version: "pypy-3.9"
python-version: "pypy3.9"
- os: "ubuntu-latest"
python-version: "pypy-3.9"
python-version: "pypy3.9"
- os: "macos-latest"
python-version: "pypy-3.10"
python-version: "pypy3.10"
- os: "windows-latest"
python-version: "pypy-3.10"
# TODO: pypy-3.9 started breaking on windows, due to some prints leftover in pypy release
- os: "ubuntu-latest"
python-version: "pypy-3.9-nightly"
- os: "macos-latest"
python-version: "pypy-3.9-nightly"
- os: "windows-latest"
python-version: "pypy-3.9"
python-version: "pypy3.10"
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
cache: "pip"
- name: Install dependencies
run: python -m pip install --upgrade nox pip setuptools
run: python -m pip install --upgrade nox pdm
- name: Run unit tests
run: nox -vs unit -- -v
env:
SKIP_COVERAGE: ${{ startsWith(matrix.python-version, env.SKIP_COVERAGE_PYTHON_VERSION_PREFIX) }}
run: nox -vs unit -p ${{ matrix.python-version }} -- -v
- name: Run integration tests
if: ${{ env.B2_TEST_APPLICATION_KEY != '' && env.B2_TEST_APPLICATION_KEY_ID != '' }}
run: nox -vs integration -- --dont-cleanup-old-buckets -v
run: nox -vs integration -p ${{ matrix.python-version }} -- --dont-cleanup-old-buckets -v
doc:
needs: build
runs-on: ubuntu-latest
Expand All @@ -127,7 +117,7 @@ jobs:
with:
fetch-depth: 0
- name: Set up Python ${{ env.PYTHON_DEFAULT_VERSION }}
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: ${{ env.PYTHON_DEFAULT_VERSION }}
cache: "pip"
Expand All @@ -137,6 +127,6 @@ jobs:
run: |
sudo apt-get update -y
sudo apt-get install -y graphviz plantuml
python -m pip install --upgrade nox pip setuptools
python -m pip install --upgrade nox pdm
- name: Build the docs
run: nox --non-interactive -vs doc
run: nox --non-interactive -vs doc
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,5 @@ dist
venv
.venv
.vscode
.pdm-build/
.pdm-python
12 changes: 7 additions & 5 deletions .readthedocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,11 @@ version: 2
build:
os: ubuntu-22.04
tools:
python: "3.8"
python: "3.12"
jobs:
post_create_environment:
- pip install pdm
- pdm export --format requirements --prod --group doc --output requirements-doc.txt

# Build documentation in the docs/ directory with Sphinx
sphinx:
Expand All @@ -20,8 +24,6 @@ formats: all
# Optionally set the version of Python and requirements required to build your docs
python:
install:
- requirements: requirements.txt
- requirements: requirements-doc.txt
- method: pip
path: .
extra_requirements:
- doc
path: .
13 changes: 10 additions & 3 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,9 @@ for a given github issue).

## Developer Info

You'll need to have [nox](https://github.com/theacodes/nox) installed:
You'll need to have [nox](https://github.com/theacodes/nox) and [pdm](https://pdm-project.org/) installed:

* `pip install nox`
* `pip install nox pdm`

With `nox`, you can run different sessions (default are `lint` and `test`):

Expand All @@ -66,7 +66,6 @@ With `nox`, you can run different sessions (default are `lint` and `test`):
* `test` (`test-3.7`, `test-3.8`, `test-3.9`, `test-3.10`) -> Run test suite.
* `cover` -> Perform coverage analysis.
* `build` -> Build the distribution.
* `deploy` -> Deploy the distribution to the PyPi.
* `doc` -> Build the documentation.
* `doc_cover` -> Perform coverage analysis for the documentation.

Expand Down Expand Up @@ -98,6 +97,14 @@ With the above setting, session `test` will run on Python 3.7 and 3.8, and all o

Given Python interpreters should be installed in the operating system or via [pyenv](https://github.com/pyenv/pyenv).

## Managing dependencies

We use [pdm](https://pdm-project.org/) for managing dependencies and developing locally.
If you want to change any of the project requirements (or requirement bounds) in `pyproject.toml`,
make sure that `pdm.lock` file reflects those changes by using `pdm add`, `pdm update` or other
commands - see [documentation](https://pdm-project.org/latest/). You can verify that lock file
is up to date by running the linter.

## Linting

To run all available linters:
Expand Down
2 changes: 0 additions & 2 deletions MANIFEST.in

This file was deleted.

1 change: 1 addition & 0 deletions changelog.d/+pdm.infrastructure.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Package the library using [pdm](https://pdm-project.org), use locked dependencies in CI.
Loading

0 comments on commit f2ee664

Please sign in to comment.