Skip to content

refactor!: restructure project to use proper src-layout #844

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Mar 10, 2025

Conversation

CyanVoxel
Copy link
Member

@CyanVoxel CyanVoxel commented Mar 7, 2025

Summary

This PR introduces a large refactor that moves files in order to properly align with what should be a proper "src-layout". A standard Python project layout is what was intended from the start of this project, but after a deeper level of research combined with a number of ongoing issues has made it clear that the current project structure is not only incorrect, but actively causes issues in a number of areas.

Changes

This PR introduces the following changes:

  • Restructured the project files to a standard (or close enough) src-layout
  • Removed old and unused build and start scripts
  • Moved requirements from requirements.txt and requirements-dev.txt to pyproject.toml and deleted the former files
  • Updated workflows to use to rely more on pyproject.toml along with other code de-duplication and improvments
  • Updated various code to comply with the new formatting and linting checks that arose as a result of correcting the project structure
  • Refactored the module import structure to begin with tagstudio in place of src
  • Replaced any relative module imports with absolute ones

Why?

This refactor fixes a number of longstanding issues while opening up the door for new development QoL features and Python-specific packaging.

  • IDEs should no longer be confused as whether or not to import local modules as tagstudio.src. or src.
  • Workflows can now read requirements and versions directly from the pyproject.toml instead of duplicating them in the workflow files and letting the versions get out of sync
  • MyPy is now able to detect additional issues due to the corrected project structure
  • Manual path overrides for MyPy are no longer required in configs
  • Dependency managers such as uv and Poetry 2.0 can be used by developers with no further requirements or maintenance overhead on our side
  • TagStudio can now be installed via pip, both for users and developers
  • TagStudio can now be packaged for NixOS

Tasks Completed

  • Platforms Tested:
    • Windows x86
    • Windows ARM
    • macOS x86
    • macOS ARM
    • Linux x86 (NixOS)
    • Linux ARM
  • Tested For:
    • Basic functionality
    • PyInstaller executable

Closes #200, Closes #365, Closes #512, Closes #800

@CyanVoxel CyanVoxel added Type: Refactor Code that needs to be restructured or cleaned up Type: CI Continuous Integration / workflows Priority: High An important issue requiring attention labels Mar 7, 2025
@CyanVoxel CyanVoxel added this to the Alpha v9.5.2 milestone Mar 7, 2025
@CyanVoxel CyanVoxel moved this to 🚧 In progress in TagStudio Development Mar 7, 2025
Copy link
Collaborator

@Computerdores Computerdores left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a couple of nits.
What else are you planning to add before merging? Because this PR is quite big already (which is also why I went and reviewed this already despite still being a draft)

@xarvex
Copy link
Member

xarvex commented Mar 8, 2025

This became a big refactor almost accidentally. Initially the change was going to be regarding having one proper pip module, which showed the problem with the existing layout. Of course, in changing both of these things, that propagates throughout, essentially, the entire project.

All to say, any other changes done are to facilitate that adjustment. There is no other upheaval planned for this PR outside accomplishing that initial task.

Copy link
Collaborator

@Computerdores Computerdores left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can confirm that the pipewire error of the nix flake is gone for me too

@xarvex xarvex linked an issue Mar 9, 2025 that may be closed by this pull request
@xarvex xarvex removed a link to an issue Mar 9, 2025
xarvex and others added 2 commits March 9, 2025 18:54
Fixes: #200
Fixes: #365
Fixes: #512
Fixes: #800

fix(pyproject): resolve mix-up of mypy and pytest

chore(ci): remove legacy scripts

chore: format with new mypy rules; fix translation test

wip(ci/mypy): remove config flag

fix(pyinstaller): use correct dict access

fix(resources): usage in ts_qt.py

feat(nix/package): validate tests with pytest hook

fix(nix/package): remove old dependency patch

feat(nix): support Darwin

fix(nix/package): move check deps to checkInputs

fix(nix/shell): typo

fix(nix/shell): correctly wrap Python with Qt args

fix(pyproject): specify mypy-extensions

feat(nix/package): provide pillow-jxl-plugin

nix(nix/package): split into multiple files, allow overriding of JXL and vtf2img

fix(nix/shell): provide FFmpeg on runtime

feat(flake): output pillow-jxl-plugin and vtf2img

fix(nix/package): load pipewire

feat(nix/package): run tests on pillow-jxl-plugin

fix: remove extra noqa comment

docs: update installation docs

docs: shrink table size on docs site

nit(nix/package): pipewire not needed in buildInputs

docs: update commands, environment, setup

fix: use consistent possessives

chore: format with prettier, add ignore flags

fix(pyinstaller): consume from pyproject

Revert "fix(pyinstaller): consume from pyproject"

This reverts commit 398cd4e.

refactor: use icon from resource manager

Also fixes incorrect path currently used in ts_qt.py.

nix(pyinstaller): replace use of sys.platform with platform.system

docs: add build section

Co-authored-by: Travis Abendshien <46939827+CyanVoxel@users.noreply.github.com>
@xarvex xarvex force-pushed the layout-refactor-1 branch from 6ae67d0 to 55bc7aa Compare March 10, 2025 00:06
@xarvex xarvex marked this pull request as ready for review March 10, 2025 00:07
@xarvex xarvex moved this from 🚧 In progress to 🍃 Pending Merge in TagStudio Development Mar 10, 2025
@xarvex xarvex added the Status: Mergeable The code is ready to be merged label Mar 10, 2025
@xarvex
Copy link
Member

xarvex commented Mar 10, 2025

Manually squashed, as there has to be two commits for git history to be preserved for each file: one for the rename, and another for changes done.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Priority: High An important issue requiring attention Type: CI Continuous Integration / workflows Type: Documentation Additions/changes to documentation Type: Refactor Code that needs to be restructured or cleaned up
Projects
Status: ✅ Done
3 participants