diff --git a/Lib/venv/__init__.py b/Lib/venv/__init__.py --- a/Lib/venv/__init__.py +++ b/Lib/venv/__init__.py @@ -52,16 +52,17 @@ class EnvBuilder: """ Create a virtual environment in a directory. :param env_dir: The target directory to create an environment in. """ env_dir = os.path.abspath(env_dir) context = self.ensure_directories(env_dir) + self.check_path(env_dir) self.create_configuration(context) self.setup_python(context) if self.with_pip: self._setup_pip(context) if not self.upgrade: self.setup_scripts(context) self.post_setup(context) @@ -124,16 +125,22 @@ class EnvBuilder: if not os.path.exists(link_path): # Issue #21643 os.symlink('lib', link_path) context.bin_path = binpath = os.path.join(env_dir, binname) context.bin_name = binname context.env_exe = os.path.join(binpath, exename) create_if_needed(binpath) return context + def check_path(self, env_dir): + # space and tab is broken for most UNIX-like systems, and # is broken + # on macOS + if ' ' in env_dir or '\t' in env_dir or '#' in env_dir: + logger.warning('Paths with space, tab or # may break Python scripts') + def create_configuration(self, context): """ Create a configuration file indicating where the environment's Python was copied from, and whether the system site-packages should be made available in the environment. :param context: The information for the environment creation request being processed.