Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

It actually comes in handy if you're using Sphinx and don't want to maintain release and version in conf.py separately from the version in setup.py. There's no reasons why the data should be consumable only by setuptools .


You can use pkg_resources which comes with setuptools to look up the version number of your package in setup.py:

  import pkg_resources
  pkg_resources.get_distribution("PIL").version


I put the version information inside the package, then anything with access to the package (which both setup.py and sphinx have) can access it - quite useful for doing things like checking the version number from the REPL, for instance.


It can be problematic to import your package from setup.py if you want your dependency specification to be useful.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: