pazz / urwidtrees

tree widgets for urwid
GNU General Public License v3.0
52 stars 18 forks source link

importing the module itself in setup.py breaks install #35

Closed knoppo closed 7 years ago

knoppo commented 7 years ago

In 4c0e887 the line import urwidtrees was (re-)added to setup.py. Now python setup.py install imports urwid before installing it as a dependency and raises ImportError: No module named urwid.

This was fixed in #29 where other things got broken. Sorry for that! I can create a PR, just thought some clarification and opinions first ;)

A recommended approach is to place the version in a separate file. E.g. urwidtrees/version.py:

__version__ = '1.0.2'

Then read and execute it in setup.py:

with open('urwidtrees/version.py') as f:
    exec(f.read())

setup(
    version=__version__,

and import it in urwidtrees/__init__.py to get urwidtrees.__version__:

from .version import __version__, __version_info__

Further reading: http://stackoverflow.com/questions/458550/standard-way-to-embed-version-into-python-package

The version.py (maybe meta_info.py?) could also contain __author__, __description__, etc. to have it all in a single place and inside the module.

pazz commented 7 years ago

Yes you are right, sorry. I copied the approach taken in another project, but there, the corresponding __init__ file only defines constants and does not do any further imports. I guess an extra version file makes sense. I wonder why one should go through the bother with REs etc, and cannot simply import urwidtrees.version.__version__ as __version__..

pazz commented 7 years ago

checkout current master. If it fixed the issue for you just close this issue.. thanks

knoppo commented 7 years ago

The version import in __init__.py should be relative, the rest looks fine to me.

Edit: or the correct absolute import: from urwidtrees.version import __version__ Edit2: This absolute import should work in the docs conf.py, too. (after sys.path.insert(0, os.path.abspath(os.path.join('..', '..'))))

pazz commented 7 years ago

yep, done. thanks.