Skip to content

Commit

Permalink
chore(internal): migrate from Poetry to Rye (#194)
Browse files Browse the repository at this point in the history
  • Loading branch information
stainless-bot authored Oct 17, 2023
1 parent cd93ef0 commit 1dd605e
Show file tree
Hide file tree
Showing 11 changed files with 171 additions and 1,496 deletions.
12 changes: 7 additions & 5 deletions .github/workflows/create-releases.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,18 @@ jobs:
repo: ${{ github.event.repository.full_name }}
stainless-api-key: ${{ secrets.STAINLESS_API_KEY }}

- name: Set up Python
- name: Install Rye
if: ${{ steps.release.outputs.releases_created }}
uses: actions/setup-python@v4
with:
python-version: '3.7'
run: |
curl -sSf https://rye-up.com/get | bash
echo "$HOME/.rye/shims" >> $GITHUB_PATH
env:
RYE_VERSION: 0.15.2
RYE_INSTALL_OPTION: "--yes"

- name: Publish to PyPI
if: ${{ steps.release.outputs.releases_created }}
run: |
pipx install poetry
bash ./bin/publish-pypi
env:
PYPI_TOKEN: ${{ secrets.ANTHROPIC_PYPI_TOKEN }}
12 changes: 7 additions & 5 deletions .github/workflows/publish-pypi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,16 @@ jobs:
steps:
- uses: actions/checkout@v3

- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.7'
- name: Install Rye
run: |
curl -sSf https://rye-up.com/get | bash
echo "$HOME/.rye/shims" >> $GITHUB_PATH
env:
RYE_VERSION: 0.15.2
RYE_INSTALL_OPTION: "--yes"

- name: Publish to PyPI
run: |
pipx install poetry
bash ./bin/publish-pypi
env:
PYPI_TOKEN: ${{ secrets.ANTHROPIC_PYPI_TOKEN }}
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,7 @@ __pycache__

dist

.venv

.env
codegen.log
5 changes: 3 additions & 2 deletions bin/publish-pypi
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#!/usr/bin/env bash

set -eux
poetry config pypi-token.pypi $PYPI_TOKEN
poetry publish --build
mkdir dist
rye build --clean
rye publish --yes --token=$PYPI_TOKEN
2 changes: 1 addition & 1 deletion bin/test
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#!/usr/bin/env bash

bin/check-test-server && poetry run pytest "$@"
bin/check-test-server && rye run pytest "$@"
9 changes: 3 additions & 6 deletions noxfile.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
import nox
import nox_poetry


@nox_poetry.session(reuse_venv=True, name="test-pydantic-v1")
@nox.session(reuse_venv=True, name="test-pydantic-v1")
def test_pydantic_v1(session: nox.Session) -> None:
session.run_always("poetry", "install", external=True)

# https://github.com/cjolowicz/nox-poetry/issues/1116
session._session.run("python", "-m", "pip", "install", "pydantic<2", external=True) # type: ignore
session.install("-r", "requirements-dev.lock")
session.install("pydantic<2")

session.run("pytest", "--showlocals", "--ignore=tests/functional", *session.posargs)
1,448 changes: 0 additions & 1,448 deletions poetry.lock

This file was deleted.

80 changes: 53 additions & 27 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,43 +1,69 @@
[tool.poetry]
[project]
name = "anthropic"
version = "0.4.1"
description = "Client library for the anthropic API"
readme = "README.md"
authors = ["Anthropic <support@anthropic.com>"]
license = "MIT"
repository = "https://github.com/anthropics/anthropic-sdk-python"
packages = [
{ include = "anthropic", from = "src" }
authors = [
{ name = "Anthropic", email = "support@anthropic.com" },
]
dependencies = [
"httpx>=0.23.0, <1",
"pydantic>=1.9.0, <3",
"typing-extensions>=4.5, <5",
"anyio>=3.5.0, <4",
"distro>=1.7.0, <2",
"tokenizers >= 0.13.0"
]
requires-python = ">= 3.7"


[tool.poetry.dependencies]
python = "^3.7"
httpx = ">= 0.23.0, < 1"
pydantic = ">= 1.9.0, < 3"
typing-extensions = ">= 4.5, < 5"
anyio = ">= 3.5.0, < 4"
distro = ">= 1.7.0, < 2"
tokenizers = ">= 0.13.0"

[project.urls]
Homepage = "https://github.com/anthropics/anthropic-sdk-python"
Repository = "https://github.com/anthropics/anthropic-sdk-python"

[tool.poetry.group.dev.dependencies]
pyright = "1.1.326"
mypy = "1.4.1"
black = "23.3.0"
respx = "0.19.2"
pytest = "7.1.1"
pytest-asyncio = "0.21.1"
ruff = "0.0.282"
isort = "5.10.1"
time-machine = "^2.9.0"
nox = "^2023.4.22"
nox-poetry = "^1.0.3"


[tool.rye]
managed = true
dev-dependencies = [
"pyright==1.1.326",
"mypy==1.4.1",
"black==23.3.0",
"respx==0.19.2",
"pytest==7.1.1",
"pytest-asyncio==0.21.1",
"ruff==0.0.282",
"isort==5.10.1",
"time-machine==2.9.0",
"nox==2023.4.22",

]

[tool.rye.scripts]
format = { chain = [
"format:black",
"format:docs",
"format:ruff",
"format:isort",
]}
"format:black" = "black ."
"format:docs" = "python bin/blacken-docs.py README.md api.md"
"format:ruff" = "ruff --fix ."
"format:isort" = "isort ."

[build-system]
requires = ["poetry-core>=1.0.0"]
build-backend = "poetry.core.masonry.api"
requires = ["hatchling"]
build-backend = "hatchling.build"

[tool.hatch.build]
include = [
"src/*"
]

[tool.hatch.build.targets.wheel]
packages = ["src/anthropic"]

[tool.black]
line-length = 120
Expand Down
61 changes: 61 additions & 0 deletions requirements-dev.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
# generated by rye
# use `rye lock` or `rye sync` to update this lockfile
#
# last locked with the following flags:
# pre: false
# features: []
# all-features: true

-e file:.
annotated-types==0.6.0
anyio==3.7.1
argcomplete==3.1.2
attrs==23.1.0
black==23.3.0
certifi==2023.7.22
charset-normalizer==3.3.0
click==8.1.7
colorlog==6.7.0
distlib==0.3.7
distro==1.8.0
exceptiongroup==1.1.3
filelock==3.12.4
fsspec==2023.9.2
h11==0.12.0
httpcore==0.15.0
httpx==0.23.0
huggingface-hub==0.16.4
idna==3.4
iniconfig==2.0.0
isort==5.10.1
mypy==1.4.1
mypy-extensions==1.0.0
nodeenv==1.8.0
nox==2023.4.22
packaging==23.2
pathspec==0.11.2
platformdirs==3.11.0
pluggy==1.3.0
py==1.11.0
pydantic==2.4.2
pydantic-core==2.10.1
pyright==1.1.326
pytest==7.1.1
pytest-asyncio==0.21.1
python-dateutil==2.8.2
pyyaml==6.0.1
requests==2.31.0
respx==0.19.2
rfc3986==1.5.0
ruff==0.0.282
six==1.16.0
sniffio==1.3.0
time-machine==2.9.0
tokenizers==0.14.0
tomli==2.0.1
tqdm==4.66.1
typing-extensions==4.8.0
urllib3==2.0.6
virtualenv==20.24.5
# The following packages are considered to be unsafe in a requirements file:
setuptools==68.2.2
33 changes: 33 additions & 0 deletions requirements.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# generated by rye
# use `rye lock` or `rye sync` to update this lockfile
#
# last locked with the following flags:
# pre: false
# features: []
# all-features: true

-e file:.
annotated-types==0.6.0
anyio==3.7.1
certifi==2023.7.22
charset-normalizer==3.3.0
distro==1.8.0
exceptiongroup==1.1.3
filelock==3.12.4
fsspec==2023.9.2
h11==0.12.0
httpcore==0.15.0
httpx==0.23.0
huggingface-hub==0.16.4
idna==3.4
packaging==23.2
pydantic==2.4.2
pydantic-core==2.10.1
pyyaml==6.0.1
requests==2.31.0
rfc3986==1.5.0
sniffio==1.3.0
tokenizers==0.14.0
tqdm==4.66.1
typing-extensions==4.8.0
urllib3==2.0.6
3 changes: 1 addition & 2 deletions src/anthropic/_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@

import pydantic
import pydantic.generics
from pydantic import Extra
from pydantic.fields import FieldInfo

from ._types import (
Expand Down Expand Up @@ -56,7 +55,7 @@ def model_fields_set(self) -> set[str]:
return self.__fields_set__ # type: ignore

class Config(pydantic.BaseConfig): # pyright: ignore[reportDeprecated]
extra: Any = Extra.allow # type: ignore
extra: Any = pydantic.Extra.allow # type: ignore

def __str__(self) -> str:
# mypy complains about an invalid self arg
Expand Down

0 comments on commit 1dd605e

Please sign in to comment.