Skip to content
Merged
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
30 changes: 10 additions & 20 deletions .github/workflows/check-lockfile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,34 +2,24 @@ name: Check lockfile

on:
push:
paths-ignore:
- 'docs/**'
- '**/*.md'
paths:
- pyproject.toml
- uv.lock
pull_request:
paths-ignore:
- 'docs/**'
- '**/*.md'
paths:
- pyproject.toml
- uv.lock

jobs:
check-lockfile:
runs-on: ubuntu-latest

strategy:
fail-fast: false

steps:
- uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.12'
cache: 'pip'
- uses: actions/checkout@v6

- name: Install poetry
run: |
pipx install poetry
- name: Install uv
uses: astral-sh/setup-uv@v7

- name: Check lockfile
run: |
poetry check --lock
uv lock --check
21 changes: 11 additions & 10 deletions .github/workflows/linting.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,21 @@ jobs:
lint:
runs-on: ubuntu-latest

strategy:
fail-fast: false

steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v6

- name: Install uv
uses: astral-sh/setup-uv@v7
with:
enable-cache: true

- name: Set up Python
uses: actions/setup-python@v5
uses: actions/setup-python@v6
with:
python-version: '3.12'
cache: 'pip'
python-version: '3.13'

- name: Lint with ruff
run: |
pip install ruff
ruff check python/target_selection
ruff format --check python/target_selection
uv tool install ruff
ruff check src/ tests/
ruff format --check src/ tests/
34 changes: 14 additions & 20 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,26 +1,23 @@
name: Create Release

on:
push:
tags:
- '*'

name: Create Release

jobs:
release:
name: Build wheels
runs-on: ubuntu-latest
name: Build and publish

strategy:
matrix:
python-version: ['3.12']
runs-on: ubuntu-24.04

permissions:
contents: write
id-token: write

steps:
- name: Checkout code
uses: actions/checkout@v4
uses: actions/checkout@v6

- name: Create release
uses: taiki-e/create-gh-release-action@v1
Expand All @@ -29,22 +26,19 @@ jobs:
changelog: CHANGELOG.md
token: ${{ secrets.GITHUB_TOKEN }}

- name: Set up Python
uses: actions/setup-python@v5
- name: Install uv
uses: astral-sh/setup-uv@v7
with:
python-version: ${{ matrix.python-version }}
enable-cache: true

- name: Install dependencies
run: |
python -m pip install --upgrade pip setuptools wheel build

- name: Build wheels
run: |
pyproject-build -w
- name: Set up Python
uses: actions/setup-python@v6
with:
python-version: '3.13'

- name: Build source
- name: Build source and dist
run: |
pyproject-build -s
uv build

- name: Publish package distributions to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
25 changes: 17 additions & 8 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,23 +17,32 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: ['3.10', '3.11', '3.12']
python-version: ['3.11', '3.12', '3.13', '3.14']

steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v6

- name: Set up Python
uses: actions/setup-python@v5
uses: actions/setup-python@v6
with:
python-version: ${{ matrix.python-version }}
cache: 'pip'

- name: Install uv
uses: astral-sh/setup-uv@v7
with:
enable-cache: true

- name: Install dependencies
run: |
pip install --upgrade wheel pip setuptools
pip install .
uv sync --python ${{ matrix.python-version }} --no-dev --frozen

- name: Test with pytest
run: |
pip install pytest pytest-mock pytest-cov
pytest tests/
uv sync --frozen --group dev
uv run pytest

- name: Upload coverage to Codecov
uses: codecov/codecov-action@v5
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: ./coverage.xml
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
# Changelog

## Next release

### 🔥 Breaking changes

