From 7f8a611b232df904b32ea3ec6200a443fbbaf007 Mon Sep 17 00:00:00 2001 From: PyYoshi Date: Mon, 17 Oct 2016 20:18:24 +0900 Subject: [PATCH] add version.py --- setup.py | 14 ++++++++++++-- src/cchardet/__init__.py | 5 +---- src/cchardet/version.py | 1 + 3 files changed, 14 insertions(+), 6 deletions(-) create mode 100644 src/cchardet/version.py diff --git a/setup.py b/setup.py index ddbfa81..fdaf6e3 100644 --- a/setup.py +++ b/setup.py @@ -6,14 +6,15 @@ import os import sys import platform +import glob +import codecs +import re try: from setuptools import setup, Extension except ImportError: from distutils.core import setup, Extension -import glob - try: import Cython.Compiler.Main as cython_compiler @@ -63,6 +64,15 @@ cchardet_module = Extension( def read(f): return open(os.path.join(os.path.dirname(__file__), f)).read().strip() + +with codecs.open(os.path.join(os.path.abspath(os.path.dirname(__file__)), 'src', 'cchardet', 'version.py'), 'r', + 'latin1') as fp: + try: + version = re.findall(r"^__version__ = '([^']+)'\r?$", + fp.read(), re.M)[0] + except IndexError: + raise RuntimeError('Unable to determine version.') + setup( name='cchardet', author='PyYoshi', diff --git a/src/cchardet/__init__.py b/src/cchardet/__init__.py index 690f162..3370e04 100644 --- a/src/cchardet/__init__.py +++ b/src/cchardet/__init__.py @@ -1,8 +1,5 @@ -#!/usr/bin/env python -# coding: utf-8 - from cchardet import _cchardet - +from .version import __version__ def detect(msg): """ diff --git a/src/cchardet/version.py b/src/cchardet/version.py new file mode 100644 index 0000000..1a72d32 --- /dev/null +++ b/src/cchardet/version.py @@ -0,0 +1 @@ +__version__ = '1.1.0'