SCM-NV/pyZacros

Why is __init__ in package root?

Closed this issue · 5 comments

I updated to the latest version and I noticed all my scripts are now broken. This seems to be a result of #64, which moves the entire package structure up one level. Now __init__.py and all modules are in the package root. Before they were in the pyzacros subdirectory.

This breaks all my code depending on pyzacros. Every statement such as:

from pyzacros.core.Species import Species

Now becomes:

from core.Species import Species

To me this is really odd in a python package. As a user, if I install pyZacros I'd expect to be able to import it as pyzacros.

But, I can also do:

import tests
import setup
import examples
import doc
import __version__

from anywhere on my system. This can cause some really nasty issues with name collisions with other packages.

For now I will revert to the latest working version, but I hope this change can be reversed in a future update.

Hi Stef,

I think you should be able to import it as pyzacros. How are you installing/importing it?

What works for me is

  1. I clone the github repo, and cd into the folder.
  2. I use pip install -e . on that folder
  3. python -c "import pyzacros; print(pyzacros.__version__)" should print out the version string

Alternatively
pip install -e git+https://github.com/SCM-NV/pyZacros.git#egg=pyzacros
To install without checking out manually, seems to work for me.

I think python setup.py install should also work.

I installed it using pip install -e ..

Did a little testing. Something in the python environment that we use within SCM software is making it work. However, using another environment I see the same issue as you are having. The issue seems to go away if I don't use the -e flag. Can you try that instead?

Yeah, that does seem to work. I prefer to have it in editable mode (easier to update/debug that way). I think the offending line is this one:

packages = ['pyzacros'] + ['pyzacros.'+i for i in find_packages('.')]

Which does something funny during setup.

That particular line is working as intended. It seems that the package_dir option is not really well supported in develop mode, from what I can gather by googling.

However, I found a way to get around it.
I found that the following helped:

git clone git@github.com:SCM-NV/pyZacros.git pyzacros
pip install -e ./pyzacros

Note the lowercase name, like the package. Now, importing pyzacros works for me.