dependency-groups.dev and switch to uv in docs

This commit is contained in:
Simon Willison 2025-12-11 14:49:21 -08:00
commit 86290a1eac
5 changed files with 31 additions and 48 deletions

View file

@ -21,7 +21,7 @@ jobs:
cache-dependency-path: pyproject.toml cache-dependency-path: pyproject.toml
- name: Install dependencies - name: Install dependencies
run: | run: |
pip install -e '.[test]' pip install . --group dev
- name: Run tests - name: Run tests
run: | run: |
pytest pytest

View file

@ -24,7 +24,7 @@ jobs:
- name: Install Python dependencies - name: Install Python dependencies
run: | run: |
python -m pip install --upgrade pip python -m pip install --upgrade pip
python -m pip install -e .[test] python -m pip install . --group dev
python -m pip install pytest-cov python -m pip install pytest-cov
- name: Run tests - name: Run tests
run: |- run: |-

View file

@ -34,7 +34,7 @@ jobs:
- run: python3 -c "import sqlite3; print(sqlite3.sqlite_version)" - run: python3 -c "import sqlite3; print(sqlite3.sqlite_version)"
- name: Install dependencies - name: Install dependencies
run: | run: |
pip install -e '.[test]' pip install . --group dev
pip freeze pip freeze
- name: Run tests - name: Run tests
run: | run: |

View file

@ -13,49 +13,41 @@ All improvements to the software should start with an issue. Read `How I build a
Obtaining the code Obtaining the code
================== ==================
To work on this library locally, first checkout the code. Then create a new virtual environment:: To work on this library locally, first checkout the code.
git clone git@github.com:simonw/sqlite-utils git clone git@github.com:simonw/sqlite-utils
cd sqlite-utils cd sqlite-utils
python3 -mvenv venv
source venv/bin/activate
Or if you are using ``pipenv``:: Use `uv run` to run the development version of the tool:
pipenv shell uv run sqlite-utils --help
Within the virtual environment running ``sqlite-utils`` should run your locally editable version of the tool. You can use ``which sqlite-utils`` to confirm that you are running the version that lives in your virtual environment.
.. _contributing_tests: .. _contributing_tests:
Running the tests Running the tests
================= =================
To install the dependencies and test dependencies:: Use `uv run` to run the tests:
pip install -e '.[test]' uv run pytest
To run the tests::
pytest
.. _contributing_docs: .. _contributing_docs:
Building the documentation Building the documentation
========================== ==========================
To build the documentation, first install the documentation dependencies:: To build the documentation run this command::
pip install -e '.[docs]' uv run make livehtml --directory docs
Then run ``make livehtml`` from the ``docs/`` directory to start a server on port 8000 that will serve the documentation and live-reload any time you make an edit to a ``.rst`` file:: This will start a server on port 8000 that will serve the documentation and live-reload any time you make an edit to a ``.rst`` file.
cd docs cd docs
make livehtml make livehtml
The `cog <https://github.com/nedbat/cog>`__ tool is used to maintain portions of the documentation. You can run it like so:: The `cog <https://github.com/nedbat/cog>`__ tool is used to maintain portions of the documentation. You can run it like so::
cog -r docs/*.rst uv run cog -r docs/*.rst
.. _contributing_linting: .. _contributing_linting:
@ -64,18 +56,12 @@ Linting and formatting
``sqlite-utils`` uses `Black <https://black.readthedocs.io/>`__ for code formatting, and `flake8 <https://flake8.pycqa.org/>`__ and `mypy <https://mypy.readthedocs.io/>`__ for linting and type checking. ``sqlite-utils`` uses `Black <https://black.readthedocs.io/>`__ for code formatting, and `flake8 <https://flake8.pycqa.org/>`__ and `mypy <https://mypy.readthedocs.io/>`__ for linting and type checking.
Black is installed as part of ``pip install -e '.[test]'`` - you can then format your code by running it in the root of the project:: uv run black .
black . Linting tools can be run like this::
To install ``mypy`` and ``flake8`` run the following:: uv run flake8
uv run mypy sqlite_utils
pip install -e '.[flake8,mypy]'
Both commands can then be run in the root of the project like this::
flake8
mypy sqlite_utils
All three of these tools are run by our CI mechanism against every commit and pull request. All three of these tools are run by our CI mechanism against every commit and pull request.

View file

@ -31,6 +31,31 @@ dependencies = [
"pip", "pip",
] ]
[dependency-groups]
dev = [
"black>=24.1.1",
"cogapp",
"hypothesis",
"pytest",
# docs
"beanbag-docutils>=2.0",
"codespell",
"furo",
"pygments-csv-lexer",
"sphinx-autobuild",
"sphinx-copybutton",
# mypy
"data-science-types",
"mypy",
"types-click",
"types-pluggy",
"types-python-dateutil",
"types-tabulate",
# flake8
"flake8",
"flake8-pyproject",
]
[project.urls] [project.urls]
Homepage = "https://github.com/simonw/sqlite-utils" Homepage = "https://github.com/simonw/sqlite-utils"
Documentation = "https://sqlite-utils.datasette.io/en/stable/" Documentation = "https://sqlite-utils.datasette.io/en/stable/"
@ -41,34 +66,6 @@ CI = "https://github.com/simonw/sqlite-utils/actions"
[project.scripts] [project.scripts]
sqlite-utils = "sqlite_utils.cli:cli" sqlite-utils = "sqlite_utils.cli:cli"
[project.optional-dependencies]
test = [
"black>=24.1.1",
"cogapp",
"hypothesis",
"pytest",
]
docs = [
"beanbag-docutils>=2.0",
"codespell",
"furo",
"pygments-csv-lexer",
"sphinx-autobuild",
"sphinx-copybutton",
]
mypy = [
"data-science-types",
"mypy",
"types-click",
"types-pluggy",
"types-python-dateutil",
"types-tabulate",
]
flake8 = [
"flake8",
"flake8-pyproject",
]
[build-system] [build-system]
requires = ["setuptools"] requires = ["setuptools"]
build-backend = "setuptools.build_meta" build-backend = "setuptools.build_meta"