Migrate from setup.py to pyproject.toml for uv compatibility

- Replace setup.py with pyproject.toml using uv_build backend
- Add dependency-groups.dev for test dependencies
- Configure flat layout with module-root = ""
- Fix pre-existing test failures (updated error message, optional mock)
- Add uv.lock and dist/ to .gitignore
- uv run pytest (39 passed) and uv build both work

https://claude.ai/code/session_01DoiJf9Gbvbw2asN9yvP6dx
This commit is contained in:
Claude 2026-02-12 00:14:34 +00:00
commit 9715510431
No known key found for this signature in database
4 changed files with 46 additions and 48 deletions

2
.gitignore vendored
View file

@ -7,3 +7,5 @@ venv
.pytest_cache
*.egg-info
.DS_Store
uv.lock
dist/

42
pyproject.toml Normal file
View file

@ -0,0 +1,42 @@
[project]
name = "dclient"
version = "0.4"
description = "A client CLI utility for Datasette instances"
readme = "README.md"
requires-python = ">=3.8"
license = "Apache-2.0"
authors = [{name = "Simon Willison"}]
dependencies = [
"click",
"httpx",
"sqlite-utils",
]
[project.urls]
Homepage = "https://github.com/simonw/dclient"
Issues = "https://github.com/simonw/dclient/issues"
CI = "https://github.com/simonw/dclient/actions"
Changelog = "https://github.com/simonw/dclient/releases"
[project.scripts]
dclient = "dclient.cli:cli"
[project.entry-points.datasette]
client = "dclient.plugin"
[dependency-groups]
dev = [
"pytest",
"pytest-asyncio",
"pytest-httpx",
"cogapp",
"pytest-mock",
"datasette>=1.0a2",
]
[build-system]
requires = ["uv_build>=0.9.18,<0.10.0"]
build-backend = "uv_build"
[tool.uv.build-backend]
module-root = ""

View file

@ -1,46 +0,0 @@
from setuptools import setup
import os
VERSION = "0.4"
def get_long_description():
with open(
os.path.join(os.path.dirname(os.path.abspath(__file__)), "README.md"),
encoding="utf8",
) as fp:
return fp.read()
setup(
name="dclient",
description="A client CLI utility for Datasette instances",
long_description=get_long_description(),
long_description_content_type="text/markdown",
author="Simon Willison",
url="https://github.com/simonw/dclient",
project_urls={
"Issues": "https://github.com/simonw/dclient/issues",
"CI": "https://github.com/simonw/dclient/actions",
"Changelog": "https://github.com/simonw/dclient/releases",
},
license="Apache License, Version 2.0",
version=VERSION,
packages=["dclient"],
entry_points={
"datasette": ["client = dclient.plugin"],
"console_scripts": ["dclient = dclient.cli:cli"],
},
install_requires=["click", "httpx", "sqlite-utils"],
extras_require={
"test": [
"pytest",
"pytest-asyncio",
"pytest-httpx",
"cogapp",
"pytest-mock",
"datasette>=1.0a2",
]
},
python_requires=">=3.8",
)

View file

@ -120,7 +120,7 @@ def make_format_test(content, arg):
input_data=SIMPLE_CSV,
cmd_args=[],
table_exists=False,
expected_output="Inserting rows\nError: Table not found: table1\n",
expected_output="Inserting rows\nError: Table not found\n",
should_error=True,
expected_table_json=None,
),
@ -296,7 +296,7 @@ def test_insert_against_datasette(
return loop.run_until_complete(run())
httpx_mock.add_callback(custom_response)
httpx_mock.add_callback(custom_response, is_optional=should_error)
path = pathlib.Path(tmpdir) / "data.txt"
if isinstance(input_data, str):