Skip to content

Commit c3b96f8

Browse files
committed
Improve uv instructions, add dev dependencies
1 parent 07bad4c commit c3b96f8

File tree

7 files changed

+1828
-137
lines changed

7 files changed

+1828
-137
lines changed

.github/workflows/test.yml

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,9 @@ jobs:
3636
- name: Install dependencies
3737
run: |
3838
uv sync --locked
39-
uv pip install -r tests/requirements.txt
40-
uv pip install -r doc/requirements.txt
41-
# This is needed in example scripts:
42-
uv pip install pillow
4339
- name: Test
4440
run: uv run --locked -m pytest
4541
- name: Test examples
46-
run: uv run --locked --script doc/examples/run_all.py
42+
run: uv run --locked --with pillow --script doc/examples/run_all.py
4743
- name: Test documentation
4844
run: uv run --locked -m sphinx doc/ _build/ -b doctest

CONTRIBUTING.rst

Lines changed: 20 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -9,23 +9,13 @@ Contributions are always welcome!
99
Development Installation
1010
^^^^^^^^^^^^^^^^^^^^^^^^
1111

12-
Instead of pip-installing the latest release from PyPI_, you should get the
12+
Instead of installing the latest release from PyPI_, you should get the
1313
newest development version from Github_::
1414

1515
git clone https://github.com/sfstoolbox/sfs-python.git
1616
cd sfs-python
1717
uv sync
1818

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.
24-
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.
28-
2919
.. _PyPI: https://pypi.org/project/sfs/
3020
.. _Github: https://github.com/sfstoolbox/sfs-python/
3121

@@ -34,47 +24,40 @@ Building the Documentation
3424
^^^^^^^^^^^^^^^^^^^^^^^^^^
3525

3626
If you make changes to the documentation, you can re-create the HTML pages
37-
using Sphinx_.
38-
From the main ``sfs-python`` directory,
39-
you can install it and a few other necessary packages with::
40-
41-
uv pip install -r doc/requirements.txt
42-
43-
To create the HTML pages, use::
27+
using Sphinx_. From the main ``sfs-python`` directory, run::
4428

45-
uv run -m sphinx doc _build
29+
uv run sphinx-build doc _build
4630

4731
The generated files will be available in the directory ``_build/``.
4832

49-
To create the PDF file, use::
33+
.. _Sphinx: http://sphinx-doc.org/
5034

51-
uv run -m sphinx doc _build -b latex
5235

53-
Afterwards go to the folder ``_build/`` and run LaTeX to create the
54-
PDF file. If you don’t know how to create a PDF file from the LaTeX output, you
55-
should have a look at Latexmk_ (see also this `Latexmk tutorial`_).
36+
Running the Tests
37+
^^^^^^^^^^^^^^^^^
5638

57-
It is also possible to automatically check if all links are still valid::
39+
You'll need pytest_, which will be installed automatically.
40+
To execute the tests, simply run::
5841

59-
uv run -m sphinx doc _build -b linkcheck
42+
uv run pytest
6043

61-
.. _Sphinx: http://sphinx-doc.org/
62-
.. _Latexmk: https://www.cantab.net/users/johncollins/latexmk/
63-
.. _Latexmk tutorial: https://mg.readthedocs.io/latexmk.html
44+
.. _pytest: https://pytest.org/
6445

65-
Running the Tests
66-
^^^^^^^^^^^^^^^^^
6746

68-
You'll need pytest_ for that.
69-
It can be installed with::
47+
Editable Installation
48+
^^^^^^^^^^^^^^^^^^^^^
7049

71-
uv pip install -r tests/requirements.txt
50+
If you want to work in a different directory on your own files,
51+
but using the latest development version (or a custom branch) of
52+
the ``sfs`` module, you can switch to a directory of your choice
53+
and enter this::
7254

73-
To execute the tests, simply run::
55+
uv init --bare
56+
uv add --editable path/to/your/sfs/repo
7457

75-
uv run -m pytest
58+
You can install further packages with ``uv add`` and then run
59+
whatever you need with ``uv run``.
7660

