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

Importing charm4py from project root fails #266

Open
mayantaylor opened this issue Aug 4, 2024 · 0 comments
Open

Importing charm4py from project root fails #266

mayantaylor opened this issue Aug 4, 2024 · 0 comments

Comments

@mayantaylor
Copy link
Collaborator

After successfully installing charm4py, and launching a python shell, import charm4py works in almost every context - except when the python shell is launched from the project root. I believe this is due to the c_object_store.*.so generation. Steps to reproduce the issue are below (this is within a python venv):

cd charm4py
python setup.py install
python
>>> import charm4py
FAILS: ModuleNotFoundError: No module named 'charm4py.c_object_store'
cd <any other directory>
python
>>> import charm4py
SUCCEEDS

Python import search process:
Python import searches the paths in sys.path for a <module_name>/__init.py__. The first entry in sys.path is always the current directory. Other relevant entries include .../lib/python3.11/site-packages, which is where the installed charm4py libraries live. In the charm4py case, the directory found by import must also include a c_object_store.*.so of some form to correctly import charm4py. The problem lies in the fact that $root/charm4py doesn't include this .so:

> > `charm4py % diff <(ls charm4py) <(ls /Users/maya/test/venv/lib/python3.11/site-packages/charm4py)
> 0a1
> > LICENSE
> 5c6
> < c_object_store.html
> ---
> ---
> c_object_store.cpython-311-darwin.so

Potential solutions:
Copying the necessary .so from site-packages into $root/charm4py solves the issue. I'm not sure if the problem here is that the .so is not in this directory, or that import looks in the root directory to begin with.

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

1 participant