Skip to content

Commit 5dc922f

Browse files
committed
Cleanup dev setup
- Removes buildout; test_layer now fetches the crate package itself - Removes setup.py - Removes stale bin/test - Removes stale requirements.txt - Updates DEVELOP.rst - Removes poethepoet. Most python developers are familiar with `ruff`, `mypy` and `pytest`, no need to add an extra DSL on top that obfuscates what's being used. - Removes `bootstrap.sh`. `python -m venv` or `uv venv` are trivial enough and Python developers should be familiar with them. - Removes the `devtools/create_tag.sh` script. It used `python setup.py --version` to get the new version, which since #757 was broken - running into a chicken and egg problem: Can't read the version from git when about to create a new version tag. Must use `git tag -s <version>` instead. - Updates the release job. It used `python -m build`, which wasn't specified as dependency anywhere. `hatch` is now used which `uv build` will pickup.
1 parent e54841b commit 5dc922f

File tree

15 files changed

+146
-585
lines changed

15 files changed

+146
-585
lines changed

.github/workflows/docs.yml

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1+
---
12
name: docs
2-
33
on:
44
workflow_dispatch:
55
pull_request: ~
@@ -13,6 +13,11 @@ concurrency:
1313
group: ${{ github.workflow }}-${{ github.ref }}
1414
cancel-in-progress: true
1515

16+
permissions:
17+
contents: read
18+
checks: write
19+
statuses: write
20+
1621
jobs:
1722
documentation:
1823

@@ -22,13 +27,20 @@ jobs:
2227
steps:
2328
- name: Acquire sources
2429
uses: actions/checkout@v6
30+
with:
31+
persist-credentials: false
2532

26-
- name: Set up Python
27-
uses: actions/setup-python@v6
33+
- name: Set up uv
34+
uses: astral-sh/setup-uv@v7
2835
with:
29-
python-version: '3.12'
30-
cache: 'pip'
31-
cache-dependency-path: 'setup.py'
36+
cache-dependency-glob: |
37+
pyproject.toml
38+
enable-cache: true
39+
activate-environment: true
40+
version: "latest"
41+
42+
- name: Setup env
43+
run: uv pip install --group docs
3244

3345
- name: Build docs
3446
run: |

.github/workflows/nightly.yml

Lines changed: 0 additions & 62 deletions
This file was deleted.

.github/workflows/release.yml

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,11 @@ name: release
33

44
on: push
55

6+
permissions:
7+
contents: read
8+
checks: write
9+
statuses: write
10+
611
jobs:
712
pypi:
813
name: Build & publish package to pypi
@@ -15,11 +20,8 @@ jobs:
1520
if: startsWith(github.event.ref, 'refs/tags')
1621
steps:
1722
- uses: actions/checkout@v6
18-
19-
- name: Set up Python
20-
uses: actions/setup-python@v6
2123
with:
22-
python-version: ${{ matrix.python-version }}
24+
persist-credentials: false
2325

2426
- name: Set up uv
2527
uses: astral-sh/setup-uv@v7
@@ -31,10 +33,7 @@ jobs:
3133
version: "latest"
3234

