title: What is the correct way to share package version with setup.py and the package?
body: <p>With <code>distutils</code>, <code>setuptools</code>, etc. a package version is specified in <code>setup.py</code>:</p>
  
  <pre><code># file: setup.py
  ...
  setup(
  name='foobar',
  version='1.0.0',
  # other attributes
  )
  </code></pre>
  
  <p>I would like to be able to access the same version number from within the package:</p>
  
  <pre><code>&gt;&gt;&gt; import foobar
  &gt;&gt;&gt; foobar.__version__
  '1.0.0'
  </code></pre>
  
  <hr>
  
  <p>I could add <code>__version__ = '1.0.0'</code> to my package's __init__.py, but I would also like to include additional imports in my package to create a simplified interface to the package:</p>
  
  <pre><code># file: __init__.py
  
  from foobar import foo
  from foobar.bar import Bar
  
  __version__ = '1.0.0'
  </code></pre>
  
  <p>and</p>
  
  <pre><code># file: setup.py
  
  from foobar import __version__
  ...
  setup(
  name='foobar',
  version=__version__,
  # other attributes
  )
  </code></pre>
  
  <p>However, these additional imports can cause the installation of <code>foobar</code> to fail if they import other packages that are not yet installed. What is the correct way to share package version with setup.py and the package?</p>