aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Jon Bernard <jbernard@tuxion.com> 2014-07-07 14:06:45 -0400
committerGravatar Jon Bernard <jbernard@tuxion.com> 2014-07-07 14:06:45 -0400
commitd42db02de0519fade43406cf887cc16d37a1032b (patch)
treeb112c0ec28266eee2ca940b565d24b264f4eb710
parentf27f6472d4f4394f24b25e77d89ea8d87330b5b6 (diff)
downloaddotfiles-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-xsetup.py16
1 files changed, 7 insertions, 9 deletions
diff --git a/setup.py b/setup.py
index 6845d9e..bde020f 100755
--- a/setup.py
+++ b/setup.py
@@ -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__,