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

Calls to appdirs functions fail on Jython in Windows if Java doesn't have JNA #154

Open
Kevin-McClusky opened this issue Aug 29, 2020 · 0 comments

Comments

@Kevin-McClusky
Copy link
Contributor

Kevin-McClusky commented Aug 29, 2020

Description

Calls to all appdirs functions that retrieve directory paths fail on Jython in Windows.

Some environments Jython runs in may have JNA. In those environments appdirs is successful. In most standard Java installs, this isn't the case, since JNA doesn't ship as part of Java.

How to Reproduce

  1. Install Jython
  2. Open the interactive interpreter
  3. 'import appdirs'
  4. 'appdirs.user_data_dir("anything")'

Output

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\jython2.7.2\Lib\appdirs.py", line 80, in user_data_dir
    path = os.path.normpath(_get_win_folder(const))
  File "C:\jython2.7.2\Lib\appdirs.py", line 470, in _get_win_folder_from_registry
    import _winreg
ImportError: No module named _winreg

Analysis

appdirs attempts to get the Windows folder from ctypes, JNA, and then winreg. However, all 3 are unavailable in a default install of Jython.

Resolutions

Having a final fallback go to os.environ would address this in Jython.
I'll submit a PR with this code in it. (Inspired by #129 ... that PR has conflicts right now, so I'll submit a fresh one.)

Downstream Issues This Resolves
pip: pypa/pip#8806

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant