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

components.cif lookup fails when AlphaFold3 is installed outside of Python prefix #336

Open
cgross95 opened this issue Mar 6, 2025 · 2 comments
Labels
enhancement New feature or request

Comments

@cgross95
Copy link

cgross95 commented Mar 6, 2025

Problem

When AlphaFold3 is installed outside of the Python prefix (whether a base installation or a virtual environment), the import

from alphafold3.cpp import cif_dict

(e.g., in the build_data and run_alphafold.py scripts), fails with error

ImportError: Could not find the libcifpp components.cif file.

As far as I can tell, this is due to the lookup in src/alphafold3/model/mkdssp_pybind.c that searches for share/libcifpp/components.cif in the value returned by site.getsitepackages(). This will only return the site packages directory under the base installation.

Rationale

There are cases for installing packages outside of the base prefix, and making them available using the PYTHONPATH variable. Our primary use case is when using EasyBuild to make software available to users in a high-performance computing environment. When EasyBuild installs a Python package, it sets PYTHONPATH as part of a module file to allow users access to the package when requested. This improves the modularity of our Python package offerings.

Suggested solution

I suggest replacing the lookup for share/libcifpp/components.cif in site.getsitepackages(). Instead, it should search relative to its own installation path, e.g., pathlib.Path(alphafold3.__path__[0]) / '../share/libcifpp/components.cif'. This finds the file in the existing expected situation when AlphaFold3 is installed in the Python prefix, or if it is installed externally and brought in via PYTHONPATH.

I believe that this also should be changed in the build_data script.

@Augustin-Zidek Augustin-Zidek added the enhancement New feature or request label Mar 7, 2025
@Augustin-Zidek
Copy link
Collaborator

Hello, thanks for the suggestion. I understand the rationale, but I also fear that while this fixes your use-case, it might break the setup for another set of users. I also know our current solution works for 99% of users (based on user feedback), while I have no data for the proposed solution.

Have you verified the approach you are suggesting works in the Docker and Singularity setup that we recommend to users in docs/installation.md? Have you tested this setup with a local installation that doesn't use Docker? Could you send a PR and test it against our GitHub CI?

@cgross95
Copy link
Author

I have tested this fix with a local installation (both inside the Python prefix and outside) that does not use Docker and it is working well. I unfortunately can't easily test the Docker instructions because our HPCC does not allow for Docker builds (and I don't have easy access to cloud credits).

As outlined in CONTRIBUTING.md, I need to review whether my employer has signed the Google CLA before I can send my fix as a PR.

I will update here when I send the PR.

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

No branches or pull requests

2 participants