Update test/ros2nix to set correct argv[0]

This commit is contained in:
Michal Sojka 2025-02-09 14:28:07 +01:00
parent 6b1e2ed106
commit 12a9d8de83

View file

@ -1,5 +1,19 @@
#!/usr/bin/env bash #!/usr/bin/env python3
DIR=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")/.." &> /dev/null && pwd) # Script for easy testing of ros2nix during development, i.e., without
export PYTHONPATH="$DIR:$PYTHONPATH" # installation. You can add the directory of this script to PATH and
exec python3 -m ros2nix "$@" # run ros2nix command.
import sys
import re
from pathlib import Path
if __name__ == '__main__' and __package__ is None:
file = Path(__file__).resolve()
sys.path.append(str(file.parents[1]))
from ros2nix.ros2nix import main
sys.argv[0] = __file__
sys.argv[0] = re.sub(r"(-script\.pyw|\.exe)?$", "", sys.argv[0])
sys.exit(main())