Repository: browniebroke/django-codemod (language: python)

Issue:
ImportError on an Apple M1 Mac related to libcst
**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.



Discussion / hints:
Workaround: `pipx install --force django-codemod==1.9.1`
Introduced in https://github.com/browniebroke/django-codemod/pull/574

The problematic line is here: https://github.com/browniebroke/django-codemod/blob/fb9f642d245098913198929e5800630749a2f131/src/django_codemod/cli.py#L19
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](https://github.com/browniebroke/django-codemod/blob/c9403903e9238c2f8afab878475b633e992af015/pyproject.toml#L32), and that version is [supposed to provide a wheel for ARM](https://github.com/Instagram/LibCST/pull/630). Maybe there is something wrong in their build?
% `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'
```

Fix patch:
diff --git a/src/django_codemod/cli.py b/src/django_codemod/cli.py
index a35fc51b..9648432a 100644
--- a/src/django_codemod/cli.py
+++ b/src/django_codemod/cli.py
@@ -1,5 +1,4 @@
 import inspect
-import os
 from collections import defaultdict
 from operator import attrgetter
 from pathlib import Path
@@ -16,8 +15,6 @@
 from django_codemod.path_utils import get_sources
 from django_codemod.visitors.base import BaseDjCodemodTransformer
 
-os.environ["LIBCST_PARSER_TYPE"] = "native"
-
 
 def index_codemodders(version_getter: Callable) -> Dict[Tuple[int, int], List]:
     """


Test patch:
diff --git a/tests/test_cli.py b/tests/test_cli.py
index deb9533c..8907f698 100644
--- a/tests/test_cli.py
+++ b/tests/test_cli.py
@@ -27,12 +27,6 @@ def command_instance():
     return BaseCodemodCommand([], CodemodContext())
 
 
-def test_use_native_parser():
-    from libcst._parser.entrypoints import is_native
-
-    assert is_native() is True
-
-
 def test_missing_argument(cli_runner):
     """Should explain missing arguments."""
     result = cli_runner.invoke(cli.djcodemod, ["run"])