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

ImportError on an Apple M1 Mac related to libcst #577

Closed
cclauss opened this issue Apr 12, 2022 · 5 comments · Fixed by #579
Closed

ImportError on an Apple M1 Mac related to libcst #577

cclauss opened this issue Apr 12, 2022 · 5 comments · Fixed by #579
Labels
bug Something isn't working

Comments

@cclauss
Copy link
Contributor

cclauss commented Apr 12, 2022

Describe the bug
A clear and concise description of what the bug is.
ImportError on an Apple M1 Mac.

libcst seems to be installed for x86_64, not the required arm64e.

To Reproduce
Steps to reproduce the behavior:

% pipx --version

1.0.0

% pipx install django-codemod

  installed package django-codemod 1.10.0, Python 3.9.12
  These apps are now globally available
    - djcodemod
done! ✨ 🌟 ✨

% djcodemod run --deprecated-in 1.3 .

Running codemods: ActionCheckboxNameTransformer
Executing codemod...
Traceback (most recent call last):
  File "/Users/cclauss/.local/bin/djcodemod", line 8, in <module>
    sys.exit(djcodemod())
  File "/Users/cclauss/.local/pipx/venvs/django-codemod/lib/python3.9/site-packages/click/core.py", line 1130, in __call__
    return self.main(*args, **kwargs)
  File "/Users/cclauss/.local/pipx/venvs/django-codemod/lib/python3.9/site-packages/rich_click/rich_group.py", line 21, in main
    return super().main(*args, standalone_mode=False, **kwargs)
  File "/Users/cclauss/.local/pipx/venvs/django-codemod/lib/python3.9/site-packages/click/core.py", line 1055, in main
    rv = self.invoke(ctx)
  File "/Users/cclauss/.local/pipx/venvs/django-codemod/lib/python3.9/site-packages/click/core.py", line 1657, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/Users/cclauss/.local/pipx/venvs/django-codemod/lib/python3.9/site-packages/click/core.py", line 1404, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/Users/cclauss/.local/pipx/venvs/django-codemod/lib/python3.9/site-packages/click/core.py", line 760, in invoke
    return __callback(*args, **kwargs)
  File "/Users/cclauss/.local/pipx/venvs/django-codemod/lib/python3.9/site-packages/django_codemod/cli.py", line 188, in run
    call_command(command_instance, files)
  File "/Users/cclauss/.local/pipx/venvs/django-codemod/lib/python3.9/site-packages/django_codemod/cli.py", line 195, in call_command
    result = parallel_exec_transform_with_prettyprint(
  File "/Users/cclauss/.local/pipx/venvs/django-codemod/lib/python3.9/site-packages/libcst/codemod/_cli.py", line 623, in parallel_exec_transform_with_prettyprint
    parse_module(
  File "/Users/cclauss/.local/pipx/venvs/django-codemod/lib/python3.9/site-packages/libcst/_parser/entrypoints.py", line 109, in parse_module
    result = _parse(
  File "/Users/cclauss/.local/pipx/venvs/django-codemod/lib/python3.9/site-packages/libcst/_parser/entrypoints.py", line 42, in _parse
    from libcst.native import parse_expression, parse_module, parse_statement
ImportError: dlopen(/Users/cclauss/.local/pipx/venvs/django-codemod/lib/python3.9/site-packages/libcst/native.cpython-39-darwin.so, 0x0002):
    tried: '/Users/cclauss/.local/pipx/venvs/django-codemod/lib/python3.9/site-packages/libcst/native.cpython-39-darwin.so'
    (mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64e'))

Additional context
Add any other context about the problem here.

@cclauss cclauss added the bug Something isn't working label Apr 12, 2022
@cclauss
Copy link
Contributor Author

cclauss commented Apr 12, 2022

Workaround: pipx install --force django-codemod==1.9.1

@browniebroke
Copy link
Owner

Introduced in #574

The problematic line is here:

os.environ["LIBCST_PARSER_TYPE"] = "native"

@browniebroke
Copy link
Owner

Could you please check the version of libCST that was installed in your pipx environment? It should be 0.4.1 as it's pinned in our dependencies, and that version is supposed to provide a wheel for ARM. Maybe there is something wrong in their build?

@cclauss
Copy link
Contributor Author

cclauss commented Apr 14, 2022

% pipx list

package django-codemod 1.10.0, installed using Python 3.9.1

% python3

Python 3.9.12 (main, Mar 26 2022, 15:44:31)
[Clang 13.1.6 (clang-1316.0.21.2)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import libcst
>>> libcst.LIBCST_VERSION
'0.4.1'

@browniebroke
Copy link
Owner

I've reverted the change in here and should be released in 1.10.1 shortly. That seems like a bug in libCST's new parser, you might want to file a bug report over there. You'll probably need to create a more minimal reproduction case not involving django-codemod... I do not own a M1 Mac, so I'm unable to reproduce this bug.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants