Skip to content

Commit b60c3d2

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 cbe3ad5 commit b60c3d2

1 file changed

Lines changed: 31 additions & 3 deletions

File tree

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

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

334-
Known Issues
334+
Known issues
335335
------------
336336

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

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

0 commit comments

Comments
 (0)