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

import only works in source-tree #1

Closed
gdmcbain opened this issue Apr 13, 2018 · 3 comments
Closed

import only works in source-tree #1

gdmcbain opened this issue Apr 13, 2018 · 3 comments

Comments

@gdmcbain
Copy link
Contributor

Having forked & installed (in a Python 3.6 venv)

pip install -e git+https://github.com/gdmcbain/scikit-fem.git#egg=scikit-fem

I find that I can import skfem and run the examples in the source-tree but not out of it. That is, inside:

cd ~/.pyenv/scikit-fem/src/scikit-fem
python examples/ex1.py

works fine but outside

cp examples/ex1.py ~
cd
python examples/ex1.py

FileNotFoundError: [Errno 2] No such file or directory: 'skfem'

I think it's the __name__ in skfem/__init__.py evaluating as skfem.

Maybe try something like

for filename in os.listdir(os.path.dirname(__file__)):
@kinnala
Copy link
Owner

kinnala commented Apr 13, 2018

Thank you for the notification, the detailed description of the issue and the suggestions for fixing it. I will take a look at it before next week.

The slightly hacky content of __init__.py is a product of shear laziness. I used to list e.g. all different elements in __init__.py for automatic import: I often use the library for creating quick proof-of-concept solvers so automatic import saves time and I got annoyed while updating new elements to __init__.py.

@kinnala
Copy link
Owner

kinnala commented Apr 13, 2018

This should now be fixed in release 0.1.5.

@kinnala kinnala closed this as completed Apr 13, 2018
@gdmcbain
Copy link
Contributor Author

Thank you, that works now.

Apologies though if the importing is now less automatic. I tried __file__ as sketched in the original post and it seemed to work, so for reference I've left that in branch import on my fork; 00f57d0.

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

2 participants