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

Does not work with Nuitka #55

Closed
txtsd opened this issue Jan 20, 2022 · 11 comments · Fixed by #68
Closed

Does not work with Nuitka #55

txtsd opened this issue Jan 20, 2022 · 11 comments · Fixed by #68
Labels
help wanted Extra attention is needed

Comments

@txtsd
Copy link

txtsd commented Jan 20, 2022

Nuitka creates a single executable out of your python code.

I've used platformdirs in a project of mine called mcrpc. The code itself runs fine, but the executable created with Nuitka spits out this error:

λ ./mcrpc-linux                                                                  
Traceback (most recent call last):
  File "/tmp/.mount_mcrpc-h4h3HH/mcrpc.py", line 14, in <module>
  File "/tmp/.mount_mcrpc-h4h3HH/platformdirs/__init__.py", line 33, in <module platformdirs>
  File "/tmp/.mount_mcrpc-h4h3HH/platformdirs/__init__.py", line 29, in _set_platform_dir_class
  File "importlib.py", line 127, in import_module
ModuleNotFoundError: No module named 'platformdirs.unix'

It spits out a similar error on windows:
ModuleNotFoundError: No module named 'platformdirs.windows'

Is there anything that can be done on platformdirs' side to help it work well with Nuitka? You can try using the executables from v1.2.

@gaborbernat
Copy link
Contributor

PRs welcome, but I'm not a Nuitka expert to tell 🤔

@txtsd
Copy link
Author

txtsd commented Jan 22, 2022

Tried it with appdirs instead of platformdirs, and there is no such error in the binary.

@gaborbernat
Copy link
Contributor

Not sure how that's relevant here.

@txtsd
Copy link
Author

txtsd commented Jan 22, 2022

platformdirs is a fork of appdirs. Whatever's causing the problem was introduced within this fork.

@gaborbernat
Copy link
Contributor

gaborbernat commented Jan 22, 2022

A lot of things changed, so I don't think that helps in any shape or form. And while it started as a fork, today is more like a complete reimagination of it with just the API being similar. And likely that information will be completely useless to track down and fix the issue. Just to spell out, a PR would be welcome on this, but don't expect the maintainers to act on this otherwise.

@gaborbernat gaborbernat added the help wanted Extra attention is needed label Jan 22, 2022
@txtsd
Copy link
Author

txtsd commented Jan 22, 2022

Fair enough. Thanks for the explanation.

@ofek
Copy link
Contributor

ofek commented Jan 22, 2022

The issue is the dynamic imports https://github.com/platformdirs/platformdirs/blob/2.4.1/src/platformdirs/__init__.py#L20-L33

Changing to actual import statements and executing the logic outside of that function should fix it.

@ofek
Copy link
Contributor

ofek commented Jan 25, 2022

@txtsd Can you try?

@Clouder0
Copy link
Contributor

For Nuitka you can specify --include-package=platformdirs and everything will be fine.

image

From my personal perspective, I don't think it makes sense to use dynamic importing for several fixed platforms. Kind of overkill I suppose.

@Julian
Copy link
Member

Julian commented Feb 19, 2022

If there's an option in nuitka to make things work, I'd vote for closing personally. Things which do "odd" packaging things (or users of them) are responsible for making things work, so long as we are doing "normal" python things. Overkill or not, what's here is perfectly well specified Python behavior.

@txtsd
Copy link
Author

txtsd commented Feb 19, 2022

@gaborbernat GLORIOUS!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
5 participants