diff options
author | Jon Bernard <jbernard@tuxion.com> | 2014-07-07 14:06:45 -0400 |
---|---|---|
committer | Jon Bernard <jbernard@tuxion.com> | 2014-07-07 14:06:45 -0400 |
commit | d42db02de0519fade43406cf887cc16d37a1032b (patch) | |
tree | b112c0ec28266eee2ca940b565d24b264f4eb710 | |
parent | f27f6472d4f4394f24b25e77d89ea8d87330b5b6 (diff) | |
download | dotfiles-d42db02de0519fade43406cf887cc16d37a1032b.tar.gz dotfiles-d42db02de0519fade43406cf887cc16d37a1032b.tar.bz2 dotfiles-d42db02de0519fade43406cf887cc16d37a1032b.zip |
Parse version string without importing source code
It's probably better to execute as little code as possible from
setup.py, so this approach seems cleaner to me.
-rwxr-xr-x | setup.py | 16 |
1 files changed, 7 insertions, 9 deletions
@@ -1,16 +1,14 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- +import re +import ast +from setuptools import setup -import os -import sys -try: - from setuptools import setup -except ImportError: - from distutils.core import setup +_version_re = re.compile(r'__version__\s+=\s+(.*)') -from dotfiles.core import __version__ +with open('dotfiles/core.py', 'rb') as f: + version = str(ast.literal_eval(_version_re.search( + f.read().decode('utf-8')).group(1))) setup(name='dotfiles', version=__version__, |