liberfa / pyerfa

Python bindings for ERFA routines
https://pyerfa.readthedocs.io
BSD 3-Clause "New" or "Revised" License
34 stars 24 forks source link

Building wheel fails on MacOS: ModuleNotFoundError: No module named 'packaging' #87

Closed dbuscher closed 2 years ago

dbuscher commented 2 years ago

Running on an M1 Macbook Air. The packaging module is installed, but installing pyerfa fails complaining about it:

pip3 --version

pip 22.2.2 from /opt/homebrew/lib/python3.10/site-packages/pip (python 3.10)

python3

Python 3.10.6 (main, Aug 11 2022, 13:36:31) [Clang 13.1.6 (clang-1316.0.21.2.5)] on darwin Type "help", "copyright", "credits" or "license" for more information.

import packaging

python3 -m pip install --user pyerfa

Collecting pyerfa Using cached pyerfa-2.0.0.1.tar.gz (808 kB) Installing build dependencies ... done Getting requirements to build wheel ... error error: subprocess-exited-with-error

× Getting requirements to build wheel did not run successfully. │ exit code: 1 ╰─> [17 lines of output] Error in sitecustomize; set PYTHONVERBOSE for traceback: AssertionError: Traceback (most recent call last): File "/opt/homebrew/lib/python3.10/site-packages/pip/_vendor/pep517/in_process/_in_process.py", line 363, in main() File "/opt/homebrew/lib/python3.10/site-packages/pip/_vendor/pep517/in_process/_in_process.py", line 345, in main json_out['return_val'] = hook(**hook_input['kwargs']) File "/opt/homebrew/lib/python3.10/site-packages/pip/_vendor/pep517/in_process/_in_process.py", line 130, in get_requires_for_build_wheel return hook(config_settings) File "/opt/homebrew/Cellar/python@3.10/3.10.6_1/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/setuptools/build_meta.py", line 177, in get_requires_for_build_wheel return self._get_build_requires( File "/opt/homebrew/Cellar/python@3.10/3.10.6_1/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/setuptools/build_meta.py", line 159, in _get_build_requires self.run_setup() File "/opt/homebrew/Cellar/python@3.10/3.10.6_1/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/setuptools/build_meta.py", line 174, in run_setup exec(code, locals()) File "", line 12, in ModuleNotFoundError: No module named 'packaging' [end of output]

note: This error originates from a subprocess, and is likely not a problem with pip. error: subprocess-exited-with-error

× Getting requirements to build wheel did not run successfully. │ exit code: 1 ╰─> See above for output.

note: This error originates from a subprocess, and is likely not a problem with pip.

avalentino commented 2 years ago

Dear @dbuscher, the fact that packaging is already installed could not be relevant in case of isolated builds. packaging is listed in the pyproject.toml file so I would expect is properly installed when pip attempts to build pyerfa from sources.

This is not the first issue related to M1 Macs (see also #86). Could you please report the full log generated by pip with the --verbose option?

Do you have the same kind of issue a conda environment?

dbuscher commented 2 years ago

I don't have a conda environment on this machine, just Homebrew Python. I don't seem to have the same problem as #86 in that installing setuptools_scm has no effect.

Here is the log from installing with the --verbose flag:

Using pip 22.2.2 from /opt/homebrew/lib/python3.10/site-packages/pip (python 3.10) Collecting pyerfa Using cached pyerfa-2.0.0.1.tar.gz (808 kB) Installing build dependencies: started Running command pip subprocess to install build dependencies Collecting setuptools>=42 Using cached setuptools-65.2.0-py3-none-any.whl (1.2 MB) Collecting setuptools_scm[toml]>=3.4 Using cached setuptools_scm-7.0.5-py3-none-any.whl (42 kB) Collecting wheel Using cached wheel-0.37.1-py2.py3-none-any.whl (35 kB) Collecting packaging Using cached packaging-21.3-py3-none-any.whl (40 kB) Collecting jinja2>=2.10.3 Using cached Jinja2-3.1.2-py3-none-any.whl (133 kB) Collecting oldest-supported-numpy Using cached oldest_supported_numpy-2022.8.16-py3-none-any.whl (3.9 kB) Collecting typing-extensions Using cached typing_extensions-4.3.0-py3-none-any.whl (25 kB) Collecting tomli>=1.0.0 Using cached tomli-2.0.1-py3-none-any.whl (12 kB) Collecting pyparsing!=3.0.5,>=2.0.2 Using cached pyparsing-3.0.9-py3-none-any.whl (98 kB) Collecting MarkupSafe>=2.0 Using cached MarkupSafe-2.1.1-cp310-cp310-macosx_10_9_universal2.whl (17 kB) Collecting numpy==1.21.6 Using cached numpy-1.21.6-cp310-cp310-macosx_11_0_arm64.whl (12.4 MB) Installing collected packages: wheel, typing-extensions, tomli, setuptools, pyparsing, numpy, MarkupSafe, packaging, oldest-supported-numpy, jinja2, setuptools_scm Successfully installed MarkupSafe-2.1.1 jinja2-3.1.2 numpy-1.21.6 oldest-supported-numpy-2022.8.16 packaging-21.3 pyparsing-3.0.9 setuptools-65.2.0 setuptools_scm-7.0.5 tomli-2.0.1 typing-extensions-4.3.0 wheel-0.37.1 Installing build dependencies: finished with status 'done' Getting requirements to build wheel: started Running command Getting requirements to build wheel Error in sitecustomize; set PYTHONVERBOSE for traceback: AssertionError: Traceback (most recent call last): File "/opt/homebrew/lib/python3.10/site-packages/pip/_vendor/pep517/in_process/_in_process.py", line 363, in main() File "/opt/homebrew/lib/python3.10/site-packages/pip/_vendor/pep517/in_process/_in_process.py", line 345, in main json_out['return_val'] = hook(**hook_input['kwargs']) File "/opt/homebrew/lib/python3.10/site-packages/pip/_vendor/pep517/in_process/_in_process.py", line 130, in get_requires_for_build_wheel return hook(config_settings) File "/opt/homebrew/Cellar/python@3.10/3.10.6_1/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/setuptools/build_meta.py", line 177, in get_requires_for_build_wheel return self._get_build_requires( File "/opt/homebrew/Cellar/python@3.10/3.10.6_1/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/setuptools/build_meta.py", line 159, in _get_build_requires self.run_setup() File "/opt/homebrew/Cellar/python@3.10/3.10.6_1/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/setuptools/build_meta.py", line 174, in run_setup exec(code, locals()) File "", line 12, in ModuleNotFoundError: No module named 'packaging' error: subprocess-exited-with-error

× Getting requirements to build wheel did not run successfully. │ exit code: 1 ╰─> See above for output.

note: This error originates from a subprocess, and is likely not a problem with pip. full command: /opt/homebrew/opt/python@3.10/bin/python3.10 /opt/homebrew/lib/python3.10/site-packages/pip/_vendor/pep517/in_process/_in_process.py get_requires_for_build_wheel /var/folders/9y/4kfs30yd1rz98737_h9jpn9h0000gn/T/tmpf2atcx_8 cwd: /private/var/folders/9y/4kfs30yd1rz98737_h9jpn9h0000gn/T/pip-install-dkqz74w4/pyerfa_fb9c7b9e37e94b9bb3eeaa11cdb6aa44 Getting requirements to build wheel: finished with status 'error' error: subprocess-exited-with-error

× Getting requirements to build wheel did not run successfully. │ exit code: 1 ╰─> See above for output.

note: This error originates from a subprocess, and is likely not a problem with pip.

avalentino commented 2 years ago

It seems that build dependencies are correctly installed at some point:

Successfully installed MarkupSafe-2.1.1 jinja2-3.1.2 numpy-1.21.6 oldest-supported-numpy-2022.8.16 packaging-21.3 pyparsing-3.0.9 setuptools-65.2.0 setuptools_scm-7.0.5 tomli-2.0.1 typing-extensions-4.3.0 wheel-0.37.1
Installing build dependencies: finished with status 'done'

but than pit tries to install it again and an error occurs in sitecustomize

Running command Getting requirements to build wheel
Error in sitecustomize; set PYTHONVERBOSE for traceback:
AssertionError:

Unfortunately it is still not clear to me what the problem could be, sorry.

dbuscher commented 2 years ago

I successfully installed pyerfa 2.0.0.1 on my Intel MacBook, also Homebrew Python 3.10.6, and also MacOS 12.5.1.. However I did not need to compile the wheel - a pre-compiled binary wheel is obviously available for Mac Intel, but not for M1. I suspect that is probably the reason #86 is also turning up on Mac M1 preferentially.

avalentino commented 2 years ago

You could use the --no-binary pyerfa option to emulate the M1 conditions.

dbuscher commented 2 years ago

Thanks for the suggestion. It fails, but with a slightly different error!

pip3 install --user --no-binary :all: pyerfa Collecting pyerfa Downloading pyerfa-2.0.0.1.tar.gz (808 kB) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 808.5/808.5 kB 8.0 MB/s eta 0:00:00 Installing build dependencies ... error error: subprocess-exited-with-error

× pip subprocess to install build dependencies did not run successfully. │ exit code: 1 ╰─> [115 lines of output] Collecting setuptools>=42 Downloading setuptools-65.2.0.tar.gz (2.6 MB) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 2.6/2.6 MB 14.8 MB/s eta 0:00:00 Getting requirements to build wheel: started Getting requirements to build wheel: finished with status 'done' Preparing metadata (pyproject.toml): started Preparing metadata (pyproject.toml): finished with status 'done' Collecting setuptools_scm[toml]>=3.4 Downloading setuptools_scm-7.0.5.tar.gz (70 kB) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 70.7/70.7 kB 2.8 MB/s eta 0:00:00 Installing build dependencies: started Installing build dependencies: finished with status 'error' error: subprocess-exited-with-error

    × pip subprocess to install build dependencies did not run successfully.
    │ exit code: 2
    ╰─> [88 lines of output]
        Collecting setuptools>=45
          Using cached setuptools-65.2.0.tar.gz (2.6 MB)
          Getting requirements to build wheel: started
          Getting requirements to build wheel: finished with status 'done'
          Preparing metadata (pyproject.toml): started
          Preparing metadata (pyproject.toml): finished with status 'done'
        Collecting packaging>=20.0
          Downloading packaging-21.3.tar.gz (84 kB)
             ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 84.8/84.8 kB 1.9 MB/s eta 0:00:00
          Installing build dependencies: started
          Installing build dependencies: finished with status 'done'
          Getting requirements to build wheel: started
          Getting requirements to build wheel: finished with status 'done'
          Preparing metadata (pyproject.toml): started
          Preparing metadata (pyproject.toml): finished with status 'done'
        Collecting typing_extensions
          Downloading typing_extensions-4.3.0.tar.gz (47 kB)
             ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 47.4/47.4 kB 1.6 MB/s eta 0:00:00
          Installing build dependencies: started
          Installing build dependencies: finished with status 'done'
          Getting requirements to build wheel: started
          Getting requirements to build wheel: finished with status 'done'
        ERROR: Exception:
        Traceback (most recent call last):
          File "/usr/local/lib/python3.10/site-packages/pip/_internal/cli/base_command.py", line 167, in exc_logging_wrapper
            status = run_func(*args)
          File "/usr/local/lib/python3.10/site-packages/pip/_internal/cli/req_command.py", line 247, in wrapper
            return func(self, options, args)
          File "/usr/local/lib/python3.10/site-packages/pip/_internal/commands/install.py", line 369, in run
            requirement_set = resolver.resolve(
          File "/usr/local/lib/python3.10/site-packages/pip/_internal/resolution/resolvelib/resolver.py", line 92, in resolve
            result = self._result = resolver.resolve(
          File "/usr/local/lib/python3.10/site-packages/pip/_vendor/resolvelib/resolvers.py", line 481, in resolve
            state = resolution.resolve(requirements, max_rounds=max_rounds)
          File "/usr/local/lib/python3.10/site-packages/pip/_vendor/resolvelib/resolvers.py", line 348, in resolve
            self._add_to_criteria(self.state.criteria, r, parent=None)
          File "/usr/local/lib/python3.10/site-packages/pip/_vendor/resolvelib/resolvers.py", line 172, in _add_to_criteria
            if not criterion.candidates:
          File "/usr/local/lib/python3.10/site-packages/pip/_vendor/resolvelib/structs.py", line 151, in __bool__
            return bool(self._sequence)
          File "/usr/local/lib/python3.10/site-packages/pip/_internal/resolution/resolvelib/found_candidates.py", line 155, in __bool__
            return any(self)
          File "/usr/local/lib/python3.10/site-packages/pip/_internal/resolution/resolvelib/found_candidates.py", line 143, in <genexpr>
            return (c for c in iterator if id(c) not in self._incompatible_ids)
          File "/usr/local/lib/python3.10/site-packages/pip/_internal/resolution/resolvelib/found_candidates.py", line 47, in _iter_built
            candidate = func()
          File "/usr/local/lib/python3.10/site-packages/pip/_internal/resolution/resolvelib/factory.py", line 206, in _make_candidate_from_link
            self._link_candidate_cache[link] = LinkCandidate(
          File "/usr/local/lib/python3.10/site-packages/pip/_internal/resolution/resolvelib/candidates.py", line 297, in __init__
            super().__init__(
          File "/usr/local/lib/python3.10/site-packages/pip/_internal/resolution/resolvelib/candidates.py", line 162, in __init__
            self.dist = self._prepare()
          File "/usr/local/lib/python3.10/site-packages/pip/_internal/resolution/resolvelib/candidates.py", line 231, in _prepare
            dist = self._prepare_distribution()
          File "/usr/local/lib/python3.10/site-packages/pip/_internal/resolution/resolvelib/candidates.py", line 308, in _prepare_distribution
            return preparer.prepare_linked_requirement(self._ireq, parallel_builds=True)
          File "/usr/local/lib/python3.10/site-packages/pip/_internal/operations/prepare.py", line 438, in prepare_linked_requirement
            return self._prepare_linked_requirement(req, parallel_builds)
          File "/usr/local/lib/python3.10/site-packages/pip/_internal/operations/prepare.py", line 524, in _prepare_linked_requirement
            dist = _get_prepared_distribution(
          File "/usr/local/lib/python3.10/site-packages/pip/_internal/operations/prepare.py", line 68, in _get_prepared_distribution
            abstract_dist.prepare_distribution_metadata(
          File "/usr/local/lib/python3.10/site-packages/pip/_internal/distributions/sdist.py", line 48, in prepare_distribution_metadata
            self._install_build_reqs(finder)
          File "/usr/local/lib/python3.10/site-packages/pip/_internal/distributions/sdist.py", line 118, in _install_build_reqs
            build_reqs = self._get_build_requires_wheel()
          File "/usr/local/lib/python3.10/site-packages/pip/_internal/distributions/sdist.py", line 95, in _get_build_requires_wheel
            return backend.get_requires_for_build_wheel()
          File "/usr/local/lib/python3.10/site-packages/pip/_internal/utils/misc.py", line 685, in get_requires_for_build_wheel
            return super().get_requires_for_build_wheel(config_settings=cs)
          File "/usr/local/lib/python3.10/site-packages/pip/_vendor/pep517/wrappers.py", line 172, in get_requires_for_build_wheel
            return self._call_hook('get_requires_for_build_wheel', {
          File "/usr/local/lib/python3.10/site-packages/pip/_vendor/pep517/wrappers.py", line 332, in _call_hook
            raise BackendUnavailable(data.get('traceback', ''))
        pip._vendor.pep517.wrappers.BackendUnavailable: Traceback (most recent call last):
          File "/usr/local/lib/python3.10/site-packages/pip/_vendor/pep517/in_process/_in_process.py", line 89, in _build_backend
            obj = import_module(mod_path)
          File "/usr/local/Cellar/python@3.10/3.10.6_1/Frameworks/Python.framework/Versions/3.10/lib/python3.10/importlib/__init__.py", line 126, in import_module
            return _bootstrap._gcd_import(name[level:], package, level)
          File "<frozen importlib._bootstrap>", line 1050, in _gcd_import
          File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
          File "<frozen importlib._bootstrap>", line 992, in _find_and_load_unlocked
          File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
          File "<frozen importlib._bootstrap>", line 1050, in _gcd_import
          File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
          File "<frozen importlib._bootstrap>", line 1004, in _find_and_load_unlocked
        ModuleNotFoundError: No module named 'flit_core'

        [end of output]

    note: This error originates from a subprocess, and is likely not a problem with pip.
  error: subprocess-exited-with-error

  × pip subprocess to install build dependencies did not run successfully.
  │ exit code: 2
  ╰─> See above for output.

  note: This error originates from a subprocess, and is likely not a problem with pip.
  [end of output]

note: This error originates from a subprocess, and is likely not a problem with pip. error: subprocess-exited-with-error

× pip subprocess to install build dependencies did not run successfully. │ exit code: 1 ╰─> See above for output.

note: This error originates from a subprocess, and is likely not a problem with pip.

avalentino commented 2 years ago

flit is an alternative to setuptools (for pure Python packages). Probably the error comes form another package.

Does the following command give the same error?

pip install --no-binary pyerfa --verbose pyerfa
dbuscher commented 2 years ago

Back to the same error as on M1!

pip3 install --no-binary pyerfa --verbose pyerfa Using pip 22.2.2 from /usr/local/lib/python3.10/site-packages/pip (python 3.10) Collecting pyerfa Using cached pyerfa-2.0.0.1.tar.gz (808 kB) Running command pip subprocess to install build dependencies Collecting setuptools>=42 Downloading setuptools-65.2.0-py3-none-any.whl (1.2 MB) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 1.2/1.2 MB 9.8 MB/s eta 0:00:00 Collecting setuptools_scm[toml]>=3.4 Downloading setuptools_scm-7.0.5-py3-none-any.whl (42 kB) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 42.9/42.9 kB 1.4 MB/s eta 0:00:00 Collecting wheel Downloading wheel-0.37.1-py2.py3-none-any.whl (35 kB) Collecting packaging Downloading packaging-21.3-py3-none-any.whl (40 kB) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 40.8/40.8 kB 1.3 MB/s eta 0:00:00 Collecting jinja2>=2.10.3 Downloading Jinja2-3.1.2-py3-none-any.whl (133 kB) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 133.1/133.1 kB 5.2 MB/s eta 0:00:00 Collecting oldest-supported-numpy Downloading oldest_supported_numpy-2022.8.16-py3-none-any.whl (3.9 kB) Collecting tomli>=1.0.0 Downloading tomli-2.0.1-py3-none-any.whl (12 kB) Collecting typing-extensions Downloading typing_extensions-4.3.0-py3-none-any.whl (25 kB) Collecting pyparsing!=3.0.5,>=2.0.2 Downloading pyparsing-3.0.9-py3-none-any.whl (98 kB) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 98.3/98.3 kB 4.0 MB/s eta 0:00:00 Collecting MarkupSafe>=2.0 Downloading MarkupSafe-2.1.1-cp310-cp310-macosx_10_9_x86_64.whl (13 kB) Collecting numpy==1.21.6 Downloading numpy-1.21.6-cp310-cp310-macosx_10_9_x86_64.whl (17.0 MB) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 17.0/17.0 MB 19.6 MB/s eta 0:00:00 Installing collected packages: wheel, typing-extensions, tomli, setuptools, pyparsing, numpy, MarkupSafe, packaging, oldest-supported-numpy, jinja2, setuptools_scm Successfully installed MarkupSafe-2.1.1 jinja2-3.1.2 numpy-1.21.6 oldest-supported-numpy-2022.8.16 packaging-21.3 pyparsing-3.0.9 setuptools-65.2.0 setuptools_scm-7.0.5 tomli-2.0.1 typing-extensions-4.3.0 wheel-0.37.1 Installing build dependencies ... done Running command Getting requirements to build wheel Error in sitecustomize; set PYTHONVERBOSE for traceback: AssertionError: Traceback (most recent call last): File "/usr/local/lib/python3.10/site-packages/pip/_vendor/pep517/in_process/_in_process.py", line 363, in main() File "/usr/local/lib/python3.10/site-packages/pip/_vendor/pep517/in_process/_in_process.py", line 345, in main json_out['return_val'] = hook(**hook_input['kwargs']) File "/usr/local/lib/python3.10/site-packages/pip/_vendor/pep517/in_process/_in_process.py", line 130, in get_requires_for_build_wheel return hook(config_settings) File "/usr/local/Cellar/python@3.10/3.10.6_1/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/setuptools/build_meta.py", line 177, in get_requires_for_build_wheel return self._get_build_requires( File "/usr/local/Cellar/python@3.10/3.10.6_1/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/setuptools/build_meta.py", line 159, in _get_build_requires self.run_setup() File "/usr/local/Cellar/python@3.10/3.10.6_1/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/setuptools/build_meta.py", line 174, in run_setup exec(code, locals()) File "", line 12, in ModuleNotFoundError: No module named 'packaging' error: subprocess-exited-with-error

× Getting requirements to build wheel did not run successfully. │ exit code: 1 ╰─> See above for output.

note: This error originates from a subprocess, and is likely not a problem with pip. full command: /usr/local/opt/python@3.10/bin/python3.10 /usr/local/lib/python3.10/site-packages/pip/_vendor/pep517/in_process/_in_process.py get_requires_for_build_wheel /var/folders/fg/2m7q9hv12ybfx5bf1gy13v5w0000gn/T/tmpf9_rm2mq cwd: /private/var/folders/fg/2m7q9hv12ybfx5bf1gy13v5w0000gn/T/pip-install-pha1g324/pyerfa_bb38b1d21c8045d59f9525fc1a9a3f66 Getting requirements to build wheel ... error error: subprocess-exited-with-error

× Getting requirements to build wheel did not run successfully. │ exit code: 1 ╰─> See above for output.

note: This error originates from a subprocess, and is likely not a problem with pip.

avalentino commented 2 years ago

OK, this command works on Intel Mac in a conda environment. I would say that the issue is related to the specific os/architecture or to brew. Do you have any chance to try with something different form brew?

dbuscher commented 2 years ago

So, yes it seems that it is brew Python which is at fault. I installed Python 3.10.6 on my M1 MacBook using pyenv, and it compiles and installs pyerfa no problem. Thanks for your help.

avalentino commented 2 years ago

Thank you for the deep investigation. I'm closing this issue but please feel free to add here any new information that could help other users. I would be happy to merge a PR if you manage to find a workaround for this issue.