-
-
Notifications
You must be signed in to change notification settings - Fork 81
Python from the Windows store alias paths #90
Copy link
Copy link
Closed
Labels
bugSomething isn't workingSomething isn't workinghelp wantedExtra attention is neededExtra attention is needed
Description
Not sure if this a bug in platformdirs, but users will hit this issue so I'll share my observations
Platform dirs will return the environment variable path for things like data dir, log dir for the Python from the Windows Store.
Python in the Windows store uses app execution aliases, so the actual path is something else.
For example:
>>> import platformdirs, os
>>> d = platformdirs.user_data_dir(appname="foo", appauthor="bar")
>>> os.makedirs(d)
>>> d
'C:\\Users\\anthonyshaw\\AppData\\Local\\bar\\foo\\'
>>> test_file = os.path.join(d, 'test.txt')
>>> test_file
'C:\\Users\\anthonyshaw\\AppData\\Local\\bar\\foo\\test.txt'
>>> os.path.realpath(test_file)
'C:\\Users\\anthonyshaw\\AppData\\Local\\Packages\\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\\LocalCache\\Local\\bar\\foo\\test.txt'This causes issues when you launch a process and use that path for something (e.g. where you created a file), but the process will resolve to a different path.
This can be disabled in apps > advanced app settings > app execution aliases in Windows.
NB: os.path.realpath only resolves this redirection in Python 3.8+ and it only works for files, not directories.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't workinghelp wantedExtra attention is neededExtra attention is needed