Chi Hsuan Yen added the comment:

Seems there are quite a few typos/copy-paste errors in the original 
steps-to-reproduce. Here are my steps on macOS:

$ ./python-build/python.exe -m venv 'aaa bbb'
$ source ./aaa\ bbb/bin/activate
$ pip
zsh: /Users/yen/tmp/aaa bbb/bin/pip: bad interpreter: "/Users/yen/tmp/aaa: no 
such file or directory

The result is similar on Linux.

Like Alex said, I don't think there's a portable solution, either, so here's a 
patch to warn users for possibly broken paths.

macOS kernel has another bug/limitation. In XNU, '#' symbol also breaks shebang:

$ ./python-build/python.exe -m venv 'aaa#bbb'
$ source ./aaa\#bbb/bin/activate
$ pip
zsh: /Users/yen/tmp/aaa#bbb/bin/pip: bad interpreter: 
/Users/yen/tmp/aaa#bbb/bin/python: no such file or directory

This is even confusing as the kernel thinks the interpreter is 
/Users/yen/tmp/aaa (everything after the first # is thrown away, see [1]) while 
zsh/bash thinks it's /Users/yen/tmp/aaa#bbb/bin/python. As a result, I add a 
warning for #, too

Some related discussions:
1. https://github.com/pypa/pip/issues/923 (pip does not support spaces in 
directories names)
2. https://github.com/pypa/virtualenv/issues/53 (Whitespace in root path of 
virtualenv breaks scripts)
3. https://github.com/pypa/virtualenv/issues/973 (bad interpreter error when 
creating virtualenv's in directories with '#' in name)

Adding venv maintainer and some macOS experts

[1] 
https://opensource.apple.com/source/xnu/xnu-3789.21.4/bsd/kern/kern_exec.c.auto.html,
 line 511

----------
components: +Library (Lib)
keywords: +patch
nosy: +Chi Hsuan Yen, ned.deily, ronaldoussoren, vinay.sajip
versions: +Python 3.6, Python 3.7
Added file: http://bugs.python.org/file45926/venv-check-path.patch

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue28446>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to