Skip to content

Commit ec459ed

Browse files
authored
Use rye for package management (#284)
Alternative to #283 --------- Signed-off-by: Mattt Zmuda <[email protected]>
1 parent 59f19a9 commit ec459ed

13 files changed

+173
-162
lines changed

.github/workflows/ci.yaml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,10 @@ jobs:
2828
shell: bash
2929

3030
steps:
31-
- uses: actions/checkout@v3
32-
- uses: actions/setup-python@v3
31+
- uses: actions/checkout@v4
32+
- uses: eifinger/setup-rye@v2
3333
with:
34-
python-version: ${{ matrix.python-version }}
35-
cache: "pip"
34+
enable-cache: true
3635

3736
- name: Setup
3837
run: ./script/setup

.python-version

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
3.12.2

pyproject.toml

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,20 +16,22 @@ dependencies = [
1616
"pydantic>1.10.7",
1717
"typing_extensions>=4.5.0",
1818
]
19-
optional-dependencies = { dev = [
20-
"pylint",
21-
"pyright",
22-
"pytest",
23-
"pytest-asyncio",
24-
"pytest-recording",
25-
"respx",
26-
"ruff>=0.3.3",
27-
] }
2819

2920
[project.urls]
3021
homepage = "https://replicate.com"
3122
repository = "https://github.com/replicate/replicate-python"
3223

24+
[tool]
25+
rye = { dev-dependencies = [
26+
"pytest>=8.1.1",
27+
"pylint>=3.1.0",
28+
"pyright>=1.1.358",
29+
"pytest-asyncio>=0.23.6",
30+
"pytest-recording>=0.13.1",
31+
"respx>=0.21.1",
32+
"ruff>=0.3.7",
33+
] }
34+
3335
[tool.pytest.ini_options]
3436
testpaths = "tests/"
3537

replicate/__about__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
from importlib.metadata import version
22

3-
__version__ = version(__package__)
3+
__version__ = version(__package__ if __package__ is not None else "replicate")

replicate/prediction.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -253,8 +253,7 @@ def output_iterator(self) -> Iterator[Any]:
253253

254254
output = self.output or []
255255
new_output = output[len(previous_output) :]
256-
for output in new_output:
257-
yield output
256+
yield from new_output
258257

259258
async def async_output_iterator(self) -> AsyncIterator[Any]:
260259
"""

requirements-dev.lock

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
# generated by rye
2+
# use `rye lock` or `rye sync` to update this lockfile
3+
#
4+
# last locked with the following flags:
5+
# pre: false
6+
# features: []
7+
# all-features: false
8+
# with-sources: false
9+
10+
-e file:.
11+
annotated-types==0.6.0
12+
# via pydantic
13+
anyio==4.3.0
14+
# via httpx
15+
astroid==3.1.0
16+
# via pylint
17+
certifi==2024.2.2
18+
# via httpcore
19+
# via httpx
20+
dill==0.3.8
21+
# via pylint
22+
h11==0.14.0
23+
# via httpcore
24+
httpcore==1.0.5
25+
# via httpx
26+
httpx==0.27.0
27+
# via replicate
28+
# via respx
29+
idna==3.7
30+
# via anyio
31+
# via httpx
32+
# via yarl
33+
iniconfig==2.0.0
34+
# via pytest
35+
isort==5.13.2
36+
# via pylint
37+
mccabe==0.7.0
38+
# via pylint
39+
multidict==6.0.5
40+
# via yarl
41+
nodeenv==1.8.0
42+
# via pyright
43+
packaging==24.0
44+
# via pytest
45+
# via replicate
46+
platformdirs==4.2.0
47+
# via pylint
48+
pluggy==1.4.0
49+
# via pytest
50+
pydantic==2.7.0
51+
# via replicate
52+
pydantic-core==2.18.1
53+
# via pydantic
54+
pylint==3.1.0
55+
pyright==1.1.358
56+
pytest==8.1.1
57+
# via pytest-asyncio
58+
# via pytest-recording
59+
pytest-asyncio==0.23.6
60+
pytest-recording==0.13.1
61+
pyyaml==6.0.1
62+
# via vcrpy
63+
respx==0.21.1
64+
ruff==0.3.7
65+
setuptools==69.2.0
66+
# via nodeenv
67+
sniffio==1.3.1
68+
# via anyio
69+
# via httpx
70+
tomlkit==0.12.4
71+
# via pylint
72+
typing-extensions==4.11.0
73+
# via pydantic
74+
# via pydantic-core
75+
# via replicate
76+
vcrpy==6.0.1
77+
# via pytest-recording
78+
wrapt==1.16.0
79+
# via vcrpy
80+
yarl==1.9.4
81+
# via vcrpy

requirements-dev.txt

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

requirements.lock

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# generated by rye
2+
# use `rye lock` or `rye sync` to update this lockfile
3+
#
4+
# last locked with the following flags:
5+
# pre: false
6+
# features: []
7+
# all-features: false
8+
# with-sources: false
9+
10+
-e file:.
11+
annotated-types==0.6.0
12+
# via pydantic
13+
anyio==4.3.0
14+
# via httpx
15+
certifi==2024.2.2
16+
# via httpcore
17+
# via httpx
18+
h11==0.14.0
19+
# via httpcore
20+
httpcore==1.0.5
21+
# via httpx
22+
httpx==0.27.0
23+
# via replicate
24+
idna==3.7
25+
# via anyio
26+
# via httpx
27+
packaging==24.0
28+
# via replicate
29+
pydantic==2.7.0
30+
# via replicate
31+
pydantic-core==2.18.1
32+
# via pydantic
33+
sniffio==1.3.1
34+
# via anyio
35+
# via httpx
36+
typing-extensions==4.11.0
37+
# via pydantic
38+
# via pydantic-core
39+
# via replicate

requirements.txt

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

script/format

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
#!/bin/bash
1+
#!/bin/sh
22

33
set -e
44

5-
python -m ruff format .
5+
exec rye fmt .

script/lint

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,19 @@ set -e
55
STATUS=0
66

77
echo "Running pyright"
8-
python -m pyright replicate || STATUS=$?
8+
rye run pyright replicate || STATUS=$?
99
echo ""
1010

1111
echo "Running pylint"
12-
python -m pylint --exit-zero replicate || STATUS=$?
12+
rye run pylint --exit-zero replicate || STATUS=$?
1313
echo ""
1414

15-
echo "Running ruff check"
16-
python -m ruff check . || STATUS=$?
15+
echo "Running rye lint"
16+
rye lint . || STATUS=$?
1717
echo ""
1818

19-
echo "Running ruff format check"
20-
python -m ruff format --check . || STATUS=$?
19+
echo "Running rye fmt --check"
20+
rye fmt --check || STATUS=$?
2121
echo ""
2222

2323
exit $STATUS

script/setup

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,28 @@
1-
#!/bin/bash
1+
#!/bin/sh
22

3-
set -e
3+
set -eu
44

5-
python -m pip install -r requirements.txt -r requirements-dev.txt .
5+
: "${RYE_INSTALL_OPTION:='--yes'}"
6+
: "${RYE_VERSION:='latest'}"
7+
8+
if ! command -v rye > /dev/null 2>&1
9+
then
10+
echo "rye is not installed."
11+
printf "Do you want to install rye? (y/n) "
12+
read -r REPLY
13+
echo # move to a new line
14+
case "$REPLY" in
15+
[yY])
16+
echo "Installing rye..."
17+
curl -sSf https://rye-up.com/get | sh
18+
echo "rye has been successfully installed."
19+
;;
20+
*)
21+
exit 1
22+
;;
23+
esac
24+
else
25+
echo "rye is already installed."
26+
fi
27+
28+
exec rye sync

script/test

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
#!/bin/bash
1+
#!/bin/sh
22

33
set -e
44

5-
python -m pytest -v
5+
exec rye test -v

0 commit comments

Comments
 (0)