Skip to content

Commit

Permalink
Convert project & packaging config to uv
Browse files Browse the repository at this point in the history
  • Loading branch information
JWCook committed Jan 17, 2025
1 parent 1082d8a commit 1433d8d
Showing 8 changed files with 2,772 additions and 3,346 deletions.
10 changes: 4 additions & 6 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -26,24 +26,22 @@ jobs:
- uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- uses: snok/[email protected]
with:
virtualenvs-in-project: true
- uses: yezz123/setup-uv@v4

# Cache packages per python version, and reuse until lockfile changes
- name: Cache python packages
id: cache
uses: actions/cache@v4
with:
path: .venv
key: venv-${{ matrix.python-version }}-${{ hashFiles('poetry.lock') }}
key: venv-${{ matrix.python-version }}-${{ hashFiles('uv.lock') }}
- name: Install dependencies
if: steps.cache.outputs.cache-hit != 'true'
run: poetry install -v -E all
run: uv sync

# Run tests with coverage report
- name: Run tests
run: poetry run pytest -rs -x -vv ${{ env.XDIST_ARGS }} ${{ env.COVERAGE_ARGS }}
run: uv run pytest -rs -x -vv ${{ env.XDIST_ARGS }} ${{ env.COVERAGE_ARGS }}

# Latest python version: send coverage report to codecov
- name: "Upload coverage report to Codecov"
22 changes: 6 additions & 16 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -27,30 +27,20 @@ jobs:
- uses: actions/setup-python@v5
with:
python-version: ${{ env.LATEST_PY_VERSION }}
- uses: snok/[email protected]
with:
virtualenvs-in-project: true
- uses: yezz123/setup-uv@v4

- name: Set pre-release version
if: ${{ !startsWith(github.ref, 'refs/tags/v') }}
env:
pre-release-suffix: ${{ github.event.inputs.pre-release-suffix || 'dev' }}
pre-release-version: ${{ github.event.inputs.pre-release-version || github.run_number }}
run: |
poetry version $(poetry version -s).${{ env.pre-release-suffix }}${{ env.pre-release-version }}
poetry version
PKG_VERSION=$(uvx --from=toml-cli toml get --toml-path=pyproject.toml project.version)
DEV_VERSION=$PKG_VERSION.${{ env.pre-release-suffix }}${{ env.pre-release-version }}
echo "Setting pre-release version to $DEV_VERSION"
uvx --from=toml-cli toml set --toml-path=pyproject.toml project.version $DEV_VERSION
- name: Build package distributions
run: poetry build
run: uvx --from build pyproject-build --installer uv
- name: Publish package distributions to PyPI
uses: pypa/gh-action-pypi-publish@release/v1

# Notify Docker image repo that there's a new release available
#- name: Repository Dispatch
# if: ${{ startsWith(github.ref, 'refs/tags/v') }}
# uses: peter-evans/repository-dispatch@v1
# with:
# token: ${{ secrets.DOCKERHUB_TRIGGER_TOKEN }}
# repository: JWCook/pyinaturalist-notebook
# event-type: post-release
# client-payload: '{"ref": "${{ github.ref }}", "sha": "${{ github.sha }}"}'
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -18,6 +18,7 @@ eggs
lib
lib64
parts
scratch
sdist
var
venv/
4 changes: 2 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -3,11 +3,11 @@ Contributions are welcome, and they are greatly appreciated! Every
little bit helps, and credit will always be given.

