Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Figure out what to do with Windows Store Python #26

Open
ericoporto opened this issue Apr 8, 2023 · 0 comments
Open

Figure out what to do with Windows Store Python #26

ericoporto opened this issue Apr 8, 2023 · 0 comments
Labels
bug Something isn't working enhancement New feature or request

Comments

@ericoporto
Copy link
Owner

Windows Store Python redirects calls to user system directories. The redirected directory names are quite long and may reach the Windows path size limit.

It also creates confusion where directory paths in config don't match with real life

Interesting code from https://github.com/mu-editor/mu/pull/2292/files

import os

import sys
import tempfile
from functools import lru_cache
import platformdirs


# The default directory for application data (i.e., configuration).
DATA_DIR = platformdirs.user_data_dir(appname="mu", appauthor="python")
@lru_cache()
def get_data_dir():
    path = platformdirs.user_data_dir(appname="mu", appauthor="python")
    if sys.platform == "win32":
        # Locate the actual path for Windows by making a temporary file
        # then resolving the real path. Solves a bug in the Windows store
        # distribution of Python 3.8+
        # See https://github.com/mu-editor/mu/issues/2293
        os.makedirs(path, exist_ok=True)
        fd, tmp = tempfile.mkstemp(dir=path)
        realpath = os.path.dirname(os.path.realpath(tmp))
        os.close(fd)
        os.remove(tmp)
        return realpath
    else:
        return path

The caveat here is we really want to let any redirections happen when using Python over Wine. So we can't naively use the proposal above directly.

I have no idea if this is a bug or enhancement, but it's a problem.

@ericoporto ericoporto added bug Something isn't working enhancement New feature or request labels Apr 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant