Hi Thomas,
Thanks for reaching out!
Please try to use pyproject-build-system and include python-setuptools
in the native-inputs. Perhaps include python-wrapper too, since
otherwise patch-shebang might only recognize 'python3', not 'python'.
Access to the source would be useful to give a more concrete advise.
(It's GPL!) But maybe the above is enough already.
Also note that there are two python-pygobject packages, the new
(default) 3.54.3 and the old 3.50.2. Try the new one first, and if that
fails, use python-pygobject-3.50. There are also two python-dbus'es,
1.3 and the older 1.2, but the 1.2 will be removed soon since it does
not work with Python 3.12, so use the (default) 1.3 python-dbus.
The python-build-system is being deprecated; there are no more packages
using it on the python-team branch. But the pyproject-build-system is
usually a drop-in replacement, except that you now explicitly need to
add python-setuptools (since other packagers like poetry and hatch are
supported too).
I don't know enough about wrapping programs to help you there. However,
there seem to be different approaches in other packages that you might
want to experiment with.
Hugo
P.S. one can just source local-file? That's good.
On 26/3/26 10:22, Thomas Danckaert via wrote:
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+)))