Python: get command from sys.argv[0]

I am trying to package a Python tool that get the command to execute from sys.argv[0], but argv0 is patched with a constant path when the program is wrapped. Usually, the tool is symlinked with with different names, so each of the symlinks invokes another command of the tool.

I’ve tried to symlink the executable, but it has no effect. In .xyz-wrapped, sys.argv[0] is set to a constant path. The name of the wrapper (xyz) or any symlinks to the wrapper (abc->xyz) has no effect.

from .xyz-wrapped:

import sys;import site;import functools;sys.argv[0] = '/nix/store/cziamzal6agz9wfbsh23036n3ynkw78l-dnf-plugins-core-4.4.3/bin/dnf-utils-3';functools.reduce(lambda k, p: site.addsitedir(p, k), ['/nix/store/cziamzal6agz9wfbsh23036n3ynkw78l-dnf-plugins-core-4.4.3/lib/python3.11/site-packages','/nix/store/r0vqrgmhpv0saydni9lsy27m8qrpnr51-dnf4-4.18.1-py/lib/python3.11/site-packages','/nix/store/4jr07iw5lkgd6n6cki9621q705hgwfg9-libcomps-0.1.20-py/lib/python3.11/site-packages','/nix/store/wiz174sv6af42z11c0zmhhsh0v4jc978-libdnf-0.72.0-py/lib/python3.11/site-packages','/nix/store/kimlhyds16v1bfn2jgcvxjahzjbaja5q-rpm-4.18.1/lib/python3.11/site-packages'], site._init_pathinfo());

As the path is injected into the wrapped program and not part of the wrapper, the only way I currently see is copying the Python program instead of creating a symlink. Then it would use the name of the copy when it gets wrapped.

Any ideas how to get this working? Someone also had the suspicion that this could be a bug. The wrapper uses exec -a $0 .xyz-wrapped but it seems like the -a flag would never have any effect.