3335
- name: Build package
34-
run: |
35-
uv pip install --system build twine wheel
36-
python -m build
37-
twine check dist/*
36+
run: uv build
3837

3938
- name: Publish package to PyPI
4039
uses: pypa/gh-action-pypi-publish@release/v1

.github/workflows/tests.yml

Lines changed: 24 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,24 @@
1+
---
12
name: Tests
23

34
on:
45
push:
5-
branches: [ main ]
6+
branches:
7+
- main
68
pull_request: ~
79
workflow_dispatch:
10+
schedule:
11+
- cron: '0 2 * * *'
812

913
concurrency:
1014
group: ${{ github.workflow }}-${{ github.ref }}
1115
cancel-in-progress: true
1216

17+
permissions:
18+
contents: read
19+
checks: write
20+
statuses: write
21+
1322
jobs:
1423
test:
1524
name: "Python: ${{ matrix.python-version }}
@@ -19,32 +28,24 @@ jobs:
1928
fail-fast: false
2029
matrix:
2130
os: ['ubuntu-22.04']
22-
python-version: ['3.9', '3.10', '3.11', '3.12', '3.13', '3.14']
23-
cratedb-version: ['nightly']
31+
python-version: ['3.10', '3.11', '3.12', '3.13', '3.14']
2432

25-
# To save resources, only verify the most recent Python versions on macOS.
33+
# Save resources - only verify the most recent Python versions on macOS.
2634
include:
2735
- os: 'macos-latest'
28-
cratedb-version: '5.9.2'
2936
python-version: '3.11'
3037
- os: 'macos-latest'
31-
cratedb-version: '5.9.2'
3238
python-version: '3.12'
3339
- os: 'macos-latest'
34-
cratedb-version: '5.9.2'
3540
python-version: '3.13'
3641

3742
env:
38-
CRATEDB_VERSION: ${{ matrix.cratedb-version }}
3943
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
4044

4145
steps:
4246
- uses: actions/checkout@v6
43-
44-
- name: Set up Python
45-
uses: actions/setup-python@v6
4647
with:
47-
python-version: ${{ matrix.python-version }}
48+
persist-credentials: false
4849

4950
- name: Set up uv
5051
uses: astral-sh/setup-uv@v7
@@ -53,30 +54,24 @@ jobs:
5354
pyproject.toml
5455
cache-suffix: ${{ matrix.python-version }}
5556
enable-cache: true
57+
activate-environment: true
5658
version: "latest"
5759

5860
- name: Setup env
59-
run: uv sync
61+
run: uv pip install --group dev .
6062

61-
- name: Invoke tests
63+
- name: Run Linters
6264
run: |
63-
64-
# Propagate build matrix information.
65-
./devtools/setup_ci.sh
66-
67-
# Bootstrap environment.
68-
source bootstrap.sh
65+
ruff check .
66+
mypy
6967
70-
# Report about the test matrix slot.
71-
echo "Invoking tests with CrateDB ${CRATEDB_VERSION}"
72-
73-
# Run linter.
74-
poe lint
75-
76-
# Run tests.
77-
poe test
68+
- name: Run tests
69+
run: |
70+
coverage run -m pytest
71+
coverage combine
72+
coverage xml
73+
coverage report
7874
79-
# https://github.com/codecov/codecov-action
8075
- name: Upload coverage results to Codecov
8176
uses: codecov/codecov-action@v5
8277
env:

DEVELOP.rst

Lines changed: 24 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -5,95 +5,49 @@ CrateDB Python developer guide
55
Setup
66
=====
77

8-
Optionally install Python package and project manager `uv`_,
9-
in order to significantly speed up the package installation::
10-
11-
{apt,brew,pip,zypper} install uv
12-
alias pip="uv pip"
13-
14-
To start things off, bootstrap the sandbox environment::
8+
Clone the repository::
159

1610
git clone https://github.com/crate/crate-python
1711
cd crate-python
18-
source bootstrap.sh
19-
20-
This command should automatically install all prerequisites for the development
21-
sandbox and drop you into the virtualenv, ready for invoking further commands.
22-
23-
24-
Running tests
25-
=============
26-
27-
All tests will be invoked using the Python interpreter that was used when
28-
creating the Python virtualenv. The test runner is `zope.testrunner`_.
29-
30-
Some examples are outlined below. In order to learn about more details,
31-
see, for example, `useful command-line options for zope-testrunner`_.
32-
33-
Run all tests::
3412

35-
poe test
13+
Setup a virtualenv and install the package::
3614

37-
Run specific tests::
15+
python -m venv .venv
16+
source .venv/bin/activate
17+
python -m pip install --group dev --group docs -e .
3818

39-
# Select modules.
40-
bin/test -t test_cursor
41-
bin/test -t client
42-
bin/test -t testing
19+
Or if using `uv`_::
4320

44-
# Select doctests.
45-
bin/test -t http.rst
21+
uv venv .venv
22+
source .venv/bin/activate
23+
uv pip install --group dev --group docs -e .
4624

47-
Ignore specific test directories::
4825

49-
bin/test --ignore_dir=testing
50-
51-
The ``LayerTest`` test cases have quite some overhead. Omitting them will save
52-
a few cycles (~70 seconds runtime)::
53-
54-
bin/test -t '!LayerTest'
55-
56-
Invoke all tests without integration tests (~10 seconds runtime)::
57-
58-
bin/test --layer '!crate.testing.layer.crate' --test '!LayerTest'
59-
60-
Yet ~60 test cases, but only ~1 second runtime::
26+
Running tests
27+
=============
6128

62-
bin/test --layer '!crate.testing.layer.crate' --test '!LayerTest' \
63-
-t '!test_client_threaded' -t '!test_no_retry_on_read_timeout' \
64-
-t '!test_wait_for_http' -t '!test_table_clustered_by'
29+
Ensure the virtualenv is active and run tests using `pytest`_::
6530

66-
To inspect the whole list of test cases, run::
31+
python -m pytest
6732

68-
bin/test --list-tests
6933

70-
The CI setup on GitHub Actions (GHA) provides a full test matrix covering
71-
relevant Python versions. You can invoke the software tests against a specific
72-
Python interpreter or multiple `Python versions`_ on your workstation using
73-
`uv`_, by supplying the ``--python`` command-line option, or by defining the
74-
`UV_PYTHON`_ environment variable prior to invoking ``source bootstrap.sh``.
34+
See also:
7535

76-
*Note*: Before running the tests, make sure to stop all CrateDB instances which
77-
are listening on the default CrateDB transport port to avoid side effects with
78-
the test layer.
36+
- `How to invoke pytest <https://docs.pytest.org/en/stable/how-to/usage.html>` for more information.
7937

8038

8139
Formatting and linting code
8240
===========================
8341

84-
To use Ruff for code formatting, according to the standards configured in
85-
``pyproject.toml``, use::
86-
87-
poe format
88-
89-
To lint the code base using Ruff and mypy, use::
42+
Use `ruff`_ for code formatting and linting::
9043

91-
poe lint
44+
ruff format --check .
45+
ruff check .
9246

93-
Linting and software testing, all together now::
9447

95-
poe check
48+
Use ``mypy`` for type checking::
9649

50+
mypy
9751

9852
Renew certificates
9953
==================
@@ -120,8 +74,8 @@ In the release branch:
12074

12175
- Push to origin/<release_branch>
12276

123-
- Create a tag by running ``./devtools/create_tag.sh``. This will trigger a
124-
Github action which releases the new version to PyPi.
77+
- Create a tag by running ``git tag -s <version>`` and push it ``git push --tags``.
78+
This will trigger a Github action which releases the new version to PyPi.
12579

12680
On branch ``main``:
12781

@@ -147,7 +101,7 @@ Writing documentation
147101

148102
The docs live under the ``docs`` directory.
149103

150-
The docs are written written with ReStructuredText_ and processed with Sphinx_.
104+
The docs are written with ReStructuredText_ and processed with Sphinx_.
151105

152106
Build the docs by running::
153107

@@ -171,4 +125,4 @@ nothing special you need to do to get the live docs to update.
171125
.. _uv: https://docs.astral.sh/uv/
172126
.. _UV_PYTHON: https://docs.astral.sh/uv/configuration/environment/#uv_python
173127
.. _versions hosted on ReadTheDocs: https://readthedocs.org/projects/crate-python/versions/
174-
.. _zope.testrunner: https://pypi.org/project/zope.testrunner/
128+
.. _pytest: https://docs.pytest.org/en/stable/

0 commit comments

Comments
 (0)