Development

Set up

py -3.12 -m venv .venv
.venv\Scripts\python -m pip install -r requirements.txt -r requirements-dev.txt

(On Linux and macOS: .venv/bin/python.) Python 3.12 or later. Everything installs inside .venv; nothing goes into the system Python.

On Linux, two system packages come first: the ALSA headers, because python-rtmidi has no Linux wheel and is compiled during the install, and PortAudio for sound (Debian and Ubuntu: sudo apt install libasound2-dev libportaudio2). bash packaging/build-linux.sh builds the app folder, the .tar.gz and the .deb; packaging/make_appimage.sh turns the folder into an AppImage.

Run

.venv\Scripts\python -m euterpes            # the app
.venv\Scripts\python -m euterpes piece.ly   # open a file
.venv\Scripts\python -m euterpes --self-test
.venv\Scripts\python -m euterpes.cli check piece.ly

--self-test checks, without a window, that every part imports and works. The build runs it on the packaged program.

The checks

Run all of these before every commit; CI runs the same set.

.venv\Scripts\python -m pytest
.venv\Scripts\python -m ruff check .
.venv\Scripts\python -m ruff format --check .
.venv\Scripts\python -m mypy
  • pytest: unit, property (Hypothesis), golden, architecture and contract tests, with branch coverage (gate: 85 per cent). Tests mirror the package: tests/core/test_model.py for core/model.py. Shared score builders are in tests/builders.py; fakes for the ports are in tests/fakes.py. UI tests run offscreen.
  • ruff: linting with docstring rules (Google style) and a complexity cap of 10 per function.
  • mypy: strict, over euterpes/core and euterpes/services.

Marks: -m "not lilypond" skips tests that need LilyPond; -m hardware runs only the tests that need a real device.

tests/test_architecture.py enforces the layers. Run it after adding any import.

Check in the real window, not only in tests

A green suite proves little about what a person sees: many UI tests check numbers, not the screen. A feature counts as working once it has been driven in the real window and looked at.

  • Readable offscreen screenshots need both QT_QPA_PLATFORM=offscreen and QT_QPA_FONTDIR=C:/Windows/Fonts; without the second, every letter is an empty box.
  • Never touch your own preferences: set EUTERPES_SETTINGS_FILE=<scratch>/settings.ini and LOCALAPPDATA=<scratch>/local before importing Qt. The test suite and tools/screenshots.py already do.
  • Drive it as a person would: build MainWindow(Session(text), Player(FakeClock(10.0), RecordingSynth()), load_music_font()), show it, and use QTest clicks and keys on the real widgets. Advance playback with clock.advance(dt) and window._tick(). Read back the session's text and what RecordingSynth was asked to play, then save window.grab() and look at it.
  • Try the edges: two staves, chords, rests, ties, tuplets, the first and last note, page, scroll and follow modes, zoom, another theme, a large library piece, Undo and Redo.

What is on disk

Frozen at 0.9.0, the first beta: every later version reads these, and a change needs a migration. tests/test_formats.py fails when one breaks.

What Where Version
A score a .ly file LilyPond's own
A library piece metadata.json beside the score, in a folder named after the piece format, 1 (a file without it is 1); fields others add are kept
A recorded run take.json and microphone.wav format, 1
Practice history practice-progress.json version, 1; a later version's file is left alone, an unreadable one is renamed .unreadable
Preferences QSettings: the keys of euterpes/settings.py no key removed or given another kind

Scores, metadata and the practice history are written with core.files.write_safely: whole or not at all.

Tools

Tool Does
tools/screenshots.py <folder> Renders every page of the real program, light and dark, to PNG files.
tools/build_site.py (python -m tools.build_site) Renders docs/ and the website to website/.
tools/make_icon.py, make_smufl_subset.py The icon, and the music font subset.

The documentation lives in docs/; translations in docs/locales/<code>/. The site is generated: do not edit generated HTML by hand, and commit the rebuilt website/ with documentation changes. Keep claims to what the code and tests show.

Build the Windows packages

powershell -ExecutionPolicy Bypass -File packaging\build.ps1

This runs the tests, builds the PyInstaller folder, the portable zip (dist\Euterpes-Portable.zip) and the Inno Setup installer (dist\Euterpes-Setup.exe, needs Inno Setup 6), and runs the packaged program's --self-test. It also ships euterpes-cli.exe beside Euterpes.exe.

Test the installer

After building:

powershell -ExecutionPolicy Bypass -File packaging\test_installer.ps1
powershell -ExecutionPolicy Bypass -File packaging\test_installer.ps1 -DeleteData
powershell -ExecutionPolicy Bypass -File packaging\test_installer.ps1 -Interactive
powershell -ExecutionPolicy Bypass -File packaging\test_installer.ps1 -Interactive -DeleteData

The script never touches your own Euterpes. It builds a probe installer from dist\Euterpes under another name (EuterpesProbe: its own uninstall entry, settings key and data folder), installs it silently into a temporary folder, runs the installed program's self-test with its settings in that folder, checks the Start menu shortcut and the uninstall entry, uninstalls, and checks that nothing is left but what was meant to stay. With -DeleteData the uninstaller deletes a throwaway library, the probe's settings and its data folder. With -Interactive the uninstall goes through the uninstaller's own windows: packaging\test_data_form.py answers "remove completely?", checks that the data form opens with its box clear, ticks it for -DeleteData, presses OK, saves the form's picture and closes the final message. It sends window messages and never moves the mouse, though the windows show for a moment. At the end the script compares your real settings with a copy taken at the start and fails if they changed. The log and the form's picture stay in the temporary folder. -Soundfont light|standard|best also tests a soundfont download.

A module walkthrough

Adding a feature usually touches, in order:

  1. core/: the domain logic, with unit and property tests.
  2. services/: the use case that composes it, with fakes in the tests.
  3. adapters/: the real hardware or program, with contract tests against the fake.
  4. ui/: the widgets, tested offscreen.
  5. docs/ and CHANGELOG.md.

See Architecture.