aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEddy Pedroni <epedroni@pm.me>2024-11-09 20:35:56 +0100
committerEddy Pedroni <epedroni@pm.me>2024-11-09 20:35:56 +0100
commitcda8197669409689be291660f93cb288ab2d31b3 (patch)
tree81db9b0c7c0491e0737cbffb39af6b935c0dfeb8
parenta2257a900d4fffd6f94b73f1c48c62370ed1d684 (diff)
Migrate to project-based structure
-rw-r--r--.gitignore4
-rw-r--r--Makefile21
-rwxr-xr-xbootstrap-venv.sh5
-rw-r--r--cli-project/pyproject.toml24
-rw-r--r--cli-project/src/solo_tool_cli.py (renamed from solo_tool_cli.py)7
-rw-r--r--cli-project/test/solo_tool_cli_integrationtest.py (renamed from solo_tool_cli_integrationtest.py)38
-rw-r--r--cli-project/test/test.flac (renamed from test.flac)bin31743252 -> 31743252 bytes
-rw-r--r--cli-project/test/test.mp3 (renamed from test.mp3)bin5389533 -> 5389533 bytes
-rw-r--r--cli-project/test/test_session.json (renamed from test_session.json)0
-rw-r--r--doc/diagram.drawio (renamed from diagram.drawio)0
-rw-r--r--doc/known-issues.md (renamed from known-issues.md)0
-rw-r--r--gui-project/pyproject.toml24
-rw-r--r--gui-project/src/MainWindow.py (renamed from MainWindow.py)0
-rw-r--r--gui-project/src/mainwindow.ui (renamed from mainwindow.ui)0
-rw-r--r--gui-project/src/solo_tool_gui.py (renamed from solo_tool_qt.py)7
-rw-r--r--pre-commit4
-rw-r--r--requirements.txt11
-rw-r--r--solo-tool-project/pyproject.toml23
-rw-r--r--solo-tool-project/src/solo_tool/__init__.py1
-rw-r--r--solo-tool-project/src/solo_tool/abcontroller.py (renamed from abcontroller.py)0
-rw-r--r--solo-tool-project/src/solo_tool/midi_controller_launchpad_mini.py (renamed from midi_controller_launchpad_mini.py)2
-rw-r--r--solo-tool-project/src/solo_tool/midi_wrapper_mido.py (renamed from midi_wrapper_mido.py)0
-rw-r--r--solo-tool-project/src/solo_tool/notifier.py (renamed from notifier.py)1
-rw-r--r--solo-tool-project/src/solo_tool/player_vlc.py (renamed from player_vlc.py)0
-rw-r--r--solo-tool-project/src/solo_tool/playlist.py (renamed from playlist.py)1
-rw-r--r--solo-tool-project/src/solo_tool/session_manager.py (renamed from session_manager.py)0
-rw-r--r--solo-tool-project/src/solo_tool/solo_tool.py (renamed from solo_tool.py)10
-rw-r--r--solo-tool-project/test/abcontroller_unittest.py (renamed from abcontroller_unittest.py)2
-rw-r--r--solo-tool-project/test/midi_launchpad_mini_integrationtest.py (renamed from midi_launchpad_mini_integrationtest.py)4
-rw-r--r--solo-tool-project/test/notifier_unittest.py (renamed from notifier_unittest.py)2
-rw-r--r--solo-tool-project/test/player_mock.py (renamed from player_mock.py)0
-rw-r--r--solo-tool-project/test/playlist_unittest.py (renamed from playlist_unittest.py)2
-rw-r--r--solo-tool-project/test/session_manager_unittest.py (renamed from session_manager_unittest.py)2
-rw-r--r--solo-tool-project/test/solo_tool_integrationtest.py (renamed from solo_tool_integrationtest.py)2
-rw-r--r--solo-tool-project/test/test.flacbin0 -> 31743252 bytes
-rw-r--r--solo-tool-project/test/test.mp3bin0 -> 5389533 bytes
-rw-r--r--solo-tool-project/test/test_session.json13
37 files changed, 140 insertions, 70 deletions
diff --git a/.gitignore b/.gitignore
index 92afa22..cbe6874 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,2 +1,4 @@
-__pycache__/
+**/__pycache__/
venv/
+**/*.egg-info
+**/build
diff --git a/Makefile b/Makefile
new file mode 100644
index 0000000..1288113
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,21 @@
+test: all
+ cd solo-tool-project/test && ../../venv/bin/pytest *test.py
+ cd cli-project/test && ../../venv/bin/pytest *test.py
+
+all: venv .git/hooks/pre-commit
+
+clean:
+ rm -rf venv
+
+.git/hooks/pre-commit: pre-commit
+ install -m 755 pre-commit .git/hooks/pre-commit
+
+venv: venv/touchfile
+
+venv/touchfile: requirements.txt solo-tool-project/pyproject.toml cli-project/pyproject.toml gui-project/pyproject.toml
+ rm -rf venv
+ python -m venv venv
+ ./venv/bin/pip install -r requirements.txt
+ touch venv/touchfile
+
+.PHONY: all test clean
diff --git a/bootstrap-venv.sh b/bootstrap-venv.sh
deleted file mode 100755
index 99919d6..0000000
--- a/bootstrap-venv.sh
+++ /dev/null
@@ -1,5 +0,0 @@
-#!/usr/bin/zsh
-
-rm -rf venv
-python -m venv venv
-./venv/bin/pip install -r requirements.txt
diff --git a/cli-project/pyproject.toml b/cli-project/pyproject.toml
new file mode 100644
index 0000000..7d31a09
--- /dev/null
+++ b/cli-project/pyproject.toml
@@ -0,0 +1,24 @@
+[build-system]
+requires = ["setuptools"]
+build-backend = "setuptools.build_meta"
+
+[project]
+name = "solo_tool_cli"
+authors = [
+ { name = "Eddy Pedroni", email = "epedroni@pm.me" },
+]
+description = "A CLI frontend for the solo_tool library"
+requires-python = ">=3.12"
+dependencies = [
+ "solo_tool"
+]
+dynamic = ["version"]
+
+[project.optional-dependencies]
+dev = [
+ "pytest"
+]
+
+[project.scripts]
+solo-tool-cli = "solo_tool_cli:main"
+
diff --git a/solo_tool_cli.py b/cli-project/src/solo_tool_cli.py
index 43e3a9d..1c8a7d6 100644
--- a/solo_tool_cli.py
+++ b/cli-project/src/solo_tool_cli.py
@@ -3,7 +3,7 @@ import time
import threading
from solo_tool import SoloTool
-from midi_controller_launchpad_mini import MidiController
+from solo_tool.midi_controller_launchpad_mini import MidiController
class SoloToolCLI:
def __init__(self, sessionJson, soloToolOverride=None, midiOverride=None, tickEnable=True):
@@ -42,7 +42,8 @@ class SoloToolCLI:
self._soloTool.tick()
threading.Timer(0.1, self._tick).start()
-def main(args):
+def main():
+ args = sys.argv[1:]
if len(args) == 0:
print("Please provide path to session file")
sys.exit(1)
@@ -53,4 +54,4 @@ def main(args):
soloToolCli.input(commandString)
if __name__ == '__main__':
- main(sys.argv[1:])
+ main()
diff --git a/solo_tool_cli_integrationtest.py b/cli-project/test/solo_tool_cli_integrationtest.py
index 25ef131..c29a223 100644
--- a/solo_tool_cli_integrationtest.py
+++ b/cli-project/test/solo_tool_cli_integrationtest.py
@@ -4,7 +4,6 @@ from contextlib import redirect_stdout
from solo_tool_cli import SoloToolCLI
from solo_tool import SoloTool
-from player_mock import Player
class MockMidiController:
def __init__(self, soloTool):
@@ -14,12 +13,8 @@ class MockMidiController:
self.connected = True
@pytest.fixture
-def mockPlayer():
- return Player()
-
-@pytest.fixture
-def soloTool(mockPlayer):
- return SoloTool(playerOverride=mockPlayer)
+def soloTool():
+ return SoloTool()
@pytest.fixture
def mockMidi(soloTool):
@@ -29,35 +24,6 @@ def mockMidi(soloTool):
def uut(soloTool, mockMidi):
return SoloToolCLI("test_session.json", soloToolOverride=soloTool, midiOverride=mockMidi, tickEnable=False)
-def test_songSelection(uut, soloTool, mockPlayer):
- expectedOutput = """\
-Songs:
- 0 test.flac
- 1 test.mp3
-Songs:
- 0 test.flac
- 1 test.mp3
-Songs:
- 0 test.flac
- 1 test.mp3
-"""
-
- with io.StringIO() as buf, redirect_stdout(buf):
- uut.input("song")
- assert mockPlayer.currentSong == None
-
- uut.input("song 0")
- assert mockPlayer.currentSong == "test.flac"
-
- uut.input("song ")
-
- uut.input("song 1")
- assert mockPlayer.currentSong == "test.mp3"
-
- uut.input("song")
-
- assert buf.getvalue() == expectedOutput
-
def test_connectMidi(uut, mockMidi):
expectedOutput = """\
Supported device: Novation Launchpad Mini MkII
diff --git a/test.flac b/cli-project/test/test.flac
index 9164735..9164735 100644
--- a/test.flac
+++ b/cli-project/test/test.flac
Binary files differ
diff --git a/test.mp3 b/cli-project/test/test.mp3
index 3c353b7..3c353b7 100644
--- a/test.mp3
+++ b/cli-project/test/test.mp3
Binary files differ
diff --git a/test_session.json b/cli-project/test/test_session.json
index f48b792..f48b792 100644
--- a/test_session.json
+++ b/cli-project/test/test_session.json
diff --git a/diagram.drawio b/doc/diagram.drawio
index e3d1846..e3d1846 100644
--- a/diagram.drawio
+++ b/doc/diagram.drawio
diff --git a/known-issues.md b/doc/known-issues.md
index ae248f5..ae248f5 100644
--- a/known-issues.md
+++ b/doc/known-issues.md
diff --git a/gui-project/pyproject.toml b/gui-project/pyproject.toml
new file mode 100644
index 0000000..1e6fcf4
--- /dev/null
+++ b/gui-project/pyproject.toml
@@ -0,0 +1,24 @@
+[build-system]
+requires = ["setuptools"]
+build-backend = "setuptools.build_meta"
+
+[project]
+name = "solo_tool_gui"
+authors = [
+ { name = "Eddy Pedroni", email = "epedroni@pm.me" },
+]
+description = "A Qt5-based GUI frontend for the solo_tool library"
+requires-python = ">=3.12"
+dependencies = [
+ "PyQt5>=5.6",
+ "solo_tool"
+]
+dynamic = ["version"]
+
+[project.optional-dependencies]
+dev = [
+]
+
+[project.gui-scripts]
+solo-tool-gui = "solo_tool_gui:main"
+
diff --git a/MainWindow.py b/gui-project/src/MainWindow.py
index 137bd33..137bd33 100644
--- a/MainWindow.py
+++ b/gui-project/src/MainWindow.py
diff --git a/mainwindow.ui b/gui-project/src/mainwindow.ui
index ac4d97b..ac4d97b 100644
--- a/mainwindow.ui
+++ b/gui-project/src/mainwindow.ui
diff --git a/solo_tool_qt.py b/gui-project/src/solo_tool_gui.py
index 86557a7..0488f84 100644
--- a/solo_tool_qt.py
+++ b/gui-project/src/solo_tool_gui.py
@@ -6,7 +6,7 @@ from PyQt5.QtCore import *
from MainWindow import Ui_MainWindow
from solo_tool import SoloTool
-from midi_controller_launchpad_mini import MidiController
+from solo_tool.midi_controller_launchpad_mini import MidiController
POSITION_FACTOR = 100000
RATE_FACTOR = 10
@@ -231,7 +231,7 @@ class MainWindow(QMainWindow, Ui_MainWindow):
if event.key() == Qt.Key_Super_L:
self.soloTool.jumpToA()
-if __name__ == '__main__':
+def main():
app = QApplication([])
app.setApplicationName("Solo Tool")
app.setStyle("Fusion")
@@ -256,3 +256,6 @@ if __name__ == '__main__':
window = MainWindow()
app.exec_()
+
+if __name__ == '__main__':
+ main()
diff --git a/pre-commit b/pre-commit
new file mode 100644
index 0000000..668071c
--- /dev/null
+++ b/pre-commit
@@ -0,0 +1,4 @@
+#!/bin/sh
+
+make test
+exit $?
diff --git a/requirements.txt b/requirements.txt
index 564f8a7..20ce1da 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -1,9 +1,4 @@
-pytest
+-e solo-tool-project[dev]
+-e cli-project[dev]
+-e gui-project[dev]
-sip
-mido
-python-rtmidi
-
-PyQt5>=5.6
-
-python-vlc
diff --git a/solo-tool-project/pyproject.toml b/solo-tool-project/pyproject.toml
new file mode 100644
index 0000000..36d4891
--- /dev/null
+++ b/solo-tool-project/pyproject.toml
@@ -0,0 +1,23 @@
+[build-system]
+requires = ["setuptools"]
+build-backend = "setuptools.build_meta"
+
+[project]
+name = "solo_tool"
+authors = [
+ { name = "Eddy Pedroni", email = "epedroni@pm.me" },
+]
+description = "A library for dissecting guitar solos"
+requires-python = ">=3.12"
+dependencies = [
+ "python-rtmidi",
+ "sip",
+ "mido",
+ "python-vlc"
+]
+dynamic = ["version"]
+
+[project.optional-dependencies]
+dev = [
+ "pytest"
+]
diff --git a/solo-tool-project/src/solo_tool/__init__.py b/solo-tool-project/src/solo_tool/__init__.py
new file mode 100644
index 0000000..e1e7777
--- /dev/null
+++ b/solo-tool-project/src/solo_tool/__init__.py
@@ -0,0 +1 @@
+from .solo_tool import SoloTool
diff --git a/abcontroller.py b/solo-tool-project/src/solo_tool/abcontroller.py
index cec9fb2..cec9fb2 100644
--- a/abcontroller.py
+++ b/solo-tool-project/src/solo_tool/abcontroller.py
diff --git a/midi_controller_launchpad_mini.py b/solo-tool-project/src/solo_tool/midi_controller_launchpad_mini.py
index 0cc952c..961127c 100644
--- a/midi_controller_launchpad_mini.py
+++ b/solo-tool-project/src/solo_tool/midi_controller_launchpad_mini.py
@@ -1,4 +1,4 @@
-from midi_wrapper_mido import MidiWrapper
+from .midi_wrapper_mido import MidiWrapper
class MidiController:
DEVICE_NAME = "Launchpad Mini MIDI 1"
diff --git a/midi_wrapper_mido.py b/solo-tool-project/src/solo_tool/midi_wrapper_mido.py
index bf3aa85..bf3aa85 100644
--- a/midi_wrapper_mido.py
+++ b/solo-tool-project/src/solo_tool/midi_wrapper_mido.py
diff --git a/notifier.py b/solo-tool-project/src/solo_tool/notifier.py
index fae41b9..9f445b6 100644
--- a/notifier.py
+++ b/solo-tool-project/src/solo_tool/notifier.py
@@ -1,4 +1,3 @@
-
class Notifier:
PLAYING_STATE_EVENT = 0
PLAYBACK_VOLUME_EVENT = 1
diff --git a/player_vlc.py b/solo-tool-project/src/solo_tool/player_vlc.py
index 283102e..283102e 100644
--- a/player_vlc.py
+++ b/solo-tool-project/src/solo_tool/player_vlc.py
diff --git a/playlist.py b/solo-tool-project/src/solo_tool/playlist.py
index 5dad711..bbfd8f5 100644
--- a/playlist.py
+++ b/solo-tool-project/src/solo_tool/playlist.py
@@ -1,4 +1,3 @@
-
class Playlist:
def __init__(self, callback):
self._songList = list()
diff --git a/session_manager.py b/solo-tool-project/src/solo_tool/session_manager.py
index 718e864..718e864 100644
--- a/session_manager.py
+++ b/solo-tool-project/src/solo_tool/session_manager.py
diff --git a/solo_tool.py b/solo-tool-project/src/solo_tool/solo_tool.py
index 6cb1a77..211babf 100644
--- a/solo_tool.py
+++ b/solo-tool-project/src/solo_tool/solo_tool.py
@@ -1,10 +1,10 @@
import os
-from playlist import Playlist
-from abcontroller import ABController
-from session_manager import SessionManager
-from notifier import Notifier
-from player_vlc import Player
+from .playlist import Playlist
+from .abcontroller import ABController
+from .session_manager import SessionManager
+from .notifier import Notifier
+from .player_vlc import Player
class SoloTool:
def __init__(self, playerOverride=None):
diff --git a/abcontroller_unittest.py b/solo-tool-project/test/abcontroller_unittest.py
index 9fdcbc3..d2b7d31 100644
--- a/abcontroller_unittest.py
+++ b/solo-tool-project/test/abcontroller_unittest.py
@@ -1,4 +1,4 @@
-from abcontroller import ABController
+from solo_tool.abcontroller import ABController
from collections import namedtuple
TCase = namedtuple("TCase", ["currentPosition", "requestedPosition"])
diff --git a/midi_launchpad_mini_integrationtest.py b/solo-tool-project/test/midi_launchpad_mini_integrationtest.py
index e9bc6b5..8542aae 100644
--- a/midi_launchpad_mini_integrationtest.py
+++ b/solo-tool-project/test/midi_launchpad_mini_integrationtest.py
@@ -1,7 +1,7 @@
import pytest
-from midi_controller_launchpad_mini import MidiController
-from solo_tool import SoloTool
+from solo_tool.midi_controller_launchpad_mini import MidiController
+from solo_tool.solo_tool import SoloTool
from player_mock import Player as PlayerMock
LED_RED = 3
diff --git a/notifier_unittest.py b/solo-tool-project/test/notifier_unittest.py
index b27a17f..8a6e988 100644
--- a/notifier_unittest.py
+++ b/solo-tool-project/test/notifier_unittest.py
@@ -1,6 +1,6 @@
import pytest
-from notifier import Notifier
+from solo_tool.notifier import Notifier
from player_mock import Player
@pytest.fixture
diff --git a/player_mock.py b/solo-tool-project/test/player_mock.py
index 3162e0f..3162e0f 100644
--- a/player_mock.py
+++ b/solo-tool-project/test/player_mock.py
diff --git a/playlist_unittest.py b/solo-tool-project/test/playlist_unittest.py
index 815a05f..842ce51 100644
--- a/playlist_unittest.py
+++ b/solo-tool-project/test/playlist_unittest.py
@@ -1,4 +1,4 @@
-from playlist import Playlist
+from solo_tool.playlist import Playlist
def test_addAndSelectOneSong():
songAddedByUser = "/path/to/song"
diff --git a/session_manager_unittest.py b/solo-tool-project/test/session_manager_unittest.py
index 169aa17..5468880 100644
--- a/session_manager_unittest.py
+++ b/solo-tool-project/test/session_manager_unittest.py
@@ -1,4 +1,4 @@
-from session_manager import SessionManager
+from solo_tool.session_manager import SessionManager
from json import loads, dumps
testSession = [
diff --git a/solo_tool_integrationtest.py b/solo-tool-project/test/solo_tool_integrationtest.py
index 5731eac..5903abf 100644
--- a/solo_tool_integrationtest.py
+++ b/solo-tool-project/test/solo_tool_integrationtest.py
@@ -2,7 +2,7 @@ import pathlib
import shutil
import pytest
-from solo_tool import SoloTool
+from solo_tool.solo_tool import SoloTool
from player_mock import Player as MockPlayer
@pytest.fixture
diff --git a/solo-tool-project/test/test.flac b/solo-tool-project/test/test.flac
new file mode 100644
index 0000000..9164735
--- /dev/null
+++ b/solo-tool-project/test/test.flac
Binary files differ
diff --git a/solo-tool-project/test/test.mp3 b/solo-tool-project/test/test.mp3
new file mode 100644
index 0000000..3c353b7
--- /dev/null
+++ b/solo-tool-project/test/test.mp3
Binary files differ
diff --git a/solo-tool-project/test/test_session.json b/solo-tool-project/test/test_session.json
new file mode 100644
index 0000000..f48b792
--- /dev/null
+++ b/solo-tool-project/test/test_session.json
@@ -0,0 +1,13 @@
+[
+ {
+ "path" : "test.flac",
+ "ab_limits" : null
+ },
+ {
+ "path" : "test.mp3",
+ "ab_limits" : [
+ [0.1, 0.2],
+ [0.3, 0.4]
+ ]
+ }
+]