flit icon indicating copy to clipboard operation
flit copied to clipboard

can not using `flit install --symlink` on Windows10

Open youngquan opened this issue 4 years ago • 4 comments

I tried to use flit on Windows 10. However, when I use flit install --symlink to install the package, I run into errors blow:

(venv) PS E:\projects\lingxi> flit install --symlink
...
Traceback (most recent call last):
  File "C:\Program Files\Python37\lib\runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "C:\Program Files\Python37\lib\runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "E:\projects\lingxi\venv\Scripts\flit.exe\__main__.py", line 9, in <module>
  File "e:\projects\lingxi\venv\lib\site-packages\flit\__init__.py", line 171, in main
    pth=args.pth_file).install()
  File "e:\projects\lingxi\venv\lib\site-packages\flit\install.py", line 408, in install
    self.install_directly()
  File "e:\projects\lingxi\venv\lib\site-packages\flit\install.py", line 306, in install_directly
    os.symlink(osp.abspath(self.module.path), dst)
OSError: symbolic link privilege not held

I also found some notes form the python offical docs:

Note On newer versions of Windows 10, unprivileged accounts can create symlinks if Developer Mode is enabled. When Developer Mode is not available/enabled, the SeCreateSymbolicLinkPrivilege privilege is required, or the process must be run as an administrator. OSError is raised when the function is called by an unprivileged user.

It seems that os.symlink can not be used when using unprivileged accounts. However, I can use pip install -e . on Windows, so maybe this is a bug or something?

youngquan avatar Mar 09 '20 15:03 youngquan

Hi, that's basically expected - there's an alternative flag --pth-file which does the same as pip install -e. It's less elegant, but it works on windows.

On Mon, 9 Mar 2020, 16:58 YangQuan, [email protected] wrote:

I tried to use flit on Windows 10. However, when I use flit install --symlink to install the package, I run into errors blow:

(venv) PS E:\projects\lingxi> flit install --symlink ... Traceback (most recent call last): File "C:\Program Files\Python37\lib\runpy.py", line 193, in run_module_as_main "main", mod_spec) File "C:\Program Files\Python37\lib\runpy.py", line 85, in run_code exec(code, run_globals) File "E:\projects\lingxi\venv\Scripts\flit.exe_main.py", line 9, in File "e:\projects\lingxi\venv\lib\site-packages\flit_init.py", line 171, in main pth=args.pth_file).install() File "e:\projects\lingxi\venv\lib\site-packages\flit\install.py", line 408, in install self.install_directly() File "e:\projects\lingxi\venv\lib\site-packages\flit\install.py", line 306, in install_directly os.symlink(osp.abspath(self.module.path), dst) OSError: symbolic link privilege not held

I also found some notes https://docs.python.org/3/library/os.html?highlight=os%20symlink#os.symlink form the python offical docs:

Note On newer versions of Windows 10, unprivileged accounts can create symlinks if Developer Mode is enabled. When Developer Mode is not available/enabled, the SeCreateSymbolicLinkPrivilege privilege is required, or the process must be run as an administrator. OSError is raised when the function is called by an unprivileged user.

It seems that os.symlink can not be used when using unprivileged accounts. However, I can use pip install -e . on Windows, so maybe this is a bug or something?

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/takluyver/flit/issues/325?email_source=notifications&email_token=AACQB5PLZDHQPQ54CTWCKYDRGUG2XA5CNFSM4LEL4WFKYY3PNVWWK3TUL52HS4DFUVEXG43VMWVGG33NNVSW45C7NFSM4ITTZEFA, or unsubscribe https://github.com/notifications/unsubscribe-auth/AACQB5PCXZXFNCXNRAA73CTRGUG2XANCNFSM4LEL4WFA .

takluyver avatar Mar 09 '20 18:03 takluyver

Thanks for you reply. I was in a hurry last night, so I did not see option --pth-file in the docs. I wonder if some advice could be add when the exception above occurs, like:

It seems you are using --symlink on Windows, maybe you can use --pth-file instead.

youngquan avatar Mar 10 '20 15:03 youngquan

Yep, that seems reasonable. I'll leave this open as a feature request.

takluyver avatar Mar 10 '20 16:03 takluyver

@youngquan Did you try running in as administrator in a command prompt, with the symlinks? that should do it.

dougransom avatar Feb 19 '21 22:02 dougransom