* [#513](https://github.com/sdss/target_selection/pull/513) Drop support for Python 3.10.

### ⚙️ Engineering

* [#513](https://github.com/sdss/target_selection/pull/513) Update package management internals with `uv` (replacing `poetry`), update workflows, fix issues with the RTDs build, and update the `README.md` with instructions for development.


## 1.4.4 - October 18, 2025

### 🔧 Fixed
Expand Down
2 changes: 0 additions & 2 deletions MANIFEST.in

This file was deleted.

104 changes: 47 additions & 57 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@ pip install .

This code adheres to the [SDSS Coding Standards](https://sdss-python-template.readthedocs.io/en/latest/standards.html).

We use [poetry](https://python-poetry.org) as the PEP517 backend and for dependency specification and resolution. To install `poetry` follow [these instructions](https://python-poetry.org/docs/#installation). The you can install the project for development with
We use [uv](https://docs.astral.sh/uv/) for dependency specification and resolution. To install `uv` follow [these instructions](https://docs.astral.sh/uv/getting-started/installation/). Then you can install the project for development with

```console
cd target_selection
poetry install
uv sync --group dev
```

Note that as long as you don't need to install or update dependencies you can still install `target_selection` in editable mode with
Expand All @@ -38,66 +38,65 @@ Note that as long as you don't need to install or update dependencies you can st
pip install -e .
```

(this will *not* install the development packages under the `dev` dependencies group, those need to be manually pip-installed in this case). Please, **do not add new dependencies without updating the `poetry.lock` file**. One of the workflows that run on commit will check that the lockfile is still valid.
(this will *not* install the development packages under the `dev` dependency group, those need to be manually pip-installed in this case). Please, **do not add new dependencies without updating the `uv.lock` file**. One of the workflows that run on commit will check that the lockfile is still valid.

We use [ruff](https://docs.astral.sh/ruff/) for both linting, import sorting, and code formatting. The configuration is stored in `pyproject.toml` and it's mainly the default `ruff` configuration (and similar to `flake8`) but with a line length of 99 characters for historical reasons and because it simplifies writing long Peewee/SQLAlchemy query statements. The formatting is similar to [black](https://github.com/psf/black), and thus quite opinionated.

A workflow checks for linting and formatting errors on each commit, and pull requests are blocked until the workflow succeeds. The easiest way to fix these problems is by installing `ruff` and letting it format the code, and then checking if any linting errors remain. The commands `ruff format` and `ruff check` are independent and both must be run.

```console
$ pip install ruff
$ ruff format ./python/
$ uv tool install ruff
$ ruff format ./src/
1 file reformatted, 46 files left unchanged
$ ruff check ./python/
$ ruff check ./src/
All checks passed!
```

Updating the package version can be done directly in the `pyproject.toml` file and doesn't require having `poetry` installed or otherwise updating the lockfile.
[ty](https://docs.astral.sh/ty/) is the recommended type checker.

### Visual Studio Code configuration

If using Visual Studio Code, it is recommended to install the [ruff](https://marketplace.visualstudio.com/items?itemName=charliermarsh.ruff) and [prettier](https://marketplace.visualstudio.com/items?itemName=esbenp.prettier-vscode) extensions. Then you can create a workspace file inside the cloned repo, under `.vscode/settings.json` with the following configuration

```json
{
"[python]": {
"editor.formatOnSave": true,
"editor.codeActionsOnSave": {
"source.fixAll": "explicit",
"source.organizeImports.ruff": "explicit"
},
"editor.wordWrap": "off",
"editor.tabSize": 4,
"editor.defaultFormatter": "charliermarsh.ruff"
"[python]": {
"editor.formatOnSave": true,
"editor.codeActionsOnSave": {
"source.fixAll": "explicit",
"source.organizeImports.ruff": "explicit"
},
"[markdown]": {
"editor.wordWrapColumn": 88
"editor.wordWrap": "off",
"editor.tabSize": 4,
"editor.defaultFormatter": "charliermarsh.ruff"
},
"[markdown]": {
"editor.wordWrapColumn": 88
},
"[restructuredtext]": {
"editor.wordWrapColumn": 88
},
"[json]": {
"editor.quickSuggestions": {
"strings": true
},
"[restructuredtext]": {
"editor.wordWrapColumn": 88
},
"[json]": {
"editor.quickSuggestions": {
"strings": true
},
"editor.suggest.insertMode": "replace",
"editor.formatOnSave": true,
"editor.defaultFormatter": "esbenp.prettier-vscode",
"editor.tabSize": 2
},
"[yaml]": {
"editor.insertSpaces": true,
"editor.formatOnSave": true,
"editor.defaultFormatter": "esbenp.prettier-vscode",
"editor.tabSize": 2,
"editor.autoIndent": "advanced",
},
"prettier.tabWidth": 2,
"editor.rulers": [99],
"editor.wordWrapColumn": 99,
"python.analysis.typeCheckingMode": "off",
"ruff.nativeServer": true
"editor.suggest.insertMode": "replace",
"editor.formatOnSave": true,
"editor.defaultFormatter": "esbenp.prettier-vscode",
"editor.tabSize": 2
},
"[yaml]": {
"editor.insertSpaces": true,
"editor.formatOnSave": true,
"editor.tabSize": 2,
"editor.autoIndent": "advanced",
},
"prettier.tabWidth": 2,
"editor.rulers": [88],
"editor.wordWrapColumn": 88,
"ruff.nativeServer": true
}

```

which will apply the formatting and linting automatically on save.
Expand All @@ -122,18 +121,9 @@ you should see a path next to the version, indicating that `sdssdb` is being imp

### Updating `sdssdb` and other dependencies before tagging

When tagging `target_selection` please make sure that you've tagged `sdssdb` (if needed) and that the lockfile reflects the change. First you'll need to install [poetry](https://python-poetry.org/docs/#installation) (this should only be required once). Follow the installation instructions there, but a recommended way to install is:

1. Install [pipx](https://pipx.pypa.io/stable/installation/). Follow the instructions for your system, but generally `pip install pipx` works fine.
2. Use `pipx` to install `poetry` with

```bash
pipx install poetry
```

3. Ensure that the `poetry` executable can be found. If you execute `poetry` in your shell and that files, make sure that you have `$HOME/.local/bin` in your `$PATH` or follow other `pipx` instructions.
When tagging `target_selection` please make sure that you've tagged `sdssdb` (if needed) and that the lockfile reflects the change. First you'll need to install [uv](https://docs.astral.sh/uv/getting-started/installation/) (this should only be required once).

Once `poetry` is installed follow these instructions:
Once `uv` is installed follow these instructions:

1. If there are changes in `sdssdb` that affect `target_selection`, tag `sdssdb`. Please do update the `sdssdb` [change log](https://github.com/sdss/sdssdb/blob/main/CHANGELOG.rst) adding the header indicating the date in which the release was made. Note that you don't necessarily need to do this every time that `target_selection` is tagged, only when the new `target_selection` tag depends on untagged changes in `sdssdb`.

Expand All @@ -154,11 +144,11 @@ Once `poetry` is installed follow these instructions:
4. Recreate the lockfile with

```bash
poetry lock
uv lock
```

It may take a bit of time for `poetry` to detect a recently released version of `sdss`. You may want to run `poetry lock --no-cache` which will take a bit longer but should grab the new package as long as PyPI has updated its internal cache.
It may take a bit of time for package indexes to detect a recently released version of `sdss`. You may want to run `uv lock --refresh` to force a fresh resolution.

Note that `poetry lock` *will not* update the version of `sdssdb` in your virtual environment, only the lockfile. If you do want to update the dependency and the lockfile use `poetry update sdssdb` (or `poetry update` to update all the dependencies).
Note that `uv lock` *will not* update the version of `sdssdb` in your virtual environment, only the lockfile. If you do want to update the dependency and the lockfile use `uv lock --upgrade-package sdssdb` (or `uv lock --upgrade` to update all the dependencies).

5. Commit the new changes (including the `poetry.lock` file) and tag the new version of `target_selection`.
5. Commit the new changes (including the `uv.lock` file) and tag the new version of `target_selection`.
8 changes: 0 additions & 8 deletions etc/config.ini

This file was deleted.

Loading
Loading