Change setup.py to extract version without importing.

This commit is contained in:
Paul Querna 2013-09-20 16:46:23 +00:00
parent 27fba494ed
commit d18f3f189c
2 changed files with 22 additions and 2 deletions

View File

@ -17,11 +17,27 @@ limitations under the License.
"""
from setuptools import setup, find_packages
import codecs
import os
import re
from teeth_agent import agent
here = os.path.abspath(os.path.dirname(__file__))
def read(*parts):
return codecs.open(os.path.join(here, *parts), 'r').read()
def find_version(*file_paths):
version_file = read(*file_paths)
version_match = re.search(r"^__version__ = ['\"]([^'\"]*)['\"]",
version_file, re.M)
if version_match:
return version_match.group(1)
raise RuntimeError("Unable to find version string.")
setup(
name='teeth-agent',
version=agent.AGENT_VERSION,
version=find_version('teeth_agent', '__init__.py'),
packages=find_packages(),
)

View File

@ -0,0 +1,4 @@
__all__ = ["__version__"]
__version__ = "0.1-dev"