Skip to content

conda-lock missing cffi package as dependency #218276

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

Closed
2 of 4 tasks
aphedges opened this issue Apr 4, 2025 · 5 comments
Closed
2 of 4 tasks

conda-lock missing cffi package as dependency #218276

aphedges opened this issue Apr 4, 2025 · 5 comments

Comments

@aphedges
Copy link

aphedges commented Apr 4, 2025

brew gist-logs <formula> link OR brew config AND brew doctor output

$ brew config
HOMEBREW_VERSION: 4.4.27
ORIGIN: https://github.com/Homebrew/brew
HEAD: 9b1efcd944408db0bd85f82fe4724ccae04a812f
Last commit: 4 days ago
Branch: stable
Core tap JSON: 04 Apr 19:30 UTC
Core cask tap JSON: 04 Apr 19:30 UTC
HOMEBREW_PREFIX: /opt/homebrew
HOMEBREW_CASK_OPTS: []
HOMEBREW_DISPLAY: /private/tmp/com.apple.launchd.vqp9Vpdhw1/org.xquartz:0
HOMEBREW_EDITOR: vim
HOMEBREW_MAKE_JOBS: 14
Homebrew Ruby: 3.3.7 => /opt/homebrew/Library/Homebrew/vendor/portable-ruby/3.3.7/bin/ruby
CPU: 14-core 64-bit arm_palma
Clang: 16.0.0 build 1600
Git: 2.49.0 => /opt/homebrew/bin/git
Curl: 8.7.1 => /usr/bin/curl
macOS: 14.7.4-arm64
CLT: 16.2.0.0.1.1733547573
Xcode: N/A
Rosetta 2: false
$ brew doctor
Please note that these warnings are just used to help the Homebrew maintainers
with debugging if you file an issue. If everything you use Homebrew for is
working fine: please don't worry or file an issue; just ignore this. Thanks!

Warning: Some installed formulae are deprecated or disabled.
You should find replacements for the following formulae:
  icu4c@76
  [email protected]
  tldr

Warning: Putting non-prefixed coreutils in your path can cause GMP builds to fail.

Warning: Putting non-prefixed findutils in your path can cause python builds to fail.

Verification

  • My brew doctor output says Your system is ready to brew. and am still able to reproduce my issue.
  • I ran brew update and am still able to reproduce my issue.
  • I have resolved all warnings from brew doctor and that did not fix my problem.
  • I searched for recent similar issues at https://github.com/Homebrew/homebrew-core/issues?q=is%3Aissue and found no duplicates.

What were you trying to do (and why)?

I was trying to run conda-lock.

What happened (include all command output)?

It failed, producing the following output:

$ conda-lock lock --file environment.yaml --lockfile conda-lock.yaml
Locking dependencies for ['linux-64', 'osx-64', 'osx-arm64']...
INFO:conda_lock.conda_solver:linux-64 using specs ['pip *', 'python 3.12.*']
INFO:virtualenv.discovery.builtin:find interpreter for spec PythonSpec(path=/opt/homebrew/Cellar/conda-lock/3.0.0/libexec/bin/python)
INFO:virtualenv.discovery.builtin:proposed PythonInfo(spec=CPython3.13.2.final.0-64, system=/opt/homebrew/opt/[email protected]/bin/python3.13, exe=/opt/homebrew/Cellar/[email protected]/3.13.2/Frameworks/Python.framework/Versions/3.13/bin/python3.13, platform=darwin, version='3.13.2 (main, Feb  4 2025, 14:51:09) [Clang 16.0.0 (clang-1600.0.26.6)]', encoding_fs_io=utf-8-utf-8)
INFO:virtualenv.run.session:create virtual environment via CPython3macOsBrew(dest=/private/var/folders/pn/dly1wlvn51s4f4_8r7xv57vw0000gq/T/tmp0svpph9v/.venv, clear=False, no_vcs_ignore=False, global=False)
INFO:virtualenv.run.session:add activators for Bash, CShell, Fish, Nushell, PowerShell, Python
Traceback (most recent call last):
  File "/opt/homebrew/bin/conda-lock", line 8, in <module>
    sys.exit(main())
             ~~~~^^
  File "/opt/homebrew/Cellar/conda-lock/3.0.0/libexec/lib/python3.13/site-packages/click/core.py", line 1161, in __call__
    return self.main(*args, **kwargs)
           ~~~~~~~~~^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/conda-lock/3.0.0/libexec/lib/python3.13/site-packages/click/core.py", line 1082, in main
    rv = self.invoke(ctx)
  File "/opt/homebrew/Cellar/conda-lock/3.0.0/libexec/lib/python3.13/site-packages/click/core.py", line 1697, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
                           ~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^
  File "/opt/homebrew/Cellar/conda-lock/3.0.0/libexec/lib/python3.13/site-packages/click/core.py", line 1443, in invoke
    return ctx.invoke(self.callback, **ctx.params)
           ~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/conda-lock/3.0.0/libexec/lib/python3.13/site-packages/click/core.py", line 788, in invoke
    return __callback(*args, **kwargs)
  File "/opt/homebrew/Cellar/conda-lock/3.0.0/libexec/lib/python3.13/site-packages/click/decorators.py", line 33, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "/opt/homebrew/Cellar/conda-lock/3.0.0/libexec/lib/python3.13/site-packages/conda_lock/conda_lock.py", line 1453, in lock
    lock_func(
    ~~~~~~~~~^
        filename_template=filename_template, check_input_hash=check_input_hash
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    )
    ^
  File "/opt/homebrew/Cellar/conda-lock/3.0.0/libexec/lib/python3.13/site-packages/conda_lock/conda_lock.py", line 1162, in run_lock
    make_lock_files(
    ~~~~~~~~~~~~~~~^
        conda=_conda_exe,
        ^^^^^^^^^^^^^^^^^
    ...<16 lines>...
        mapping_url=mapping_url,
        ^^^^^^^^^^^^^^^^^^^^^^^^
    )
    ^
  File "/opt/homebrew/Cellar/conda-lock/3.0.0/libexec/lib/python3.13/site-packages/conda_lock/conda_lock.py", line 399, in make_lock_files
    fresh_lock_content = create_lockfile_from_spec(
        conda=conda,
    ...<8 lines>...
        mapping_url=mapping_url,
    )
  File "/opt/homebrew/Cellar/conda-lock/3.0.0/libexec/lib/python3.13/site-packages/conda_lock/conda_lock.py", line 851, in create_lockfile_from_spec
    deps = _solve_for_arch(
        conda=conda,
    ...<7 lines>...
        mapping_url=mapping_url,
    )
  File "/opt/homebrew/Cellar/conda-lock/3.0.0/libexec/lib/python3.13/site-packages/conda_lock/conda_lock.py", line 774, in _solve_for_arch
    pip_deps = solve_pypi(
        pip_specs=requested_deps_by_name["pip"],
    ...<17 lines>...
        mapping_url=mapping_url,
    )
  File "/opt/homebrew/Cellar/conda-lock/3.0.0/libexec/lib/python3.13/site-packages/conda_lock/pypi_solver.py", line 567, in solve_pypi
    result = s.solve(use_latest=to_update)
  File "/opt/homebrew/Cellar/conda-lock/3.0.0/libexec/lib/python3.13/site-packages/conda_lock/_vendor/poetry/puzzle/solver.py", line 85, in solve
    packages = self._solve()
  File "/opt/homebrew/Cellar/conda-lock/3.0.0/libexec/lib/python3.13/site-packages/conda_lock/_vendor/poetry/puzzle/solver.py", line 166, in _solve
    result = resolve_version(self._package, self._provider)
  File "/opt/homebrew/Cellar/conda-lock/3.0.0/libexec/lib/python3.13/site-packages/conda_lock/_vendor/poetry/mixology/__init__.py", line 18, in resolve_version
    return solver.solve()
           ~~~~~~~~~~~~^^
  File "/opt/homebrew/Cellar/conda-lock/3.0.0/libexec/lib/python3.13/site-packages/conda_lock/_vendor/poetry/mixology/version_solver.py", line 174, in solve
    next = self._choose_package_version()
  File "/opt/homebrew/Cellar/conda-lock/3.0.0/libexec/lib/python3.13/site-packages/conda_lock/_vendor/poetry/mixology/version_solver.py", line 514, in _choose_package_version
    package = self._provider.complete_package(package)
  File "/opt/homebrew/Cellar/conda-lock/3.0.0/libexec/lib/python3.13/site-packages/conda_lock/_vendor/poetry/puzzle/provider.py", line 545, in complete_package
    self.search_for_direct_origin_dependency(dep)
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^
  File "/opt/homebrew/Cellar/conda-lock/3.0.0/libexec/lib/python3.13/site-packages/conda_lock/_vendor/poetry/puzzle/provider.py", line 218, in search_for_direct_origin_dependency
    package = self._search_for_vcs(dependency)
  File "/opt/homebrew/Cellar/conda-lock/3.0.0/libexec/lib/python3.13/site-packages/conda_lock/_vendor/poetry/puzzle/provider.py", line 293, in _search_for_vcs
    package = self._direct_origin.get_package_from_vcs(
        dependency.vcs,
    ...<6 lines>...
        or (self._env.path.joinpath("src") if self._env else None),
    )
  File "/opt/homebrew/Cellar/conda-lock/3.0.0/libexec/lib/python3.13/site-packages/conda_lock/_vendor/poetry/packages/direct_origin.py", line 116, in get_package_from_vcs
    return _get_package_from_git(
        url=url,
    ...<4 lines>...
        source_root=source_root,
    )
  File "/opt/homebrew/Cellar/conda-lock/3.0.0/libexec/lib/python3.13/site-packages/conda_lock/_vendor/poetry/packages/direct_origin.py", line 48, in _get_package_from_git
    package = DirectOrigin.get_package_from_directory(path)
  File "/opt/homebrew/Cellar/conda-lock/3.0.0/libexec/lib/python3.13/site-packages/conda_lock/_vendor/poetry/packages/direct_origin.py", line 80, in get_package_from_directory
    return PackageInfo.from_directory(path=directory).to_package(root_dir=directory)
           ~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/conda-lock/3.0.0/libexec/lib/python3.13/site-packages/conda_lock/_vendor/poetry/inspection/info.py", line 462, in from_directory
    info = get_pep517_metadata(path)
  File "/opt/homebrew/Cellar/conda-lock/3.0.0/libexec/lib/python3.13/site-packages/conda_lock/_vendor/poetry/inspection/info.py", line 543, in get_pep517_metadata
    with isolated_builder(path, "wheel") as builder:
         ~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/[email protected]/3.13.2/Frameworks/Python.framework/Versions/3.13/lib/python3.13/contextlib.py", line 141, in __enter__
    return next(self.gen)
  File "/opt/homebrew/Cellar/conda-lock/3.0.0/libexec/lib/python3.13/site-packages/conda_lock/_vendor/poetry/utils/isolated_build.py", line 180, in isolated_builder
    with ephemeral_environment(
         ~~~~~~~~~~~~~~~~~~~~~^
        executable=python_executable,
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        flags={"no-pip": True},
        ^^^^^^^^^^^^^^^^^^^^^^^
    ) as venv:
    ^
  File "/opt/homebrew/Cellar/[email protected]/3.13.2/Frameworks/Python.framework/Versions/3.13/lib/python3.13/contextlib.py", line 141, in __enter__
    return next(self.gen)
  File "/opt/homebrew/Cellar/conda-lock/3.0.0/libexec/lib/python3.13/site-packages/conda_lock/_vendor/poetry/utils/env/__init__.py", line 47, in ephemeral_environment
    EnvManager.build_venv(
    ~~~~~~~~~~~~~~~~~~~~~^
        path=venv_dir,
        ^^^^^^^^^^^^^^
        executable=executable,
        ^^^^^^^^^^^^^^^^^^^^^^
        flags=flags,
        ^^^^^^^^^^^^
    )
    ^
  File "/opt/homebrew/Cellar/conda-lock/3.0.0/libexec/lib/python3.13/site-packages/conda_lock/_vendor/poetry/utils/env/env_manager.py", line 557, in build_venv
    import xattr
  File "/opt/homebrew/Cellar/conda-lock/3.0.0/libexec/lib/python3.13/site-packages/xattr/__init__.py", line 12, in <module>
    from .lib import (XATTR_NOFOLLOW, XATTR_CREATE, XATTR_REPLACE,
    ...<3 lines>...
        _removexattr, _fremovexattr, _listxattr, _flistxattr)
  File "/opt/homebrew/Cellar/conda-lock/3.0.0/libexec/lib/python3.13/site-packages/xattr/lib.py", line 4, in <module>
    from ._lib import lib, ffi
