Hi all. I’m working on packaging a Python program using pyproject.nix as explained in the wiki. I’ve got the following in pyproject.toml
, which declares the entrypoint:
[project.scripts]
snapcast-mqtt = "snapcast_mqtt.app:main"
This works fine in nix shell
and the script has no problems finding its own modules. But, when the script tries to invoke one of its own modules as a subprocess using subprocess.Popen
, Python complains it can’t find the module. Effectively, it’s running:
/nix/store/h3i0acpmr8mrjx07519xxmidv8mpax4y-python3-3.12.5/bin/python3.12 -m snapcast_mqtt.server
Despite using the same environment and interpreter as the one that launched the script itself, I get the following:
/nix/store/h3i0acpmr8mrjx07519xxmidv8mpax4y-python3-3.12.5/bin/python3.12: Error while finding module specification for 'snapcast_mqtt.server' (ModuleNotFoundError: No module named 'snapcast_mqtt')
I think the reason the parent process works is because of the magic wrapping that happens within buildPythonPackage
to generate the entrypoint script. How can I similarly bootstrap the Python interpreter invocation?