Skip to content

Commit b1924b1

Browse files
authored
GH-95029: Describe Windows Store package isolation and redirection in more detail (GH-95030)
1 parent 6e2fbda commit b1924b1

File tree

1 file changed

+31
-3
lines changed

1 file changed

+31
-3
lines changed

Doc/using/windows.rst

+31-3
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

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

351-
Known Issues
351+
Known issues
352352
------------
353353

354+
Redirection of local data, registry, and temporary paths
355+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
356+
354357
Because of restrictions on Microsoft Store apps, Python scripts may not have
355-
full write access to shared locations such as ``TEMP`` and the registry.
358+
full write access to shared locations such as :envvar:`TEMP` and the registry.
356359
Instead, it will write to a private copy. If your scripts must modify the
357360
shared locations, you will need to install the full installer.
358361

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

0 commit comments

Comments
 (0)