Skip to content

Commit

Permalink
repackage everything into proper subdirectories
Browse files Browse the repository at this point in the history
  • Loading branch information
azuline committed May 12, 2024
1 parent 9c39a2e commit 752b2a9
Show file tree
Hide file tree
Showing 64 changed files with 206 additions and 73 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ __pycache__
.coverage
.coverage.*
htmlcov
*.egg-info

# Zig
*.so
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ check: typecheck test lintcheck

# Build the Zig library for development.
build-zig:
cd rose_zig && zig build -Doptimize=Debug
cd rose-zig && zig build -Doptimize=Debug

typecheck:
mypy .
Expand Down
1 change: 0 additions & 1 deletion conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@

import pytest
from click.testing import CliRunner

from rose.cache import CACHE_SCHEMA_PATH, process_string_for_fts, update_cache
from rose.common import VERSION
from rose.config import Config, VirtualFSConfig
Expand Down
87 changes: 40 additions & 47 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,9 @@
flake-utils.lib.eachDefaultSystem (system:
let
pkgs = import nixpkgs { inherit system; };
python = pkgs.python311;
uuid6-python = python.pkgs.buildPythonPackage {
python-pin = pkgs.python311;
version = nixpkgs.lib.strings.removeSuffix "\n" (builtins.readFile ./rose-py/rose/.version);
uuid6 = python-pin.pkgs.buildPythonPackage {
pname = "uuid6-python";
version = "2023.5.2";
src = pkgs.fetchFromGitHub {
Expand All @@ -26,28 +27,31 @@
};
doCheck = false;
};
prod-py-deps = with python.pkgs; [
appdirs
cffi
click
jinja2
llfuse
mutagen
send2trash
setuptools
tomli-w
uuid6-python
watchdog
];
dev-py-deps = with python.pkgs; [
mypy
pytest
pytest-timeout
pytest-cov
pytest-xdist
snapshottest
];
version = nixpkgs.lib.strings.removeSuffix "\n" (builtins.readFile ./rose/.version);
py-deps = with python-pin.pkgs; {
inherit
# Runtime deps.
appdirs
cffi
click
jinja2
llfuse
mutagen
send2trash
setuptools
tomli-w
uuid6
watchdog
# Dev tools.
mypy
pytest
pytest-timeout
pytest-cov
pytest-xdist
snapshottest;
};
python-with-deps = python-pin.withPackages (_:
pkgs.lib.attrsets.mapAttrsToList (a: b: b) py-deps
);
in
{
devShells.default = pkgs.mkShell {
Expand All @@ -60,13 +64,17 @@
echo "$path"
}
export ROSE_ROOT="$(find-up flake.nix)"
export ROSE_SO_PATH="$ROSE_ROOT/rose_zig/zig-out/lib/librose.so"
export ROSE_SO_PATH="$ROSE_ROOT/rose-zig/zig-out/lib/librose.so"
export PYTHONPATH="$ROSE_ROOT/rose-py:''${PYTHONPATH:-}"
export PYTHONPATH="$ROSE_ROOT/rose-watchdog:$PYTHONPATH"
export PYTHONPATH="$ROSE_ROOT/rose-vfs:$PYTHONPATH"
export PYTHONPATH="$ROSE_ROOT/rose-cli:$PYTHONPATH"
'';
buildInputs = [
(pkgs.buildEnv {
name = "rose-devshell";
paths = with pkgs; [
(python.withPackages (_: prod-py-deps ++ dev-py-deps))
python-with-deps
ruff
nodePackages.pyright
nodePackages.prettier
Expand All @@ -77,29 +85,14 @@
];
};
packages = rec {
rose-zig = pkgs.callPackage ./rose_zig { inherit version; };
# TODO: Split up into multiple packages.
rose-py = python.pkgs.buildPythonPackage {
pname = "rose";
version = version;
src = ./.;
propagatedBuildInputs = prod-py-deps ++ [ rose-zig ];
nativeBuildInputs = [ pkgs.makeWrapper ];
postInstall = ''
wrapProgram $out/bin/rose --set ROSE_SO_PATH "${rose-zig}/lib/librose.so"
'';
doCheck = false;
};
# CLI is currently rose-py...
rose-cli = rose-py;
# Mainly for building everything in CI.
rose-zig = pkgs.callPackage ./rose-zig { inherit version; };
rose-py = pkgs.callPackage ./rose-py { inherit version python-pin py-deps rose-zig; };
rose-watchdog = pkgs.callPackage ./rose-watchdog { inherit version python-pin py-deps rose-py; };
rose-vfs = pkgs.callPackage ./rose-vfs { inherit version python-pin py-deps rose-py; };
rose-cli = pkgs.callPackage ./rose-cli { inherit version python-pin py-deps rose-py rose-vfs rose-watchdog; };
all = pkgs.buildEnv {
name = "rose-all";
paths = [
rose-zig
rose-py
rose-cli
];
paths = [ rose-zig rose-py rose-watchdog rose-vfs rose-cli ];
};
};
});
Expand Down
3 changes: 3 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,9 @@ unfixable = [
strict = true
strict_optional = true
explicit_package_bases = true
exclude = [
"setup.py"
]

[[tool.mypy.overrides]]
module = "fuse"
Expand Down
File renamed without changes.
20 changes: 20 additions & 0 deletions rose-cli/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{ python-pin
, version
, py-deps
, rose-py
, rose-vfs
, rose-watchdog
}:

python-pin.pkgs.buildPythonPackage {
pname = "rose-cli";
version = version;
src = ./.;
propagatedBuildInputs = [
rose-py
rose-vfs
rose-watchdog
py-deps.click
];
doCheck = false;
}
File renamed without changes.
3 changes: 1 addition & 2 deletions rose_cli/__main__.py → rose-cli/rose_cli/__main__.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
import sys

import click
from rose import RoseExpectedError

from rose_cli.cli import CliExpectedError, cli


def main() -> None:
from rose import RoseExpectedError

try:
cli()
except (RoseExpectedError, CliExpectedError) as e:
Expand Down
6 changes: 3 additions & 3 deletions rose_cli/cli.py → rose-cli/rose_cli/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
from pathlib import Path

import click

from rose import (
VERSION,
Action,
Expand Down Expand Up @@ -51,6 +50,9 @@
toggle_release_new,
update_cache,
)
from rose_vfs import mount_virtualfs
from rose_watchdog import start_watchdog

from rose_cli.dump import (
dump_all_artists,
dump_all_collages,
Expand All @@ -70,8 +72,6 @@
dump_track,
)
from rose_cli.templates import preview_path_templates
from rose_vfs import mount_virtualfs
from rose_watchdog import start_watchdog

logger = logging.getLogger(__name__)

Expand Down
4 changes: 2 additions & 2 deletions rose_cli/cli_test.py → rose-cli/rose_cli/cli_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@

import pytest
from click.testing import CliRunner

from rose import AudioTags, Config
from rose.ffi import get_release
from rose_vfs.virtualfs_test import start_virtual_fs

from rose_cli.cli import (
Context,
InvalidReleaseArgError,
Expand All @@ -19,7 +20,6 @@
unwatch,
watch,
)
from rose_vfs.virtualfs_test import start_virtual_fs


@pytest.mark.usefixtures("seeded_cache")
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion rose_cli/dump_test.py → rose-cli/rose_cli/dump_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
from typing import Any

import pytest

from rose import Config, Matcher

from rose_cli.dump import (
dump_all_artists,
dump_all_collages,
Expand Down
File renamed without changes.
File renamed without changes.
1 change: 0 additions & 1 deletion rose_cli/templates.py → rose-cli/rose_cli/templates.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import click

from rose import (
Config,
PathTemplate,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import click
from click.testing import CliRunner

from rose import Config

from rose_cli.templates import (
preview_path_templates,
)
Expand Down
21 changes: 21 additions & 0 deletions rose-cli/setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import setuptools

with open(".version") as f:
version = f.read().strip()

setuptools.setup(
name="rose-cli",
version=version,
python_requires=">=3.11.0",
author="blissful",
author_email="blissful@sunsetglow.net",
license="Apache-2.0",
entry_points={"console_scripts": ["rose = rose_cli.__main__:main"]},
packages=["rose_cli"],
install_requires=[
"click",
"rose",
"rose-vfs",
"rose-watchdog",
],
)
23 changes: 23 additions & 0 deletions rose-py/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{ python-pin
, version
, py-deps
, rose-zig
}:

python-pin.pkgs.buildPythonPackage {
pname = "rose";
version = version;
src = ./.;
propagatedBuildInputs = [
rose-zig
py-deps.appdirs
py-deps.click
py-deps.jinja2
py-deps.mutagen
py-deps.send2trash
py-deps.tomli-w
py-deps.uuid6
];
doCheck = false;
ROSE_SO_PATH = "${rose-zig}/lib/librose.so";
}
1 change: 1 addition & 0 deletions rose-py/rose/.version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
0.5.0
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
3 changes: 1 addition & 2 deletions setup.py → rose-py/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@
author="blissful",
author_email="blissful@sunsetglow.net",
license="Apache-2.0",
entry_points={"console_scripts": ["rose = rose_cli.__main__:main"]},
packages=setuptools.find_namespace_packages(where="."),
packages=["rose"],
package_data={"rose": ["*.sql", ".version"]},
install_requires=[
"appdirs",
Expand Down
1 change: 1 addition & 0 deletions rose-vfs/.version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
0.5.0
16 changes: 16 additions & 0 deletions rose-vfs/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{ python-pin
, version
, py-deps
, rose-py
}:

python-pin.pkgs.buildPythonPackage {
pname = "rose-vfs";
version = version;
src = ./.;
propagatedBuildInputs = [
rose-py
py-deps.llfuse
];
doCheck = false;
}
1 change: 1 addition & 0 deletions rose_vfs/__init__.py → rose-vfs/rose_vfs/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from rose import initialize_logging

from rose_vfs.virtualfs import mount_virtualfs, unmount_virtualfs

__all__ = [
Expand Down
1 change: 0 additions & 1 deletion rose_vfs/virtualfs.py → rose-vfs/rose_vfs/virtualfs.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@
from typing import Any, Generic, Literal, TypeVar

import llfuse

from rose import (
SUPPORTED_AUDIO_EXTENSIONS,
AudioTags,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
from pathlib import Path

import pytest
from rose import AudioTags, Config

from conftest import retry_for_sec
from rose import AudioTags, Config
from rose_vfs.virtualfs import ALL_TRACKS, mount_virtualfs, unmount_virtualfs

R1_VNAME = "Techno Man & Bass Man - 2023. Release 1"
Expand Down
18 changes: 18 additions & 0 deletions rose-vfs/setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import setuptools

with open(".version") as f:
version = f.read().strip()

setuptools.setup(
name="rose-vfs",
version=version,
python_requires=">=3.11.0",
author="blissful",
author_email="blissful@sunsetglow.net",
license="Apache-2.0",
packages=["rose_vfs"],
install_requires=[
"rose",
"llfuse",
],
)
1 change: 1 addition & 0 deletions rose-watchdog/.version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
0.5.0
Loading

0 comments on commit 752b2a9

Please sign in to comment.