## Installation
To set up for local development (requires [poetry](https://python-poetry.org)):
To set up for local development (requires [uv](https://docs.astral.sh/uv)):
```bash
$ git clone https://github.com/pyinat/pyinaturalist.git
$ cd pyinaturalist
$ poetry install -v -E docs
$ uv sync --all-extras
```

## Contribution Guidelines
14 changes: 6 additions & 8 deletions noxfile.py
Original file line number Diff line number Diff line change
@@ -8,7 +8,6 @@
from shutil import rmtree

import nox
from nox_poetry import session

nox.options.reuse_existing_virtualenvs = True
nox.options.sessions = ['lint', 'cov']
@@ -25,38 +24,37 @@
]


@session(python=['3.8', '3.9', '3.10', '3.11', '3.12', '3.13'])
@nox.session(python=['3.8', '3.9', '3.10', '3.11', '3.12', '3.13'])
def test(session):
"""Run tests for a specific python version"""
test_paths = session.posargs or ['test']
session.install('.', 'pytest', 'pytest-sugar', 'pytest-xdist', 'requests-mock')
session.run('pytest', '-n', 'auto', *test_paths)


@session(python=False)
@nox.session(python=False)
def clean(session):
"""Clean up temporary build + documentation files"""
for dir in CLEAN_DIRS:
print(f'Removing {dir}')
rmtree(dir, ignore_errors=True)


@session(python=False)
@session(python=False, name='cov')
@nox.session(python=False, name='cov')
def coverage(session):
"""Run tests and generate coverage report"""
cmd = 'pytest -n auto --cov --cov-report=term --cov-report=html'
session.run(*cmd.split(' '))


@session(python=False)
@nox.session(python=False)
def docs(session):
"""Build Sphinx documentation"""
cmd = 'sphinx-build docs docs/_build/html -j auto'
session.run(*cmd.split(' '))


@session(python=False)
@nox.session(python=False)
def livedocs(session):
"""Auto-build docs with live reload in browser.
Add `-- open` to also open the browser after starting.
@@ -73,7 +71,7 @@ def livedocs(session):
session.run(*cmd.split(' '))


@session(python=False)
@nox.session(python=False)
def lint(session):
"""Run linters and code formatters via pre-commit"""
cmd = 'pre-commit run --all-files'
3,214 changes: 0 additions & 3,214 deletions poetry.lock

This file was deleted.

186 changes: 86 additions & 100 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,115 +1,101 @@
[tool.poetry]
name = "pyinaturalist"
version = "0.20.1"
description = "iNaturalist API client for python"
authors = ["Jordan Cook"]
license = "MIT"
readme = "README.md"
homepage = "https://github.com/pyinat/pyinaturalist"
repository = "https://github.com/pyinat/pyinaturalist"
documentation = "https://pyinaturalist.readthedocs.io"
[project]
name = 'pyinaturalist'
version = '0.20.1'
description = 'iNaturalist API client for python'
authors = [{ name = 'Jordan Cook' }]
license = 'MIT'
readme = 'README.md'
keywords = [
"inaturalist",
"biodiversity",
"conservation",
"citizen-science",
"community-science",
"api",
"api-client",
"data-model",
"requests",
'inaturalist',
'biodiversity',
'conservation',
'citizen-science',
'community-science',
'api',
'api-client',
'data-model',
'requests',
]
classifiers = [
"Development Status :: 4 - Beta",
"Intended Audience :: Developers",
"Intended Audience :: Education",
"Intended Audience :: Science/Research",
"Topic :: Software Development :: Libraries :: Python Modules",
"Typing :: Typed",
'Development Status :: 4 - Beta',
'Intended Audience :: Developers',
'Intended Audience :: Education',
'Intended Audience :: Science/Research',
'Topic :: Software Development :: Libraries :: Python Modules',
'Typing :: Typed',
]
include = [
{ path = "*.md" },
{ path = "*.yml" },
{ path = "docs", format = "sdist" },
{ path = "examples", format = "sdist" },
{ path = "test", format = "sdist" }
requires-python = '>=3.8'
dependencies = [
'attrs>=21.2',
'keyring>=22.3',
'platformdirs>=2.6',
'python-dateutil>=2.0',
'requests>=2.25',
'requests-cache>=1.2',
'requests-ratelimiter>=0.5.1',
'rich>=10.9',
]
packages = [
{ include = "pyinaturalist" },
{ include = "pyinat" },
]

[tool.poetry.dependencies]
python = "^3.8"
attrs = ">=21.2"
keyring = ">=22.3"
platformdirs = ">=2.6"
python-dateutil = ">=2.0"
requests = ">=2.25"
requests-cache = ">=1.2"
requests-ratelimiter = ">=0.5.1"
rich = ">=10.9"

[project.urls]
homepage = 'https://github.com/pyinat/pyinaturalist'
repository = 'https://github.com/pyinat/pyinaturalist'
documentation = 'https://pyinaturalist.readthedocs.io'

# include = [
# { path = '*.md' },
# { path = '*.yml' },
# { path = 'docs', format = 'sdist' },
# { path = 'examples', format = 'sdist' },
# { path = 'test', format = 'sdist' }
# ]
# packages = [
# { include = 'pyinaturalist' },
# { include = 'pyinat' },
# ]


[project.optional-dependencies]
# Optional dependencies
filelock = {optional=true, version=">2.0"}
ujson = {optional=true, version=">5.0"}
all = [
'filelock>2.0',
'ujson>5.0',
]

# Documentation dependencies needed for Readthedocs builds
furo = {optional=true, version="^2024.8"}
ipython = {optional=true, version="^8.12"}
linkify-it-py = {optional=true, version="^2.0"}
matplotlib = {optional=true, version=">=3.7"}
myst-parser = {optional=true, version=">=1.0"}
nbsphinx = {optional=true, version="^0.9"}
pillow = {optional=true, version=">=10.1"}
sphinx = {optional=true, version="^6.2"}
sphinx-automodapi = {optional=true, version="^0.18"}
sphinx-autodoc-typehints = {optional=true, version="1.20"}
sphinx-copybutton = {optional=true, version=">=0.5"}
sphinx-design = {optional=true, version=">=0.5"}
sphinxcontrib-apidoc = {optional=true, version="^0.5"}
sphinxext-opengraph = {optional=true, version=">=0.9"}
setuptools = "^72.2.0"

[tool.poetry.dev-dependencies]
coverage = ">=7.2"
nox = "^2024.4"
nox-poetry = "^1.0.0"
pre-commit = "^3.5"
pretty-errors = ">=1.2"
pytest = "^8.2"
pytest-asyncio = ">=0.21"
pytest-cov = ">=3.0"
pytest-xdist = ">=2.2"
requests-mock = "^1.8"
sphinx-autobuild = ">=2021.3"

[tool.poetry.extras]
all = ["filelock", "ujson"]
docs = [
"furo",
"ipython",
"linkify-it-py",
"matplotlib",
"myst-parser",
"nbsphinx",
"pillow",
"sphinx",
"sphinx-automodapi",
"sphinx-autodoc-typehints",
"sphinx-copybutton",
"sphinx-design",
"sphinxcontrib-apidoc",
"sphinxext-opengraph",
'furo~=2024.8',
'ipython~=8.12',
'linkify-it-py~=2.0',
'matplotlib>=3.7',
'myst-parser>=1.0',
'nbsphinx~=0.9',
'pillow>=10.1',
'sphinx~=6.2',
'sphinx-automodapi~=0.18',
'sphinx-autodoc-typehints==1.20',
'sphinx-copybutton>=0.5',
'sphinx-design>=0.5',
'sphinxcontrib-apidoc~=0.5',
'sphinxext-opengraph>=0.9',
]

[build-system]
requires = ["poetry-core>=1.0.0"]
build-backend = "poetry.core.masonry.api"
[tool.uv]
dev-dependencies = [
'coverage>=7.2',
'nox~=2024.4',
'pre-commit~=3.5',
'pretty-errors>=1.2',
'pytest~=8.2',
'pytest-asyncio>=0.21',
'pytest-cov>=3.0',
'pytest-xdist>=2.2',
'requests-mock~=1.8',
'sphinx-autobuild>=2021.3',
]

[tool.black]
skip-string-normalization = true
line-length = 100
[build-system]
requires = ['hatchling>=1.0.0']
build-backend = 'hatchling.build'

[tool.coverage.html]
directory = 'test-reports'
@@ -142,7 +128,7 @@ files = ['pyinaturalist']

[tool.pytest.ini_options]
markers = [
"enable_client_session: Enable all ClientSession features: caching, rate-limiting, etc.",
'enable_client_session: Enable all ClientSession features: caching, rate-limiting, etc.',
]

[tool.ruff]
2,667 changes: 2,667 additions & 0 deletions uv.lock

Large diffs are not rendered by default.

0 comments on commit 1433d8d

Please sign in to comment.