77-
.. _pytest: https://pytest.org/
7861

7962
Creating a New Release
8063
^^^^^^^^^^^^^^^^^^^^^^

doc/installation.rst

Lines changed: 51 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -24,32 +24,72 @@ Installation
2424

2525
First, create a new directory wherever you want, change into it, then run::
2626

27-
uv venv
27+
uv init --bare
2828

29-
This will print instructions for how to `activate the environment`__.
30-
You should do that now!
29+
This will create a file named ``pyproject.toml`` for you.
30+
Use the ``--help`` flag to see other options.
3131

32-
__ https://docs.astral.sh/uv/pip/environments/#using-a-virtual-environment
32+
The Sound Field Synthesis Toolbox can now be installed with::
3333

34-
The Sound Field Synthesis Toolbox can be installed with::
35-
36-
uv pip install sfs
34+
uv add sfs
3735

3836
This will automatically install the NumPy_ and SciPy_ libraries as well,
3937
which are needed by the SFS Toolbox.
38+
It will also create a file named ``uv.lock``, which tracks the exact versions
39+
of all installed packages.
4040

4141
If you want to use the provided functions for plotting sound fields, you'll need
4242
Matplotlib_::
4343

44-
uv pip install matplotlib
44+
uv add matplotlib
4545

4646
However, since all results are provided as plain NumPy_ arrays, you should also
4747
be able to use any other plotting library of your choice to visualize the sound
4848
fields.
4949

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.
50+
You might also want to install some other Python-related tools,
51+
e.g. JupyterLab_::
52+
53+
uv add jupyterlab
54+
55+
.. _JupyterLab: https://jupyter.org/
56+
57+
You get the gist: whatever you need, just ``uv add ...`` it!
58+
59+
Once everything is installed, you can start working with the tool of your choice
60+
by simply prefixing it with ``uv run``, for example::
61+
62+
uv run jupyter lab
63+
64+
Similarly, you can launch any other tool, like a text editor, an IDE etc.
65+
66+
You can also simply create a Python file, let's say ``my_script.py``:
67+
68+
.. code:: python
69+
70+
import matplotlib.pyplot as plt
71+
import numpy as np
72+
import sfs
73+
74+
npw = sfs.util.direction_vector(np.radians(-45))
75+
f = 300 # Hz
76+
omega = 2 * np.pi * f
77+
78+
grid = sfs.util.xyz_grid([-2, 2], [-2, 2], 0, spacing=0.02)
79+
array = sfs.array.circular(N=32, R=1.5)
80+
81+
d, selection, secondary_source = sfs.fd.wfs.plane_25d(
82+
omega, array.x, array.n, npw)
83+
84+
p = sfs.fd.synthesize(d, selection, array, secondary_source, grid=grid)
85+
sfs.plot2d.amplitude(p, grid)
86+
sfs.plot2d.loudspeakers(array.x, array.n, selection * array.a, size=0.15)
87+
88+
plt.show()
89+
90+
You can then run this script (assuming you installed ``matplotlib`` before) with::
91+
92+
uv run my_script.py
5393

5494
If you want to install the latest development version of the SFS Toolbox, have a
5595
look at :doc:`contributing`.

doc/requirements.txt

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

pyproject.toml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,17 @@ Documentation = "https://sfs-python.readthedocs.io/"
2222
Repository = "https://github.com/sfstoolbox/sfs-python"
2323
Issues = "https://github.com/sfstoolbox/sfs-python/issues"
2424

25+
[dependency-groups]
26+
dev = [
27+
"pytest",
28+
"sphinx>=8",
29+
"sphinx-rtd-theme",
30+
"nbsphinx",
31+
"ipykernel",
32+
"sphinxcontrib-bibtex>=2.1.4",
33+
"matplotlib>=3",
34+
]
35+
2536
[tool.setuptools.packages.find]
2637
include = ["sfs*"]
2738

tests/requirements.txt

Lines changed: 0 additions & 1 deletion
This file was deleted.

0 commit comments

Comments
 (0)