pex-tool / pex

A tool for generating .pex (Python EXecutable) files, lock files and venvs.
https://docs.pex-tool.org/
Apache License 2.0
2.53k stars 258 forks source link

pex fails in a non-elevated Windows session #111

Open pfmoore opened 9 years ago

pfmoore commented 9 years ago

I just tried one of the simple examples from the pex documentation on Windows:

PS 19:27 (VE-1) C:\Work\Scratch
->pip install --pre pex
You are using pip version 6.1.1, however version 7.0.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
Collecting pex
  Downloading pex-1.0.0.dev3-py2.py3-none-any.whl (89kB)
    100% |################################| 90kB 1.4MB/s
Requirement already satisfied (use --upgrade to upgrade): setuptools<16,>=2.2 in c:\users\gustav\appdata\local\temp\ve-1\lib\site-packages (from pex)
Installing collected packages: pex
Successfully installed pex-1.0.0.dev3
PS 19:27 (VE-1) {00:03} C:\Work\Scratch
->pex requests psutil
Traceback (most recent call last):
  File "C:\Apps\Python34\Lib\runpy.py", line 170, in _run_module_as_main
    "__main__", mod_spec)
  File "C:\Apps\Python34\Lib\runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "C:\Users\Gustav\AppData\Local\Temp\VE-1\Scripts\pex.exe\__main__.py", line 9, in <module>
  File "C:\Users\Gustav\AppData\Local\Temp\VE-1\lib\site-packages\pex\bin\pex.py", line 506, in main
    pex_builder = build_pex(reqs, options, resolver_options_builder)
  File "C:\Users\Gustav\AppData\Local\Temp\VE-1\lib\site-packages\pex\bin\pex.py", line 444, in build_pex
    interpreter = interpreter_from_options(options)
  File "C:\Users\Gustav\AppData\Local\Temp\VE-1\lib\site-packages\pex\bin\pex.py", line 437, in interpreter_from_options
    interpreter = resolve(interpreter, WHEEL_REQUIREMENT)
  File "C:\Users\Gustav\AppData\Local\Temp\VE-1\lib\site-packages\pex\bin\pex.py", line 410, in resolve_interpreter
    installer_provider)
  File "C:\Users\Gustav\AppData\Local\Temp\VE-1\lib\site-packages\pex\bin\pex.py", line 380, in _resolve_and_link_interpreter
    _safe_link(target_location, target_link)
  File "C:\Users\Gustav\AppData\Local\Temp\VE-1\lib\site-packages\pex\bin\pex.py", line 355, in _safe_link
    os.symlink(src, dst)
OSError: symbolic link privilege not held

It looks like pex requires symlink support which is not available on Windows except in an elevated session.

jenisys commented 8 years ago

I run into similar issues on Windows. It would be helpful if the documentation (or README) states the supported and unsupported platforms. The metadata in the setup.py currently states that pex is supported on any platform (by leaving out platform specific details and stating that it is OS independent).

erikfa commented 8 years ago

Same here. Fresh installation of "WinPython-64bit-3.5.1.1Zero.exe":

>pip install pex

Collecting pex
  Using cached pex-1.1.2-py2.py3-none-any.whl
Requirement already satisfied (use --upgrade to upgrade): setuptools<20,>=2.2 in c:\users\erik\documents\winpython-64bit-3.5.1.1zero\python-3.5.1.amd64\lib\site-packages (from pex)
Installing collected packages: pex
Successfully installed pex-1.1.2

C:\Users\Erik\Documents\WinPython-64bit-3.5.1.1Zero\python-3.5.1.amd64>pex
Traceback (most recent call last):
  File "C:\Users\Erik\Documents\WinPython-64bit-3.5.1.1Zero\python-3.5.1.amd64\lib\runpy.py", line 170, in _run_module_as_main
    "__main__", mod_spec)
  File "C:\Users\Erik\Documents\WinPython-64bit-3.5.1.1Zero\python-3.5.1.amd64\lib\runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "C:\Users\Erik\Documents\WinPython-64bit-3.5.1.1Zero\python-3.5.1.amd64\Scripts\pex.exe\__main__.py", line 9, in <module>
  File "C:\Users\Erik\Documents\WinPython-64bit-3.5.1.1Zero\python-3.5.1.amd64\lib\site-packages\pex\bin\pex.py", line 509, in main
    pex_builder = build_pex(reqs, options, resolver_options_builder)
  File "C:\Users\Erik\Documents\WinPython-64bit-3.5.1.1Zero\python-3.5.1.amd64\lib\site-packages\pex\bin\pex.py", line 444, in build_pex
    interpreter = interpreter_from_options(options)
  File "C:\Users\Erik\Documents\WinPython-64bit-3.5.1.1Zero\python-3.5.1.amd64\lib\site-packages\pex\bin\pex.py", line 437, in interpreter_from_options
    interpreter = resolve(interpreter, WHEEL_REQUIREMENT)
  File "C:\Users\Erik\Documents\WinPython-64bit-3.5.1.1Zero\python-3.5.1.amd64\lib\site-packages\pex\bin\pex.py", line 410, in resolve_interpreter
    installer_provider)
  File "C:\Users\Erik\Documents\WinPython-64bit-3.5.1.1Zero\python-3.5.1.amd64\lib\site-packages\pex\bin\pex.py", line 380, in _resolve_and_link_interpreter
    _safe_link(target_location, target_link)
  File "C:\Users\Erik\Documents\WinPython-64bit-3.5.1.1Zero\python-3.5.1.amd64\lib\site-packages\pex\bin\pex.py", line 355, in _safe_link
    os.symlink(src, dst)
OSError: symbolic link privilege not held
skvark commented 8 years ago

I'm also very interested in Windows support. Setup.py indeed claims that pex supports any platform but it's clearly not true since the examples do not work.

padmanabani86 commented 4 years ago

The issue still remains even with pex 2.1.14. Is there any workaround or fix for this issue without using the elevated mode?

jsirois commented 2 years ago

Pex has never supported Windows, so the fact it ever worked in an elevated session was by luck!

Apologies for the lack of attention to this issue. The active developers of Pex have never been active Windows users - just Linux and Mac; so we never added support. A few folks tried to step up to the plate with PRs, but there are alot of tests to fix and that thwarted all comers.

That said, I'm actively working on Windows support. I bit the bullet and have been working in Windows for the last few weeks getting thinks working.

The initial release will support Python >= 3.8 but still requires an elevated session / developer mode in newer Windows. I think this makes sense for creators of PEX files (Pex build time) since people doing that are - almost by definition - developers. For end users though, this is not acceptable. I should be able to email a PEX to grandma and have her be able to double-click and run it ... mod other issues like a default .pyz association, etc.

The task of getting the test base green on Windows was large and I didn't really expect anyone to have the time to devote to that. Once I'm done though they'll be a green CI with 5 new Windows shards covering Python + Pip permutations; so, hopefully, that will make it more attractive for someone to come in and pitch in help on support for no-symlinks support and no long path aware support. Althoug my current work does get simple Python 2.7 / Python 3.7 cowsay PEXes buildable and runnable, the advanced features of Pex like --venv mode and all aspects of lockfile creation and consumption will need work to handle short paths and lack of symlinks.