Hi Thomas I strongly recommend to use a pyproject.toml [1] file, even for simple packages like yours. It is easy and quick to write and you can specify your script there [2]. Then pyproject-build-system takes care of everything and you don't have to use custom wrappers.
Best, Reza [1] https://packaging.python.org/en/latest/guides/writing-pyproject-toml/ [2] https://packaging.python.org/en/latest/guides/creating-command-line-tools/ > Hi friendly people of guix, > > I have a custom package (definition below) which wraps a single > python script. This has worked well, but I noticed that since I ran > guix pull and reconfigured my system at the end of january, my python > script doesn't get the right shebang anymore. > > Where my python script used to get a shebang like > > #!/gnu/store/...-python-wrapper-3.11.14/bin/python > > It's now just > > #!python > > which doesn't work. > > My python package still uses a setup.py. I also wrap the executable > script using 'wrap-program' to set a few environment variables, > perhaps this has an impact? > > During the build, it looks like patch-shebangs is working as > intended, from the output: > > patch-shebang: ./listen_dbus.py: changing `/usr/bin/python' to > `/gnu/store/81l90y4w90wf8c5gj0042x3pikadzchm-python-wrapper-3.11.14/bin/python' > > but it seems that during one of the next phases, the shebang is > changed again (could this be related to wrap-program?). I noticed > that there is now also 'wrap-script', which looks like what I need > when I read the documentation. However, if I change my package to > use wrap-script, the build fails with an exception > “no-interpreter-found” > > thank you for reading this far! > > Thomas > > (define-public backup-daemon > (package > (name "backup-daemon") > (version "1.0") > (source (local-file "./backup-daemon" #:recursive? #t)) > (build-system python-build-system) > (inputs > `(("rsnapshot" ,rsnapshot) > ("python-dbus" ,python-dbus) > ("python-pygobject" ,python-pygobject) > ("glib" ,glib))) > (arguments > `(#:tests? #f > #:phases > (modify-phases %standard-phases > (add-after 'install 'wrap-executable > (lambda* (#:key inputs outputs #:allow-other-keys) > (let ((out (assoc-ref outputs "out")) > (rsnapshot (assoc-ref inputs "rsnapshot")) > (glib (assoc-ref inputs "glib"))) > (wrap-program (string-append out > "/bin/listen_dbus.py") > `("PATH" ":" prefix > (,(string-append rsnapshot "/bin"))) > `("GI_TYPELIB_PATH" ":" prefix > (,(string-append glib > "/lib/girepository-1.0")))))))))) > (synopsis "Script to make weekly/monthly/yearly rsnapshot > backups") > (description "The backup daemon takes a config file for rsnapshot, > a partition UUID, and a backup directory as command line arguments. > When started, it listens for DBus signals from UDisks to detect if a > partition with the correct UUID is mounted. When the desired > partition is mounted, it runs rsnapshot with the given > configuration.") > (home-page "file:///home/thomas") > (license license:gpl3+)))
