diff --git a/.github/workflows/python-package.yml b/.github/workflows/python-package.yml index d312ec8..c714371 100644 --- a/.github/workflows/python-package.yml +++ b/.github/workflows/python-package.yml @@ -19,10 +19,8 @@ jobs: contents: write steps: - uses: actions/checkout@v4 - - run: | - date > generated.txt - git tag -l --contains HEAD > TAG - git describe --tags > REVISIONS || echo > REVISIONS + with: + lfs: true - name: Set up Python ${{ matrix.python-version }} uses: actions/setup-python@v5 with: @@ -31,14 +29,22 @@ jobs: run: | python -m pip install --upgrade pip python -m pip install build ruff mypy - sudo apt install fuse3 libfuse3-dev libfuse-dev -y - python -m pip install -e . - - name: Lint with ruff + sudo apt install fuse3 libfuse3-dev libfuse-dev ffmpeg -y + python -m pip install -e ".[lint]" + - name: Test with pytest + run: | + python -m pip install -e ".[test]" + pytest + - name: Lint code with Ruff + run: | + ruff check --output-format=github + - name: Check code formatting with Ruff run: | - ruff check - - name: Lint with mypy + ruff format --diff + - name: Lint code with mypy run: | mypy yandex_fuse + mypy tests - name: Build package run: python -m build - name: Release diff --git a/.gitignore b/.gitignore index 2bd45c9..38f8f12 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,4 @@ -# Byte-compiled / optimized / DLL files +# Byte-compiled / optimized .idea *.iml __pycache__/ @@ -50,4 +50,7 @@ ENV/ # ruff .ruff_cache -VERSION +yandex_fuse/_version.py + +# coverage +*.coverage diff --git a/.mypy.ini b/.mypy.ini deleted file mode 100644 index 1471e17..0000000 --- a/.mypy.ini +++ /dev/null @@ -1,9 +0,0 @@ -[mypy] -python_version = 3.10 -warn_unused_ignores = True -warn_return_any = True -warn_unreachable = True -strict_equality = True -strict = True -pretty = True - diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..67fb9f6 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,92 @@ +[build-system] +requires = ["setuptools >= 65.0", "setuptools-scm >= 8"] +build-backend = "setuptools.build_meta" + +[project] +name = "yandex-fuse" +dynamic = ["version"] +description = "Yandex Music Fuse FS" +readme = "README.md" +authors = [{ name = "Roman Nebaluev" }] +license = { text = "LGPLv3" } +keywords = ["yandex", "music", "fuse", "filesystem"] + +dependencies = ["yandex-music >=2.2.0", "mutagen >=1.47.0", "pyfuse3 >=3.4.0"] +requires-python = ">=3.10" + +[project.optional-dependencies] +test = ["pytest", "coverage", "pytest-cov"] +lint = ["mypy", "ruff"] + +[project.scripts] +yamusic-fs = "yandex_fuse.main:main" + +[tool.setuptools] +zip-safe = false +include-package-data = true + +[tool.setuptools.packages.find] +include = ["yandex_fuse"] + +[tool.setuptools.package-data] +"yandex_fuse" = ["contrib/*"] + +[tool.setuptools_scm] +version_file = "yandex_fuse/_version.py" + +[tool.pytest.ini_options] +pythonpath = "yandex_fuse" +addopts = "--cov --cov-report term-missing:skip-covered -v -s" +testpaths = ["tests"] + +[tool.ruff] +target-version = "py310" +line-length = 80 +indent-width = 4 + +[tool.ruff.lint] +# https://docs.astral.sh/ruff/rules/#legend +select = ["ALL"] +# D10* Missing docstring +ignore = [ + "D10", + "D204", + "D203", + "D211", + "D212", + "D213", + "EM101", + "EM102", + "ERA001", + "FBT002", + "FBT003", + "FIX002", + "PT001", + "PT023", + "Q001", + "TD003", + "TRY003", + "COM812", + "ISC001", + "S603", + "S607", +] +# Allow unused variables when underscore-prefixed. +dummy-variable-rgx = '^(_+|(_+[a-zA-Z0-9_]*[a-zA-Z0-9]+?))$' + +[tool.ruff.lint.flake8-quotes] +inline-quotes = "double" + +[tool.ruff.format] +quote-style = "double" +indent-style = "space" +docstring-code-format = false + +[tool.mypy] +python_version = "3.10" +warn_unused_ignores = true +warn_return_any = true +warn_unreachable = true +strict_equality = true +strict = true +pretty = true diff --git a/ruff.toml b/ruff.toml deleted file mode 100644 index 230995a..0000000 --- a/ruff.toml +++ /dev/null @@ -1,41 +0,0 @@ -target-version = "py310" -line-length = 80 -indent-width = 4 - -[lint] -# https://docs.astral.sh/ruff/rules/#legend -select = ["ALL"] -# D10* Missing docstring -ignore = [ - "D10", - "D204", - "D203", - "D211", - "D212", - "D213", - "EM101", - "EM102", - "ERA001", - "FBT002", - "FBT003", - "FIX002", - "PT001", - "PT023", - "Q001", - "TD003", - "TRY003", - "COM812", - "ISC001", - "S603", - "S607", -] -# Allow unused variables when underscore-prefixed. -dummy-variable-rgx = '^(_+|(_+[a-zA-Z0-9_]*[a-zA-Z0-9]+?))$' - -[lint.flake8-quotes] -inline-quotes = "double" - -[format] -quote-style = "double" -indent-style = "space" -docstring-code-format = false diff --git a/setup.cfg b/setup.cfg deleted file mode 100644 index 5484b92..0000000 --- a/setup.cfg +++ /dev/null @@ -1,32 +0,0 @@ -[metadata] -name = yandex-fuse -version = file:VERSION -summary = "Yandex Music Fuse FS" -description_file = - README.md -author = Roman Nebaluev -license = LGPLv3 - -[options] -zip_safe = false -include_package_data = true -packages = - yandex_fuse -python_requires >=3.10 -install_requires = - yandex-music >=2.2.0 - mutagen >=1.47.0 - pyfuse3 >=3.4.0 - -[options.package_data] -yandex_fuse = contrib/* - -[options.entry_points] -console_scripts = - yamusic-fs = yandex_fuse.main:main - -[sdist] -formats = gztar - -[build-system] -requires = ["setuptools >= 68"] diff --git a/setup.py b/setup.py deleted file mode 100644 index 5adf268..0000000 --- a/setup.py +++ /dev/null @@ -1,73 +0,0 @@ -import os -import shutil -from pathlib import Path -from subprocess import check_call, check_output - -from setuptools import setup - -SERVICE_NAME = "yamusic-fs.service" - -IS_CI = os.getenv("CI") is not None - - -def get_tag() -> str: - if IS_CI: - if not Path("TAG").exists(): - return "" - tag = Path("TAG").read_text().strip() - else: - tag = ( - check_output(["git", "tag", "-l", "--contains", "HEAD"]) - .strip() - .decode() - ) - return tag - - -def get_revisions() -> str: - if IS_CI: - if not Path("REVISIONS").exists(): - return "" - version = Path("REVISIONS").read_text().strip() - else: - version = check_output(["git", "describe", "--tags"]).strip().decode() - return version - - -def pre_setup() -> None: - if Path("VERSION").exists(): - return - tag = get_tag() - if tag: - version = tag.replace("v", "") - else: - revisions = get_revisions() - if revisions: - tag, count_commit, _ = revisions.split("-") - major, minor, revision = tag.split(".") - version = f"{major}.{minor}.dev{count_commit}" - else: - version = "0.0.1" - Path("VERSION").write_text(version) - - -def install() -> None: - if IS_CI: - return - install_system_service_path = Path.home().joinpath( - f".config/systemd/user/{SERVICE_NAME}" - ) - install_system_service_path.parent.mkdir(parents=True, exist_ok=True) - shutil.copy2( - Path(f"contrib/{SERVICE_NAME}"), - install_system_service_path, - ) - - check_call(["systemctl", "daemon-reload", "--user"]) - check_call(["systemctl", "enable", SERVICE_NAME, "--user"]) - - -if __name__ == "__main__": - pre_setup() - setup() - install()