Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 4db86bc

Browse files
committed
Changes pyvenv.cfg trick into an actual sys.path file.
1 parent 783c9ef commit 4db86bc

5 files changed

Lines changed: 154 additions & 99 deletions

File tree

Doc/using/windows.rst

Lines changed: 30 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,13 @@ Supported Versions
2929

3030
As specified in :pep:`11`, a Python release only supports a Windows platform
3131
while Microsoft considers the platform under extended support. This means that
32-
Python 3.5 supports Windows Vista and newer. If you require Windows XP support
32+
Python 3.6 supports Windows Vista and newer. If you require Windows XP support
3333
then please install Python 3.4.
3434

3535
Installation Steps
3636
------------------
3737

38-
Four Python 3.5 installers are available for download - two each for the 32-bit
38+
Four Python 3.6 installers are available for download - two each for the 32-bit
3939
and 64-bit versions of the interpreter. The *web installer* is a small initial
4040
download, and it will automatically download the required components as
4141
necessary. The *offline installer* includes the components necessary for a
@@ -193,13 +193,13 @@ of available options is shown below.
193193
For example, to silently install a default, system-wide Python installation,
194194
you could use the following command (from an elevated command prompt)::
195195

196-
python-3.5.0.exe /quiet InstallAllUsers=1 PrependPath=1 Include_test=0
196+
python-3.6.0.exe /quiet InstallAllUsers=1 PrependPath=1 Include_test=0
197197

198198
To allow users to easily install a personal copy of Python without the test
199199
suite, you could provide a shortcut with the following command. This will
200200
display a simplified initial page and disallow customization::
201201

202-
python-3.5.0.exe InstallAllUsers=0 Include_launcher=0 Include_test=0
202+
python-3.6.0.exe InstallAllUsers=0 Include_launcher=0 Include_test=0
203203
SimpleInstall=1 SimpleInstallDescription="Just for me, no test suite."
204204

