hmedina/KaSaAn

Namespace import: develop vs. install

Closed this issue · 4 comments

KaSaAn.core not found when package installed via ./setup.py install --user, but found when ./setup.py develop --user

I was just about to start an issue on this. I found a variant of the same problem, namely that if one installs KaSaAn with pip:

# in KaSaAn directory
pip install .

then only KaSaAn appears as an empty package in site-packages, meaning you can do import KaSaAn but the submodules like core won't be available. But if one uses the deprecated way of installing,

python setup.py install 

then core becomes available. I don't know why, but I think the issue might be in your setup.py where you have:

setup(
    name='KaSaAn',
    version='0.1.dev0',
    packages=['KaSaAn'],
    package_dir={'': '.'},
...

I believe some package managers rely on you listing the submodules you want to be made available (as described here: https://docs.python.org/3/distutils/setupscript.html#listing-individual-modules)

In a fresh venv:

(venv) $ pip list
Package    Version
---------- -------
pip        20.1.1
setuptools 40.6.2

Installing via:

(venv) $ pip install .

Then trying to use the KaSaAn API as:

(venv) $ python3
Python 3.7.2 (default, Apr 22 2019, 23:35:37)
[GCC 5.4.0 20160609] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from KaSaAn.core import KappaSnapshot
>>> print(KappaSnapshot.__doc__)
Class for representing Kappa snapshots. A snapshot is represented as a dictionary, where the kappa expression
     serves as the key, and the abundance serves as the value. Many of the methods for this class are simple re-namings
     of the Dict() class', but with more informative names for Kappa entities.

So using pip installation with the standard process, the package behaves as I expect it on this machine. I don't understand why some machines find the subpackages, other don't. Maybe an issue with setuptools versioning?

Yep, changing directories reproduced the error. Just pushed a commit that should address this (on this machine at least), so let me know if it remains an issue.