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 the module itself in setup.py breaks install #35

Closed
knoppo opened this issue Dec 25, 2016 · 4 comments
Closed

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

knoppo opened this issue Dec 25, 2016 · 4 comments

Comments

@knoppo
Copy link
Contributor

knoppo commented Dec 25, 2016

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
Copy link
Owner

pazz commented Dec 25, 2016

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
Copy link
Owner

pazz commented Dec 25, 2016

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

@knoppo
Copy link
Contributor Author

knoppo commented Dec 27, 2016

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
Copy link
Owner

pazz commented Dec 27, 2016

yep, done. thanks.

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