axeldelafosse / stemgen

🎛 Stemgen is a Stem file generator. Convert any track into a Stem and have fun with Traktor.
https://stemgen.dev
MIT License
212 stars 39 forks source link

Infinite recursion when installed via pipx #51

Open fwcd opened 3 months ago

fwcd commented 3 months ago

Running pipx install stemgen and then stemgen seems to cause infinite recursion:

Traceback (most recent call last):
  File "/Users/<user>/.local/bin/stemgen", line 10, in <module>
    sys.exit(main())
             ^^^^^^
  File "/Users/<user>/Library/Application Support/pipx/venvs/stemgen/lib/python3.12/site-packages/cli/stemgen/__init__.py", line 12, in main
    stemgen.main()
  File "/Users/<user>/Library/Application Support/pipx/venvs/stemgen/lib/python3.12/site-packages/cli/stemgen/__init__.py", line 12, in main
    stemgen.main()
  File "/Users/<user>/Library/Application Support/pipx/venvs/stemgen/lib/python3.12/site-packages/cli/stemgen/__init__.py", line 12, in main
    stemgen.main()
  File "/Users/<user>/Library/Application Support/pipx/venvs/stemgen/lib/python3.12/site-packages/cli/stemgen/__init__.py", line 12, in main
    stemgen.main()
  [Previous line repeated 995 more times]
RecursionError: maximum recursion depth exceeded

This seems to be an issue with the sys.path logic: The script seems to run from the cli/stemgen directory, but outside the repository, so it cannot find the actual stemgen.py script.

My recommendation would be to put everything under a top-level package named stemgen (so it can be installed properly), move the script implementations into the package, e.g. under stemgen.cli, and then point your entry points in setup.cfg to those functions. The top-level scripts in the repo (stemgen.py et al.) could then be simple wrappers that import the package (stemgen.cli.something) and call their main.