linkedin / shiv

shiv is a command line utility for building fully self contained Python zipapps as outlined in PEP 441, but with all their dependencies included.
BSD 2-Clause "Simplified" License
1.73k stars 94 forks source link

Repetition of `site-packages\build\lib\build\lib\...` #220

Open jonas-hagen opened 2 years ago

jonas-hagen commented 2 years ago

When creating a shiv package, the path site-packages\build\lib\build\lib\... is repeated multiple times and ends up being very long: \site-packages\build\lib\build\lib\build\lib\build\lib\build\lib\build\lib\build\lib\build\lib\build\lib\build\lib\build\lib\build\lib\build\lib\build\lib\build\lib\mytools\

Versions: shiv 1.0.1 and python 3.10 Command used to create package: shiv -e mytool.cli:cli -o mytool.pyz .

Then, when executing the archive we experience some strange problems only on Windows systems which are configured in French language. Other systems we have at hand (German and English) do not show this behavior and the shiv package runs as expected. Python version (and python installation) is the same on all systems.

This is the error we get on French systems:

Traceback (most recent call last):
  File "C:\Program Files\Python310\lib\runpy.py", line 196, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "C:\Program Files\Python310\lib\runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "D:\paths\mytool.pyz\__main__.py", line 3, in <module>
  File "D:\paths\mytools.pyz\_bootstrap\__init__.py", line 197, in bootstrap
  File "D:\paths\mytool.pyz\_bootstrap\__init__.py", line 137, in extract_site_packages
  File "C:\Program Files\Python310\lib\zipfile.py", line 1628, in extract
    return self._extract_member(member, path, pwd)
  File "C:\Program Files\Python310\lib\zipfile.py", line 1691, in _extract_member
    os.makedirs(upperdirs)
  File "C:\Program Files\Python310\lib\os.py", line 215, in makedirs
    makedirs(head, exist_ok=exist_ok)
  File "C:\Program Files\Python310\lib\os.py", line 215, in makedirs
    makedirs(head, exist_ok=exist_ok)
  File "C:\Program Files\Python310\lib\os.py", line 215, in makedirs
    makedirs(head, exist_ok=exist_ok)
  [Previous line repeated 4 more times]
  File "C:\Program Files\Python310\lib\os.py", line 225, in makedirs
    mkdir(name, mode)
FileNotFoundError: [WinError 206] Nom de fichier ou extension trop long: 'C:\\Users\\XYZ\\.shiv\\mytool.pyz_bd23d769b67428a55f59e57861d9e79feb6ac7d6ca7b6156b777d17bd09a877b.tmp\\site-packages\\build\\lib\\build\\lib\\build\\lib\\build\\lib\\build\\lib\\build\\lib\\build\\lib\\build\\lib\\build\\lib\\build\\lib\\build\\lib\\build\\lib'

We think this path should not be repeated in the first place. Where does it come from? What should \site-packages\build\lib actually contain? It is not present in my virtual environment (\site-packages\build is present).

lorencarvalho commented 2 years ago

Hi @jonas-hagen,

Sorry for the delay in responding to this issue! This is a tricky one, I don't currently have access to a windows machine to test on but I will in the coming week or two. An example repository that you can consistently reproduce with would be extremely helpful for debugging, if you have one handy.