Skip to content

Commit 95ee0ab

Browse files
authored
Add pyproject.toml, use uv (#183)
* Add pyproject.toml * Require Python 3.11, change installation instructions to using "uv" ... and use it for CI as well.
1 parent 6b99b63 commit 95ee0ab

File tree

9 files changed

+258
-104
lines changed

9 files changed

+258
-104
lines changed

.github/workflows/test.yml

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@ name: Test
22

33
on: [push, pull_request]
44

5+
env:
6+
UV_PYTHON_DOWNLOADS: never
7+
58
jobs:
69
build:
710

@@ -10,13 +13,15 @@ jobs:
1013
matrix:
1114
os: [ubuntu-latest, macOS-latest, windows-latest]
1215
python-version: ['3.11', '3.12']
13-
16+
1417
steps:
1518
- uses: actions/checkout@v4
1619
- name: Set up Python ${{ matrix.python-version }}
1720
uses: actions/setup-python@v5
1821
with:
1922
python-version: ${{ matrix.python-version }}
23+
- name: Install uv
24+
uses: astral-sh/setup-uv@v6
2025
- name: Prepare Ubuntu
2126
run: |
2227
sudo apt-get update
@@ -30,16 +35,14 @@ jobs:
3035
if: matrix.os == 'windows-latest'
3136
- name: Install dependencies
3237
run: |
33-
python -V
34-
python -m pip install --upgrade pip
35-
python -m pip install .
36-
python -m pip install -r tests/requirements.txt
37-
python -m pip install -r doc/requirements.txt
38+
uv sync --locked
39+
uv pip install -r tests/requirements.txt
40+
uv pip install -r doc/requirements.txt
3841
# This is needed in example scripts:
39-
python -m pip install pillow
42+
uv pip install pillow
4043
- name: Test
41-
run: python -m pytest
44+
run: uv run --locked -m pytest
4245
- name: Test examples
43-
run: python doc/examples/run_all.py
46+
run: uv run --locked --script doc/examples/run_all.py
4447
- name: Test documentation
45-
run: python -m sphinx doc/ _build/ -b doctest
48+
run: uv run --locked -m sphinx doc/ _build/ -b doctest

CONTRIBUTING.rst

Lines changed: 20 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,17 @@ newest development version from Github_::
1414

1515
git clone https://github.com/sfstoolbox/sfs-python.git
1616
cd sfs-python
17-
python3 -m pip install --user -e .
17+
uv sync
1818

19-
... where ``-e`` stands for ``--editable``.
19+
This creates a virtual environment where the latest development version
20+
of the SFS Toolbox is installed.
21+
Note that you can activate this environment from any directory
22+
(e.g. one where you have some Python scripts using the ``sfs`` module),
23+
it doesn't have to be the directory where you cloned the Git repository.
2024

21-
This way, your installation always stays up-to-date, even if you pull new
22-
changes from the Github repository.
25+
Wherever you activate that environment from,
26+
it will always stay up-to-date, even if you pull new
27+
changes from the Github repository or switch branches.
2328

2429
.. _PyPI: https://pypi.org/project/sfs/
2530
.. _Github: https://github.com/sfstoolbox/sfs-python/
@@ -30,37 +35,31 @@ Building the Documentation
3035

3136
If you make changes to the documentation, you can re-create the HTML pages
3237
using Sphinx_.
33-
You can install it and a few other necessary packages with::
38+
From the main ``sfs-python`` directory,
39+
you can install it and a few other necessary packages with::
3440

35-
python3 -m pip install -r doc/requirements.txt --user
41+
uv pip install -r doc/requirements.txt
3642

3743
To create the HTML pages, use::
3844

39-
python3 setup.py build_sphinx
45+
uv run -m sphinx doc _build
4046

41-
The generated files will be available in the directory ``build/sphinx/html/``.
42-
43-
To create the EPUB file, use::
44-
45-
python3 setup.py build_sphinx -b epub
46-
47-
The generated EPUB file will be available in the directory
48-
``build/sphinx/epub/``.
47+
The generated files will be available in the directory ``_build/``.
4948

5049
To create the PDF file, use::
5150

52-
python3 setup.py build_sphinx -b latex
51+
uv run -m sphinx doc _build -b latex
5352

54-
Afterwards go to the folder ``build/sphinx/latex/`` and run LaTeX to create the
53+
Afterwards go to the folder ``_build/`` and run LaTeX to create the
5554
PDF file. If you don’t know how to create a PDF file from the LaTeX output, you
5655
should have a look at Latexmk_ (see also this `Latexmk tutorial`_).
5756

5857
It is also possible to automatically check if all links are still valid::
5958

60-
python3 setup.py build_sphinx -b linkcheck
59+
uv run -m sphinx doc _build -b linkcheck
6160

6261
.. _Sphinx: http://sphinx-doc.org/
63-
.. _Latexmk: http://personal.psu.edu/jcc8/software/latexmk-jcc/
62+
.. _Latexmk: https://www.cantab.net/users/johncollins/latexmk/
6463
.. _Latexmk tutorial: https://mg.readthedocs.io/latexmk.html
6564

6665
Running the Tests
@@ -69,11 +68,11 @@ Running the Tests
6968
You'll need pytest_ for that.
7069
It can be installed with::
7170

72-
python3 -m pip install -r tests/requirements.txt --user
71+
uv pip install -r tests/requirements.txt
7372

7473
To execute the tests, simply run::
7574

76-
python3 -m pytest
75+
uv run -m pytest
7776

7877
.. _pytest: https://pytest.org/
7978

MANIFEST.in

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

README.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ License:
1515
MIT -- see the file ``LICENSE`` for details.
1616

1717
Quick start:
18-
* Install Python 3, NumPy, SciPy and Matplotlib
19-
* ``python3 -m pip install sfs --user``
18+
* Install Python and (optionally) Matplotlib
19+
* Install the ``sfs`` package for Python
2020
* Check out the examples in the documentation
2121

2222
More information about the underlying theory can be found at

doc/installation.rst

Lines changed: 31 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -5,40 +5,51 @@ Requirements
55
------------
66

77
Obviously, you'll need Python_.
8-
More specifically, you'll need Python 3.
9-
NumPy_ and SciPy_ are needed for the calculations.
10-
If you want to use the provided functions for plotting sound fields, you'll need
11-
Matplotlib_.
12-
However, since all results are provided as plain NumPy_ arrays, you should also
13-
be able to use any plotting library of your choice to visualize the sound
14-
fields.
8+
There are many ways to install Python,
9+
and you can use any way you like,
10+
however, we recommend using uv_ as shown in the steps below.
1511

16-
Instead of installing all of the requirements separately, you should probably
17-
get a Python distribution that already includes everything, e.g. Anaconda_.
12+
You can install ``uv`` with your favorite package manager,
13+
or by one of the other methods described at
14+
https://docs.astral.sh/uv/getting-started/installation/.
1815

1916
.. _Python: https://www.python.org/
17+
.. _uv: https://docs.astral.sh/uv/
2018
.. _NumPy: http://www.numpy.org/
2119
.. _SciPy: https://www.scipy.org/scipylib/
2220
.. _Matplotlib: https://matplotlib.org/
23-
.. _Anaconda: https://docs.anaconda.com/anaconda/
2421

2522
Installation
2623
------------
2724

28-
Once you have installed the above-mentioned dependencies, you can use pip_
29-
to download and install the latest release of the Sound Field Synthesis Toolbox
30-
with a single command::
25+
First, create a new directory wherever you want, change into it, then run::
26+
27+
uv venv
3128

32-
python3 -m pip install sfs --user
29+
This will print instructions for how to `activate the environment`__.
30+
You should do that now!
3331

34-
If you want to install it system-wide for all users (assuming you have the
35-
necessary rights), you can just drop the ``--user`` option.
32+
__ https://docs.astral.sh/uv/pip/environments/#using-a-virtual-environment
3633

37-
To un-install, use::
34+
The Sound Field Synthesis Toolbox can be installed with::
3835

39-
python3 -m pip uninstall sfs
36+
uv pip install sfs
37+
38+
This will automatically install the NumPy_ and SciPy_ libraries as well,
39+
which are needed by the SFS Toolbox.
40+
41+
If you want to use the provided functions for plotting sound fields, you'll need
42+
Matplotlib_::
43+
44+
uv pip install matplotlib
45+
46+
However, since all results are provided as plain NumPy_ arrays, you should also
47+
be able to use any other plotting library of your choice to visualize the sound
48+
fields.
49+
50+
The steps above need to be executed only once.
51+
Whenever you come back to this directory at a later time,
52+
you just need to activate the environment again.
4053

4154
If you want to install the latest development version of the SFS Toolbox, have a
4255
look at :doc:`contributing`.
43-
44-
.. _pip: https://pip.pypa.io/en/latest/installing/

pyproject.toml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
[build-system]
2+
requires = ["setuptools", "setuptools-scm"]
3+
build-backend = "setuptools.build_meta"
4+
5+
[project]
6+
name = "sfs"
7+
license = "MIT"
8+
dynamic = ["version"]
9+
description = "Sound Field Synthesis Toolbox"
10+
readme = "README.rst"
11+
keywords = ["audio", "SFS", "WFS", "Ambisonics"]
12+
authors = [{ name = "SFS Toolbox Developers", email = "[email protected]" }]
13+
dependencies = ["numpy >= 2", "scipy >= 1.16"]
14+
requires-python = ">= 3.11"
15+
classifiers = [
16+
"Operating System :: OS Independent",
17+
"Topic :: Scientific/Engineering",
18+
]
19+
20+
[project.urls]
21+
Documentation = "https://sfs-python.readthedocs.io/"
22+
Repository = "https://github.com/sfstoolbox/sfs-python"
23+
Issues = "https://github.com/sfstoolbox/sfs-python/issues"
24+
25+
[tool.setuptools.packages.find]
26+
include = ["sfs*"]
27+
28+
[tool.setuptools.dynamic]
29+
version = { attr = "sfs.__version__" }

setup.cfg

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

setup.py

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

0 commit comments

Comments
 (0)