ModuleNotFoundError: No module named '_cffi_backend'

What did you expect to happen?

I expected no exception to be thrown and for the command to complete successfully.

Step-by-step reproduction instructions (by running brew commands)

  1. Run brew install conda-lock
  2. Create an environment.yaml
    • Unfortunately, I've been unable to reproduce this error with anything except for a private package installed directly from GitLab, but I have more information about the problem at the bottom of this issue.
  3. Run conda-lock

I looked up the error ModuleNotFoundError: No module named '_cffi_backend', and I followed the suggestion of python - No module named _cffi_backend - Stack Overflow to install cffi.

I ran the following command to install the package:

pip --python "$(brew --cellar conda-lock)"/3.0.0/libexec/bin/python install cffi

Afterwards, conda-lock started working!

Therefore, I feel that the problem is that cffi is not being properly included in the formula.

As further evidence, in a fresh conda-lock installation, see that xattr (installed by the formula) requires cffi, which is unavailable:

$ pip --python "$(brew --cellar conda-lock)"/3.0.0/libexec/bin/python show xattr | grep 'Requires:'
Requires: cffi
$ pip --python "$(brew --cellar conda-lock)"/3.0.0/libexec/bin/python show cffi
WARNING: Package(s) not found: cffi
@aphedges
Copy link
Author

aphedges commented Apr 4, 2025

I just thought of a better way to show the problem:

$ "$(brew --cellar conda-lock)"/3.0.0/libexec/bin/python -m pip check
xattr 1.1.4 requires cffi, which is not installed.
secretstorage 3.3.3 requires cryptography, which is not installed.

It might make sense to add a call to pip check as part of every Python package-based formula to catch other bugs like this one.

@daeho-ro
Copy link
Member

Can you check the new revision after the brew update? The PR is merged.

@aphedges
Copy link
Author

I can confirm it works now! Thanks for fixing it!

One weird thing is that I needed to explicitly brew install conda-lock instead of it being automatically updated. Is that expected behavior?

@daeho-ro
Copy link
Member

Once you update brew by brew update and if it is a latest, then brew upgrade conda-lock should work AFAIK. Anyway I am happy to hear that it is working. 👍

@aphedges
Copy link
Author

brew upgrade didn't work, but I didn't try brew upgrade conda-lock. If I encounter this problem again, I'll create a separate issue for it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants