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

Error when using black 21.8b0 black binary on linux #2464

Closed
jalaziz opened this issue Aug 31, 2021 · 0 comments · Fixed by #2466
Closed

Error when using black 21.8b0 black binary on linux #2464

jalaziz opened this issue Aug 31, 2021 · 0 comments · Fixed by #2466
Labels
T: bug Something isn't working

Comments

@jalaziz
Copy link
Contributor

jalaziz commented Aug 31, 2021

Describe the bug

When running the latest black binary on linux, the following error is thrown:

Traceback (most recent call last):
  File "black/__main__.py", line 1, in <module>
  File "PyInstaller/loader/pyimod03_importers.py", line 546, in exec_module
  File "black/__init__.py", line 38, in <module>
  File "PyInstaller/loader/pyimod03_importers.py", line 546, in exec_module
  File "black/nodes.py", line 28, in <module>
  File "PyInstaller/loader/pyimod03_importers.py", line 546, in exec_module
  File "black/cache.py", line 9, in <module>
  File "PyInstaller/loader/pyimod03_importers.py", line 546, in exec_module
  File "platformdirs/__init__.py", line 31, in <module>
  File "platformdirs/__init__.py", line 27, in _set_platform_dir_class
  File "importlib/__init__.py", line 127, in import_module
ModuleNotFoundError: No module named 'platformdirs.unix'
[2725] Failed to execute script '__main__' due to unhandled exception!

This seems to an issue with PyInstaller missing a module during packaging.

To Reproduce

  1. Run a linux container: docker run --rm -it debian:stable-slim bash
  2. Download the black binary: wget --tries=5 -q -O /usr/local/bin/black https://github.com/psf/black/releases/download/21.8b0/black_linux && chmod +x /usr/local/bin/black
  3. Run black: black -v

Expected behavior

The version of black should be printed.

Environment (please complete the following information):

  • Version: 21.8b0
  • OS and Python version: Linux

Does this bug also happen on main?

N/A?

Additional context

This is likely due to #2375.

This error doesn't occur when using the 21.7b0 binaries. platformdirs.unix may need to be added explicitly using PyInstaller's hidden imports functionality.

@jalaziz jalaziz added the T: bug Something isn't working label Aug 31, 2021
ichard26 pushed a commit that referenced this issue Sep 1, 2021
Add new platformdirs dependencies as hidden imports when creating
PyInstaller-based binaries.

platformdirs imports the module for each platform dynamically, which
PyInstaller is unable to correctly detect for packing. By adding the
modules as hidden imports, we are telling PyInstaller to include the
modules in the packaged binary.

This issue seems to have been introduce when switching to platformdirs
in #2375. fixes #2464

Commit history before merge:

* Add hidden import to PyInstaller build

Add new platformdirs dependency as a hidden import when creating
PyInstaller based binaries.

* Only include the platformdirs for the relevant os
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
T: bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant