Skip to content

Commit

Permalink
Package with hatch (#856)
Browse files Browse the repository at this point in the history
* Update CI and build configs to use `hatch` and `hatch-vcs`.
* Remove `typing_extensions` (used to backport `typing.Literal`)
  as we now drop support for Python 3.7 or older.

Co-authored-by: Joongi Kim <[email protected]>
  • Loading branch information
eevelweezel and achimnol authored Jun 11, 2024
1 parent 167301f commit 8e50208
Show file tree
Hide file tree
Showing 13 changed files with 115 additions and 101 deletions.
18 changes: 6 additions & 12 deletions .github/workflows/ci-cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,13 +68,10 @@ jobs:
with:
python-version: ${{ env.PYTHON_LATEST }}
cache: pip
cache-dependency-path: |
setup.py
requirements/lint.txt
- name: Install dependencies
uses: py-actions/py-dependency-install@v4
with:
path: requirements/lint.txt
run: |
python -m pip install --upgrade pip
python -m pip install -e .[ci,dev]
- uses: actions/cache@v4
with:
path: ~/.cache/pre-commit/
Expand Down Expand Up @@ -112,13 +109,10 @@ jobs:
with:
python-version: ${{ matrix.python-version }}
cache: pip
cache-dependency-path: |
setup.py
requirements/test.txt
- name: Install dependencies
uses: py-actions/py-dependency-install@v4
with:
path: requirements/test.txt
run: |
python -m pip install --upgrade pip
python -m pip install -e .[ci,dev]
- name: Start Docker services
if: ${{ matrix.registry == '1' }}
run: |
Expand Down
1 change: 1 addition & 0 deletions CHANGES/848.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Migrate from setuptools to hatch. To install the package and all dependencies, use "pip install .[dev,doc]".
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ endif


develop:
@pip install -e .
@pip install -e .[dev]

install:
@pip install -U pip
@pip install -Ur requirements/dev.txt
@pip install -e .[dev]
pre-commit install

create-tar:
Expand Down
37 changes: 37 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,43 @@ Installation
pip install aiodocker
Development
===========

Create a virtualenv (either using ``python -m venv``, ``pyenv`` or your
favorite tools) and install in the editable mode with ``ci`` and ``dev`` optional
dependency sets.

.. code-block:: sh
pip install -U pip
pip install -e '.[ci,dev]' # in zsh, you need to escape brackets
pre-commit install
Running tests
~~~~~~~~~~~~~

.. code-block:: sh
# Run all tests
make test
# Run individual tests
python -m pytest tests/test_images.py
Building packages
~~~~~~~~~~~~~~~~~

NOTE: Usually you don't need to run this step by yourself.

.. code-block:: sh
pip install -U build
python -m build --sdist --wheel
Documentation
=============

Expand Down
11 changes: 9 additions & 2 deletions aiodocker/execs.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,15 @@
import json
from typing import TYPE_CHECKING, Any, Dict, Optional, Tuple, overload
from typing import (
TYPE_CHECKING,
Any,
Dict,
Literal,
Optional,
Tuple,
overload,
)

import aiohttp
from typing_extensions import Literal
from yarl import URL

from .stream import Stream
Expand Down
3 changes: 1 addition & 2 deletions aiodocker/images.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,14 @@
AsyncIterator,
Dict,
List,
Literal,
Mapping,
MutableMapping,
Optional,
Union,
overload,
)

from typing_extensions import Literal

from .jsonstream import json_stream_list, json_stream_stream
from .types import SupportsRead
from .utils import clean_map, compose_auth_header
Expand Down
59 changes: 59 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,62 @@
[build-system]
requires = [
"hatchling >= 1.10.0",
"hatch-vcs",
]
build-backend = "hatchling.build"

[project]
name = "aiodocker"
dynamic = ["version"]
readme = "README.rst"
description = "A simple Docker HTTP API wrapper written with asyncio and aiohttp."
license = { text = "Apache 2.0" }
requires-python = ">=3.8.0"

classifiers = [
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3 :: Only",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12"
]
dependencies = [
"aiohttp>=3.8",
]

[project.optional-dependencies]
ci = [
# pinned for reproducible CI
"aiohttp==3.9.5",
"async-timeout==4.0.3",
"multidict==6.0.5",
"yarl==1.9.4",
]
dev = [
"codecov==2.1.13",
"mypy==1.10",
"packaging==24.0",
"pre-commit>=3.5.0",
"pytest==8.2.1",
"pytest-asyncio==0.23.7",
"pytest-cov==5.0.0",
"pytest-sugar==1.0.0",
"ruff==0.4.4",
"ruff-lsp==0.0.53",
"towncrier==23.11.0"
]
doc = [
"alabaster==0.7.16",
"sphinx==7.3.7",
"sphinx-autodoc-typehints==2.1.0",
"sphinxcontrib-asyncio==0.3.0"
]

[tool.hatch.version]
source = "vcs"

[tool.towncrier]
package = "aiodocker"
filename = "CHANGES.rst"
Expand Down
6 changes: 0 additions & 6 deletions requirements/ci.txt

This file was deleted.

7 changes: 0 additions & 7 deletions requirements/dev.txt

This file was deleted.

4 changes: 0 additions & 4 deletions requirements/doc.txt

This file was deleted.

4 changes: 0 additions & 4 deletions requirements/lint.txt

This file was deleted.

5 changes: 0 additions & 5 deletions requirements/test.txt

This file was deleted.

57 changes: 0 additions & 57 deletions setup.py

This file was deleted.

0 comments on commit 8e50208

Please sign in to comment.