Skip to content

Commit e2e8ec0

Browse files
GH-95029: Describe Windows Store package isolation and redirection in more detail (GH-95030)
(cherry picked from commit b1924b1) Co-authored-by: Anthony Shaw <anthony.p.shaw@gmail.com>
1 parent 57375d1 commit e2e8ec0

File tree

1 file changed

+31
-3
lines changed

1 file changed

+31
-3
lines changed

Doc/using/windows.rst

Lines changed: 31 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ developers using Python for any kind of project.
3434

3535
:ref:`windows-store` is a simple installation of Python that is suitable for
3636
running scripts and packages, and using IDLE or other development environments.
37-
It requires Windows 10, but can be safely installed without corrupting other
37+
It requires Windows 10 and above, but can be safely installed without corrupting other
3838
programs. It also provides many convenient commands for launching Python and
3939
its tools.
4040

@@ -335,14 +335,42 @@ Python in Start and right-click to select Uninstall. Uninstalling will
335335
remove all packages you installed directly into this Python installation, but
336336
will not remove any virtual environments
337337

338-
Known Issues
338+
Known issues
339339
------------
340340

341+
Redirection of local data, registry, and temporary paths
342+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
343+
341344
Because of restrictions on Microsoft Store apps, Python scripts may not have
342-
full write access to shared locations such as ``TEMP`` and the registry.
345+
full write access to shared locations such as :envvar:`TEMP` and the registry.
343346
Instead, it will write to a private copy. If your scripts must modify the
344347
shared locations, you will need to install the full installer.
345348

349+
At runtime, Python will use a private copy of well-known Windows folders and the registry.
350+
For example, if the environment variable :envvar:`%APPDATA%` is :file:`c:\\Users\\<user>\\AppData\\`,
351+
then when writing to :file:`C:\\Users\\<user>\\AppData\\Local` will write to
352+
:file:`C:\\Users\\<user>\\AppData\\Local\\Packages\\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\\LocalCache\\Local\\`.
353+
354+
When reading files, Windows will return the file from the private folder, or if that does not exist, the
355+
real Windows directory. For example reading :file:`C:\\Windows\\System32` returns the contents of :file:`C:\\Windows\\System32`
356+
plus the contents of :file:`C:\\Program Files\\WindowsApps\\package_name\\VFS\\SystemX86`.
357+
358+
You can find the real path of any existing file using :func:`os.path.realpath`:
359+
360+
.. code-block:: python
361+
362+
>>> import os
363+
>>> test_file = 'C:\\Users\\example\\AppData\\Local\\test.txt'
364+
>>> os.path.realpath(test_file)
365+
'C:\\Users\\example\\AppData\\Local\\Packages\\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\\LocalCache\\Local\\test.txt'
366+
367+
When writing to the Windows Registry, the following behaviors exist:
368+
369+
* Reading from ``HKLM\\Software`` is allowed and results are merged with the :file:`registry.dat` file in the package.
370+
* Writing to ``HKLM\\Software`` is not allowed if the corresponding key/value exists, i.e. modifying existing keys.
371+
* Writing to ``HKLM\\Software`` is allowed as long as a corresponding key/value does not exist in the package
372+
and the user has the correct access permissions.
373+
346374
For more detail on the technical basis for these limitations, please consult
347375
Microsoft's documentation on packaged full-trust apps, currently available at
348376
`docs.microsoft.com/en-us/windows/msix/desktop/desktop-to-uwp-behind-the-scenes

0 commit comments

Comments
 (0)