Skip to content

Commit 6094f5a

Browse files
authored
Modernize Python package infrastructure (#84)
* Replace setup.py with pyproject.toml Signed-off-by: Mattt Zmuda <[email protected]> * Set requires-python >= 3.8 Signed-off-by: Mattt Zmuda <[email protected]> * Generate requirements files from pyproject.toml using pip-tools Signed-off-by: Mattt Zmuda <[email protected]> * Replace pytest.ini with pyproject.toml entry Signed-off-by: Mattt Zmuda <[email protected]> * Define canonical version in pyproject.toml Set __version__ dynamically Signed-off-by: Mattt Zmuda <[email protected]> * Update CI workflow Signed-off-by: Mattt Zmuda <[email protected]> * Update dev dependencies Signed-off-by: Mattt Zmuda <[email protected]> --------- Signed-off-by: Mattt Zmuda <[email protected]>
1 parent 3ae1539 commit 6094f5a

File tree

8 files changed

+105
-47
lines changed

8 files changed

+105
-47
lines changed

.github/workflows/ci.yaml

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -16,23 +16,16 @@ jobs:
1616
run:
1717
shell: bash
1818
steps:
19-
- uses: actions/checkout@master
19+
- uses: actions/checkout@v3
2020
- name: Setup Python
21-
uses: actions/setup-python@v2
21+
uses: actions/setup-python@v3
2222
with:
2323
python-version: ${{ matrix.python-version }}
24-
- uses: actions/cache@v2
25-
with:
26-
path: ~/.cache/pip
27-
key: pip-${{ hashFiles('**/requirements-dev.txt') }}
28-
restore-keys: |
29-
pip-${{ secrets.CACHE_VERSION }}-
30-
- name: Install development dependencies
31-
run: pip install -r requirements-dev.txt
32-
- name: Install package & dependencies
33-
run: pip install .
24+
cache: "pip"
25+
- name: Install dependencies
26+
run: python -m pip install -r requirements.txt -r requirements-dev.txt .
3427
- name: Test
35-
run: pytest
28+
run: python -m pytest
3629

3730
release:
3831
name: "Release"

pyproject.toml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
[build-system]
2+
requires = ["setuptools", "wheel"]
3+
build-backend = "setuptools.build_meta"
4+
5+
[project]
6+
name = "replicate"
7+
version = "0.7.0"
8+
description = "Python client for Replicate"
9+
readme = "README.md"
10+
license = { file = "LICENSE" }
11+
authors = [{ name = "Replicate, Inc." }]
12+
requires-python = ">=3.8"
13+
dependencies = ["packaging", "pydantic>1", "requests>2"]
14+
optional-dependencies = { dev = ["black", "pytest", "responses"] }
15+
16+
[project.urls]
17+
homepage = "https://replicate.com"
18+
repository = "https://github.com/replicate/replicate-python"
19+
20+
[tool.pytest.ini_options]
21+
testpaths = "tests/"

pytest.ini

Lines changed: 0 additions & 2 deletions
This file was deleted.

replicate/__about__.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
1-
__version__ = "0.7.0"
1+
from importlib.metadata import version
2+
3+
__version__ = version(__package__)

replicate/__init__.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
from .__about__ import __version__
21
from .client import Client
32

43
default_client = Client()

requirements-dev.txt

Lines changed: 53 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,53 @@
1-
packaging==21.3
2-
pytest==7.1.2
3-
responses==0.21.0
1+
#
2+
# This file is autogenerated by pip-compile with Python 3.11
3+
# by the following command:
4+
#
5+
# pip-compile --extra=dev --output-file=requirements-dev.txt pyproject.toml
6+
#
7+
attrs==22.2.0
8+
# via pytest
9+
black==23.3.0
10+
# via replicate (pyproject.toml)
11+
certifi==2022.12.7
12+
# via requests
13+
charset-normalizer==3.1.0
14+
# via requests
15+
click==8.1.3
16+
# via black
17+
idna==3.4
18+
# via requests
19+
iniconfig==2.0.0
20+
# via pytest
21+
mypy-extensions==1.0.0
22+
# via black
23+
packaging==23.0
24+
# via
25+
# black
26+
# pytest
27+
# replicate (pyproject.toml)
28+
pathspec==0.11.1
29+
# via black
30+
platformdirs==3.2.0
31+
# via black
32+
pluggy==1.0.0
33+
# via pytest
34+
pydantic==1.10.7
35+
# via replicate (pyproject.toml)
36+
pytest==7.2.2
37+
# via replicate (pyproject.toml)
38+
pyyaml==6.0
39+
# via responses
40+
requests==2.28.2
41+
# via
42+
# replicate (pyproject.toml)
43+
# responses
44+
responses==0.23.1
45+
# via replicate (pyproject.toml)
46+
types-pyyaml==6.0.12.9
47+
# via responses
48+
typing-extensions==4.5.0
49+
# via pydantic
50+
urllib3==1.26.15
51+
# via
52+
# requests
53+
# responses

requirements.txt

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#
2+
# This file is autogenerated by pip-compile with Python 3.11
3+
# by the following command:
4+
#
5+
# pip-compile --output-file=requirements.txt pyproject.toml
6+
#
7+
certifi==2022.12.7
8+
# via requests
9+
charset-normalizer==3.1.0
10+
# via requests
11+
idna==3.4
12+
# via requests
13+
packaging==23.0
14+
# via replicate (pyproject.toml)
15+
pydantic==1.10.7
16+
# via replicate (pyproject.toml)
17+
requests==2.28.2
18+
# via replicate (pyproject.toml)
19+
typing-extensions==4.5.0
20+
# via pydantic
21+
urllib3==1.26.15
22+
# via requests

setup.py

Lines changed: 0 additions & 27 deletions
This file was deleted.

0 commit comments

Comments
 (0)