Closed sudarshanvm closed 1 year ago
Hi @sudarshanvm,
A pyz
created with shiv should work exactly as you describe. In fact, internally at LinkedIn we sometimes package multiple CLIs that share a set of dependencies this way. Another option is to use the pyz
as the shebang for a script, like so:
$ shiv httpx -o httpx.pyz --quiet
$ cat << EOF > tryme.py
> #!/usr/bin/env httpx.pyz
>
> import httpx
> url = "https://shiv.readthedocs.io"
> response = httpx.get(url)
> print(f"Got {response.status_code} from {url}!")
>
> EOF
$ chmod +x tryme.py
$ ./tryme.py
Got 200 from https://shiv.readthedocs.io!
Suppose I have 3 files : requirements.txt, module1.py and module2.py I need to bake a single shiv executable with all the dependencies specified inside requirements.txt and later I want to use the same shiv executable for running module1.py as well as module2.py
can we do something like:
shiv requirements.txt -o shiv.pyz
export SHIV_ENTRY_POINT=module1:main
and then./shiv.pyz
should run the module1 scriptexport SHIV_ENTRY_POINT=module2:main
and then./shiv.pyz
should run the module2 scriptdoes this work? do we have any alternative to do that?
Thanks, Sudarshan