Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Transition from Poetry to UV #334

Closed
wants to merge 14 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions .github/workflows/deploy_docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,16 @@ jobs:
contents: write
steps:
- uses: actions/checkout@v4
- run: pipx install poetry
- name: Set up Python
uses: actions/setup-python@v5
- name: Set up uv
uses: astral-sh/setup-uv@v2
with:
python-version: "3.10"
cache: "poetry"
- run: poetry install
- run: poetry run mkdocs build
uv-version: latest
- name: Install dependencies
run: uv sync --all-extras --dev
- name: Build documentation
run: uv run mkdocs build
- name: Deploy to GitHub Pages
uses: peaceiris/actions-gh-pages@v4
with:
Expand Down
12 changes: 7 additions & 5 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,15 @@ jobs:
id-token: write # Required for trusted publishing to PyPI
steps:
- uses: actions/checkout@v4
- run: pipx install poetry
- name: Set up Python
uses: actions/setup-python@v5
- name: Set up uv
uses: astral-sh/setup-uv@v2
with:
python-version: "3.10"
cache: "poetry"
- run: poetry install
- run: poetry build
uv-version: latest
- name: Install dependencies
run: uv sync --all-extras --dev
- name: Build package
run: uv build
- name: Publish
uses: pypa/gh-action-pypi-publish@release/v1
27 changes: 13 additions & 14 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,38 +33,37 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: pipx install poetry
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.10"
cache: "poetry"
- run: poetry install --all-extras
- run: poetry run ruff check --output-format=github .
- run: poetry run ruff format --check .
- run: poetry run mypy .
- run: poetry run pytest -vv tests/
- name: Set up uv
uses: astral-sh/setup-uv@v2
- name: Install dependencies
run: uv sync --all-extras --dev
- run: uv run ruff check --output-format=github .
- run: uv run ruff format --check .
- run: uv run mypy .
- run: uv run pytest -vv tests/
# Do not use `github.event.inputs` because it converts booleans to strings
# https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#onworkflow_dispatchinputs
- if: inputs.anthropic
env:
ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }}
run: poetry run pytest -vv tests/ -m 'anthropic'
run: uv run pytest -vv tests/ -m 'anthropic'
- if: inputs.litellm_anthropic
env:
ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }}
run: poetry run pytest -vv tests/ -m 'litellm_anthropic'
run: uv run pytest -vv tests/ -m 'litellm_anthropic'
- if: inputs.litellm_openai
env:
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
OPENAI_ORG_ID: ${{ secrets.OPENAI_ORG_ID }}
run: poetry run pytest -vv tests/ -m 'litellm_openai'
run: uv run pytest -vv tests/ -m 'litellm_openai'
- if: inputs.mistral
env:
MISTRAL_API_KEY: ${{ secrets.MISTRAL_API_KEY }}
run: poetry run pytest -vv tests/ -m 'mistral'
run: uv run pytest -vv tests/ -m 'mistral'
- if: inputs.openai
env:
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
OPENAI_ORG_ID: ${{ secrets.OPENAI_ORG_ID }}
run: poetry run pytest -vv tests/ -m 'openai'
run: uv run pytest -vv tests/ -m 'openai'
1 change: 1 addition & 0 deletions .python-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.10
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ Easily integrate Large Language Models into your Python code. Simply use the `@p
pip install magentic
```

or using poetry
or using uv

```sh
poetry add magentic
uv add magentic
```

Configure your OpenAI API key by setting the `OPENAI_API_KEY` environment variable. To configure a different LLM provider see [Configuration] for more.
Expand Down
4 changes: 2 additions & 2 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ Easily integrate Large Language Models into your Python code. Simply use the `@p
pip install magentic
```

or using poetry
or using uv

```sh
poetry add magentic
uv add magentic
```

Configure your OpenAI API key by setting the `OPENAI_API_KEY` environment variable. To configure a different LLM provider see [Configuration] for more.
Expand Down
4,534 changes: 0 additions & 4,534 deletions poetry.lock

This file was deleted.

142 changes: 68 additions & 74 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,44 @@
[project]
name = "magentic"
version = "0.32.0"
description = "Seamlessly integrate LLMs as Python functions"
readme = "README.md"
requires-python = ">=3.10,<4.0"
dependencies = [
"filetype>=1.2.0",
"logfire-api>=0.1.0",
"openai>=1.40.0",
"pydantic>=2.7.0",
"pydantic-settings>=2.0.0",
]

[project.optional-dependencies]
anthropic = ["anthropic>=0.27.0"]
litellm = ["litellm>=1.41.12"]

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

[tool.uv]
dev-dependencies = [
"blacken-docs>=1.16.0",
"ghapi>=1.0.5",
"jupyter",
"logfire>=0.46.1,<0.50.0",
"mkdocs>=1.5.3",
"mkdocs-glightbox>=0.4.0",
"mkdocs-jupyter>=0.24.6",
"mkdocs-material>=9.5.11",
"mypy",
"pandas>=2.2.1",
"pytest>=7.0.0",
"pytest-asyncio>=0.18.0",
"pytest-clarity>=0.1.0",
"pytest-cov>=4.0.0",
"python-dotenv>=1.0.1",
"ruff>=0.3",
]

[tool.mypy]
check_untyped_defs = true
Expand All @@ -18,52 +56,6 @@ module = [
]
ignore_missing_imports = true

[tool.poetry]
name = "magentic"
version = "0.32.0"
description = "Seamlessly integrate LLMs as Python functions"
license = "MIT"
authors = ["Jack Collins"]
readme = "README.md"
homepage = "https://magentic.dev/"
repository = "https://github.com/jackmpcollins/magentic"

[tool.poetry.dependencies]
python = ">=3.10,<4.0"
anthropic = {version = ">=0.27.0", optional = true}
filetype = "*"
litellm = {version = ">=1.41.12", optional = true}
logfire-api = "*"
openai = ">=1.40.0"
pydantic = ">=2.7.0"
pydantic-settings = ">=2.0.0"

[tool.poetry.extras]
anthropic = ["anthropic"]
litellm = ["litellm"]

[tool.poetry.group.dev.dependencies]
blacken-docs = "^1.16.0"
logfire = ">=0.46.1,<0.50.0"
mypy = "*"
pytest = "*"
pytest-asyncio = "*"
pytest-clarity = "*"
pytest-cov = "*"
python-dotenv = "^1.0.1"
ruff = ">=0.3,<0.6"

[tool.poetry.group.docs.dependencies]
mkdocs = "^1.5.3"
mkdocs-glightbox = "^0.4.0"
mkdocs-jupyter = "^0.24.6"
mkdocs-material = "^9.5.11"

[tool.poetry.group.examples.dependencies]
ghapi = "^1.0.5"
jupyter = "*"
pandas = "^2.2.1"

[tool.pytest.ini_options]
addopts = "--cov=magentic --cov-report=term-missing -m 'not anthropic and not litellm_anthropic and not litellm_openai and not mistral and not litellm_ollama and not openai'"
markers = [
Expand All @@ -77,33 +69,35 @@ markers = [

[tool.ruff]
include = ["*.py", "*.pyi", "**/pyproject.toml", "*.ipynb"]
# Use `ruff linter` to list available linters
# https://beta.ruff.rs/docs/rules/

[tool.ruff.lint]
select = ["ALL"]
ignore = [
"C90", # mccabe
"D", # pydocstyle
"ANN", # flake8-annotations
"A", # flake8-builtins
"COM", # flake8-commas
"FA", # flake8-future-annotations
"INP", # flake8-no-pep420
"PIE790", # flake8-pie: Unnecessary `...` literal
"SLF", # flake8-self
"ARG", # flake8-unused-arguments
"TD", # flake8-todos
"FIX", # flake8-fixme
"PL", # Pylint
# Compatibility with ruff formatter
"E501",
"ISC001",
"Q000",
"Q001",
"Q002",
"Q003",
"W191",
"C90", # mccabe
"D", # pydocstyle
"ANN", # flake8-annotations
"A", # flake8-builtins
"COM", # flake8-commas
"FA", # flake8-future-annotations
"INP", # flake8-no-pep420
"PIE790", # flake8-pie: Unnecessary `...` literal
"SLF", # flake8-self
"ARG", # flake8-unused-arguments
"TD", # flake8-todos
"FIX", # flake8-fixme
"PL", # Pylint
# Compatibility with ruff formatter
"E501",
"ISC001",
"Q000",
"Q001",
"Q002",
"Q003",
"W191",
"B905", # TODO: Reenable this
"UP006", # TODO: Reenable this
"UP007", # TODO: Reenable this
"UP035", # TODO: Reenable this
]

[tool.ruff.lint.flake8-pytest-style]
Expand All @@ -114,11 +108,11 @@ known-first-party = ["magentic"]

[tool.ruff.lint.per-file-ignores]
"docs/examples/*" = [
"T20", # flake8-print
"T20", # flake8-print
]
"examples/*" = [
"T20", # flake8-print
"T20", # flake8-print
]
"tests/*" = [
"S", # flake8-bandit
"S", # flake8-bandit
]
Loading