205205
(Note that omitting the launcher also omits file associations, and is only
@@ -234,13 +234,13 @@ where a large number of installations are going to be performed it is very
234234
useful to have a locally cached copy.
235235

236236
Execute the following command from Command Prompt to download all possible
237-
required files. Remember to substitute ``python-3.5.0.exe`` for the actual
237+
required files. Remember to substitute ``python-3.6.0.exe`` for the actual
238238
name of your installer, and to create layouts in their own directories to
239239
avoid collisions between files with the same name.
240240

241241
::
242242

243-
python-3.5.0.exe /layout [optional target directory]
243+
python-3.6.0.exe /layout [optional target directory]
244244

245245
You may also specify the ``/quiet`` option to hide the progress display.
246246

@@ -345,7 +345,7 @@ User level and the System level, or temporarily in a command prompt.
345345
To temporarily set environment variables, open Command Prompt and use the
346346
:command:`set` command::
347347

348-
C:\>set PATH=C:\Program Files\Python 3.5;%PATH%
348+
C:\>set PATH=C:\Program Files\Python 3.6;%PATH%
349349
C:\>set PYTHONPATH=%PYTHONPATH%;C:\My_python_lib
350350
C:\>python
351351

@@ -401,10 +401,10 @@ Finding the Python executable
401401

402402
Besides using the automatically created start menu entry for the Python
403403
interpreter, you might want to start Python in the command prompt. The
404-
installer for Python 3.5 and later has an option to set that up for you.
404+
installer for Python 3.6 has an option to set that up for you.
405405

406-
On the first page of the installer, an option labelled "Add Python 3.5 to
407-
PATH" can be selected to have the installer add the install location into the
406+
On the first page of the installer, an option labelled "Add Python to PATH"
407+
may be selected to have the installer add the install location into the
408408
:envvar:`PATH`. The location of the :file:`Scripts\\` folder is also added.
409409
This allows you to type :command:`python` to run the interpreter, and
410410
:command:`pip` for the package installer. Thus, you can also execute your
@@ -418,7 +418,7 @@ of your Python installation, delimited by a semicolon from other entries. An
418418
example variable could look like this (assuming the first two entries already
419419
existed)::
420420

421-
C:\WINDOWS\system32;C:\WINDOWS;C:\Program Files\Python 3.5
421+
C:\WINDOWS\system32;C:\WINDOWS;C:\Program Files\Python 3.6
422422

423423
.. _launcher:
424424

@@ -720,7 +720,15 @@ installation directory. So, if you had installed Python to
720720
:file:`C:\\Python\\Lib\\` and third-party modules should be stored in
721721
:file:`C:\\Python\\Lib\\site-packages\\`.
722722

723-
This is how :data:`sys.path` is populated on Windows:
723+
To completely override :data:`sys.path`, create a text file named ``'sys.path'``
724+
containing a list of paths alongside the Python executable. This will ignore all
725+
registry settings and environment variables, enable isolated mode, disable
726+
importing :mod:`site`, and fill :data:`sys.path` with exactly the paths listed
727+
in the file. Paths may be absolute or relative to the directory containing the
728+
file.
729+
730+
When the ``'sys.path'`` file is missing, this is how :data:`sys.path` is
731+
populated on Windows:
724732

725733
* An empty entry is added at the start, which corresponds to the current
726734
directory.
@@ -755,10 +763,6 @@ directory one level above the executable, the following variations apply:
755763
path is used instead of the path to the main executable when deducing the
756764
home location.
757765

758-
* If ``applocal`` is set to true, the ``home`` property or the main executable
759-
is always used as the home path, and all environment variables or registry
760-
values affecting the path are ignored. The landmark file is not checked.
761-
762766
The end result of all this is:
763767

764768
* When running :file:`python.exe`, or any other .exe in the main Python
@@ -777,13 +781,11 @@ The end result of all this is:
777781
For those who want to bundle Python into their application or distribution, the
778782
following advice will prevent conflicts with other installations:
779783

780-
* Include a ``pyvenv.cfg`` file alongside your executable containing
781-
``applocal = true``. This will ensure that your own directory will be used to
782-
resolve paths even if you have included the standard library in a ZIP file.
783-
It will also ignore user site-packages and other paths listed in the
784-
registry.
784+
* Include a ``sys.path`` file alongside your executable containing the
785+
directories to include. This will ignore user site-packages and other paths
786+
listed in the registry or in environment variables.
785787

786-
* If you are loading :file:`python3.dll` or :file:`python35.dll` in your own
788+
* If you are loading :file:`python3.dll` or :file:`python36.dll` in your own
787789
executable, explicitly call :c:func:`Py_SetPath` or (at least)
788790
:c:func:`Py_SetProgramName` before :c:func:`Py_Initialize`.
789791

@@ -801,6 +803,11 @@ Otherwise, your users may experience problems using your application. Note that
801803
the first suggestion is the best, as the other may still be susceptible to
802804
non-standard paths in the registry and user site-packages.
803805

806+
.. versionchanged:: 3.6
807+
808+
Adds ``sys.path`` file support and removes ``applocal`` option from
809+
``pyvenv.cfg``.
810+
804811
Additional modules
805812
==================
806813

@@ -900,7 +907,7 @@ directly accessed by end-users.
900907
When extracted, the embedded distribution is (almost) fully isolated from the
901908
user's system, including environment variables, system registry settings, and
902909
installed packages. The standard library is included as pre-compiled and
903-
optimized ``.pyc`` files in a ZIP, and ``python3.dll``, ``python35.dll``,
910+
optimized ``.pyc`` files in a ZIP, and ``python3.dll``, ``python36.dll``,
904911
``python.exe`` and ``pythonw.exe`` are all provided. Tcl/tk (including all
905912
dependants, such as Idle), pip and the Python documentation are not included.
906913

Lib/site.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -463,12 +463,6 @@ def venv(known_paths):
463463
system_site = value.lower()
464464
elif key == 'home':
465465
sys._home = value
466-
elif key == 'applocal' and value.lower() == 'true':
467-
# App-local installs use the exe_dir as prefix,
468-
# not one level higher, and do not use system
469-
# site packages.
470-
site_prefix = exe_dir
471-
system_site = 'false'
472466

473467
sys.prefix = sys.exec_prefix = site_prefix
474468

0 commit comments

Comments
 (0)