44import shutil
55import subprocess
66import sys
7- import zipimport
87from getpass import getuser
98from pathlib import Path
109from tempfile import gettempdir
@@ -751,6 +750,7 @@ def test_pip_install_target():
751750
752751def test_uv_path ():
753752 # `pip install uv` before testing
753+ _clean_paths (root = False )
754754 output = subprocess .check_output (
755755 [sys .executable , "-m" , "zipapps" , "six" , "--uv" , "uv" ], stderr = subprocess .STDOUT
756756 )
@@ -763,6 +763,34 @@ def test_uv_path():
763763 assert b"Collecting six" in output , output .decode ("utf-8" , "replace" )
764764
765765
766+ def test_uvx_zipapps ():
767+ # `pip install uv` before testing
768+ _clean_paths (root = False )
769+ if shutil .which ("uvx" ) is None :
770+ raise RuntimeError ("uvx not found, please install uvx first" )
771+ subprocess .Popen (["uvx" , "--with" , ".." , "zipapps" , "-o" , "app.pyz" , "six" ]).wait ()
772+ proc = subprocess .Popen (
773+ [sys .executable , "app.pyz" , "-c" , "import six;print(six.__file__)" ],
774+ stderr = subprocess .STDOUT ,
775+ stdout = subprocess .PIPE ,
776+ )
777+ output = proc .communicate ()[0 ]
778+ assert b"app.pyz" in output , output .decode ("utf-8" , "replace" )
779+ _clean_paths (root = False )
780+ if shutil .which ("uvx" ) is None :
781+ raise RuntimeError ("uvx not found, please install uvx first" )
782+ subprocess .Popen (
783+ ["uvx" , "--with" , ".." , "zipapps" , "-o" , "app.pyz" , "--uv" , "uv" , "six" ]
784+ ).wait ()
785+ proc = subprocess .Popen (
786+ [sys .executable , "app.pyz" , "-c" , "import six;print(six.__file__)" ],
787+ stderr = subprocess .STDOUT ,
788+ stdout = subprocess .PIPE ,
789+ )
790+ output = proc .communicate ()[0 ]
791+ assert b"app.pyz" in output , output .decode ("utf-8" , "replace" )
792+
793+
766794def main ():
767795 """
768796 test all cases
0 commit comments