Skip to content

Commit

Permalink
Read version in setup.py without importing tablib
Browse files Browse the repository at this point in the history
Importing tablib in setup.py to read the version number is problematic when
dependencies are needed during tablib import.
  • Loading branch information
claudep committed Aug 30, 2016
1 parent f59abe8 commit 1fe0998
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,20 @@
# -*- coding: utf-8 -*-

import os
import re
import sys

import tablib

try:
from setuptools import setup
except ImportError:
from distutils.core import setup

# Read version from core.py (without importing it)
with open(os.path.join(os.path.dirname(__file__), 'tablib', 'core.py')) as fh:
for line in fh:
if line.startswith('__version__'):
m = re.match(r"^[^=]*=\s'(\d+\.\d+\.\d+)'", line)
version = m.groups()[0]

if sys.argv[-1] == 'publish':
os.system("python setup.py sdist upload")
Expand Down Expand Up @@ -64,7 +69,7 @@

setup(
name='tablib',
version=tablib.__version__,
version=version,
description='Format agnostic tabular data library (XLS, JSON, YAML, CSV)',
long_description=(open('README.rst').read() + '\n\n' +
open('HISTORY.rst').read()),
Expand Down

0 comments on commit 1fe0998

Please sign in to comment.