Skip to content

Commit

Permalink
chore: Stop using nox-poetry (#2713)
Browse files Browse the repository at this point in the history
* chore: Stop using `nox-poetry`

* Avoid unnecessarily installing Poetry
  • Loading branch information
edgarrmondragon authored Oct 9, 2024
1 parent 7068e19 commit b22ed49
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 83 deletions.
1 change: 0 additions & 1 deletion .github/workflows/api-changes.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ jobs:
run: |
python -Im pip install -U pip
pipx install griffe nox
pipx inject nox nox-poetry
pipx list
- name: Set REF
Expand Down
3 changes: 0 additions & 3 deletions .github/workflows/constraints.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
griffe==1.3.2
pip==24.2
poetry==1.8.3
poetry-plugin-export==1.8.0
poetry-dynamic-versioning==1.4.1
pre-commit==4.0.0
nox==2024.4.15
nox-poetry==1.0.3
3 changes: 0 additions & 3 deletions .github/workflows/cookiecutter-e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,7 @@ jobs:
PIP_CONSTRAINT: ${{ github.workspace }}/.github/workflows/constraints.txt
run: |
pipx install poetry
pipx inject poetry poetry-plugin-export
poetry --version
poetry self show plugins
- uses: actions/setup-python@v5
with:
Expand All @@ -67,7 +65,6 @@ jobs:
PIP_CONSTRAINT: ${{ github.workspace }}/.github/workflows/constraints.txt
run: |
pipx install nox
pipx inject nox nox-poetry
nox --version
- name: Run Nox
Expand Down
33 changes: 0 additions & 33 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,16 +61,6 @@ jobs:
with:
fetch-depth: 0

- name: Install Poetry
env:
PIP_CONSTRAINT: ${{ github.workspace }}/.github/workflows/constraints.txt
run: |
pipx install poetry
pipx inject poetry poetry-plugin-export
pipx inject poetry poetry-dynamic-versioning[plugin]
poetry --version
poetry self show plugins
- uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
Expand All @@ -87,7 +77,6 @@ jobs:
PIP_CONSTRAINT: ${{ github.workspace }}/.github/workflows/constraints.txt
run: |
pipx install 'nox[uv]'
pipx inject nox nox-poetry
nox --version
- uses: actions/cache@v4
Expand Down Expand Up @@ -126,16 +115,6 @@ jobs:
with:
fetch-depth: 0

- name: Install Poetry
env:
PIP_CONSTRAINT: ${{ github.workspace }}/.github/workflows/constraints.txt
run: |
pipx install poetry
pipx inject poetry poetry-plugin-export
pipx inject poetry poetry-dynamic-versioning[plugin]
poetry --version
poetry self show plugins
- uses: actions/setup-python@v5
with:
python-version: ${{ env.NOXPYTHON }}
Expand All @@ -152,7 +131,6 @@ jobs:
PIP_CONSTRAINT: ${{ github.workspace }}/.github/workflows/constraints.txt
run: |
pipx install 'nox[uv]'
pipx inject nox nox-poetry
nox --version
- name: Run Nox
Expand All @@ -167,16 +145,6 @@ jobs:
NOXSESSION: coverage
steps:
- uses: actions/checkout@v4

- name: Install Poetry
env:
PIP_CONSTRAINT: ${{ github.workspace }}/.github/workflows/constraints.txt
run: |
pipx install poetry
pipx inject poetry poetry-plugin-export
poetry --version
poetry self show plugins
- uses: actions/setup-python@v5
with:
python-version: '3.12'
Expand All @@ -198,7 +166,6 @@ jobs:
PIP_CONSTRAINT: ${{ github.workspace }}/.github/workflows/constraints.txt
run: |
pipx install 'nox[uv]'
pipx inject nox nox-poetry
nox --version
- run: nox --install-only
Expand Down
1 change: 0 additions & 1 deletion docs/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ With `pipx` installed, you globally add the required tools:
pipx install poetry
pipx install pre-commit
pipx install nox
pipx inject nox nox-poetry
```

Now you can use Poetry to install package dependencies:
Expand Down
66 changes: 24 additions & 42 deletions noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,9 @@
import sys
import tempfile
from pathlib import Path
from textwrap import dedent

import nox

try:
from nox_poetry import Session, session
except ImportError:
message = f"""\
Nox failed to import the 'nox-poetry' package.
Please install it using the following command:
{sys.executable} -m pip install nox-poetry"""
raise SystemExit(dedent(message)) from None

nox.needs_version = ">=2024.4.15"
nox.options.default_venv_backend = "uv|virtualenv"

Expand Down Expand Up @@ -49,8 +39,8 @@
typing_dependencies = poetry_config["group"]["typing"]["dependencies"].keys()


@session(python=main_python_version)
def mypy(session: Session) -> None:
@nox.session(python=main_python_version)
def mypy(session: nox.Session) -> None:
"""Check types with mypy."""
args = session.posargs or ["singer_sdk"]
session.install(".[faker,jwt,parquet,s3,testing]")
Expand All @@ -60,19 +50,15 @@ def mypy(session: Session) -> None:
session.run("mypy", f"--python-executable={sys.executable}", "noxfile.py")


@session(python=python_versions)
def tests(session: Session) -> None:
@nox.session(python=python_versions)
def tests(session: nox.Session) -> None:
"""Execute pytest tests and compute coverage."""
session.install(".[faker,jwt,parquet,s3]")
session.install(*test_dependencies)

sqlalchemy_version = os.environ.get("SQLALCHEMY_VERSION")
if sqlalchemy_version:
# Bypass nox-poetry use of --constraint so we can install a version of
# SQLAlchemy that doesn't match what's in poetry.lock.
session.poetry.session.install( # type: ignore[attr-defined]
f"sqlalchemy=={sqlalchemy_version}.*",
)
session.install(f"sqlalchemy=={sqlalchemy_version}.*")

env = {"COVERAGE_CORE": "sysmon"} if session.python == "3.12" else {}

Expand All @@ -93,18 +79,14 @@ def tests(session: Session) -> None:
session.notify("coverage", posargs=[])


@session(python=main_python_version)
def benches(session: Session) -> None:
@nox.session(python=main_python_version)
def benches(session: nox.Session) -> None:
"""Run benchmarks."""
session.install(".[jwt,s3]")
session.install(*test_dependencies)
sqlalchemy_version = os.environ.get("SQLALCHEMY_VERSION")
if sqlalchemy_version:
# Bypass nox-poetry use of --constraint so we can install a version of
# SQLAlchemy that doesn't match what's in poetry.lock.
session.poetry.session.install( # type: ignore[attr-defined]
f"sqlalchemy=={sqlalchemy_version}",
)
session.install(f"sqlalchemy=={sqlalchemy_version}")
session.run(
"pytest",
"--benchmark-only",
Expand All @@ -113,16 +95,16 @@ def benches(session: Session) -> None:
)


@session(name="deps", python=python_versions)
def dependencies(session: Session) -> None:
@nox.session(name="deps", python=python_versions)
def dependencies(session: nox.Session) -> None:
"""Check issues with dependencies."""
session.install(".[s3,testing]")
session.install("deptry")
session.run("deptry", "singer_sdk", *session.posargs)


@session(python=main_python_version)
def update_snapshots(session: Session) -> None:
@nox.session(python=main_python_version)
def update_snapshots(session: nox.Session) -> None:
"""Update pytest snapshots."""
args = session.posargs or ["-m", "snapshot"]

Expand All @@ -131,8 +113,8 @@ def update_snapshots(session: Session) -> None:
session.run("pytest", "--snapshot-update", *args)


@session(python=python_versions)
def doctest(session: Session) -> None:
@nox.session(python=python_versions)
def doctest(session: nox.Session) -> None:
"""Run examples with xdoctest."""
if session.posargs:
args = [package, *session.posargs]
Expand All @@ -146,8 +128,8 @@ def doctest(session: Session) -> None:
session.run("pytest", "--xdoctest", *args)


@session(python=main_python_version)
def coverage(session: Session) -> None:
@nox.session(python=main_python_version)
def coverage(session: nox.Session) -> None:
"""Generate coverage report."""
args = session.posargs or ["report", "-m"]

Expand All @@ -159,8 +141,8 @@ def coverage(session: Session) -> None:
session.run("coverage", *args)


@session(name="docs", python=main_python_version)
def docs(session: Session) -> None:
@nox.session(name="docs", python=main_python_version)
def docs(session: nox.Session) -> None:
"""Build the documentation."""
args = session.posargs or ["docs", "build", "-W"]
if not session.posargs and "FORCE_COLOR" in os.environ:
Expand All @@ -175,8 +157,8 @@ def docs(session: Session) -> None:
session.run("sphinx-build", *args)


@session(name="docs-serve", python=main_python_version)
def docs_serve(session: Session) -> None:
@nox.session(name="docs-serve", python=main_python_version)
def docs_serve(session: nox.Session) -> None:
"""Build the documentation."""
args = session.posargs or [
"--open-browser",
Expand All @@ -198,8 +180,8 @@ def docs_serve(session: Session) -> None:


@nox.parametrize("replay_file_path", COOKIECUTTER_REPLAY_FILES)
@session(python=main_python_version)
def test_cookiecutter(session: Session, replay_file_path: str) -> None:
@nox.session(python=main_python_version)
def test_cookiecutter(session: nox.Session, replay_file_path: str) -> None:
"""Uses the tap template to build an empty cookiecutter.
Runs the lint task on the created test project.
Expand Down Expand Up @@ -261,8 +243,8 @@ def test_cookiecutter(session: Session, replay_file_path: str) -> None:
session.run("pre-commit", "run", "--all-files", external=True)


@session(name="version-bump")
def version_bump(session: Session) -> None:
@nox.session(name="version-bump")
def version_bump(session: nox.Session) -> None:
"""Run commitizen."""
session.install(
"commitizen",
Expand Down

0 comments on commit b22ed49

Please sign in to comment.