From 910effd145e29660a7bfc1935ffb4a727bf9f7e5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Gra=C3=B1a?= Date: Wed, 6 Feb 2013 11:44:26 -0200 Subject: [PATCH] get scrapy version from package data --- MANIFEST.in | 1 + Makefile.buildbot | 2 +- extras/makedeb.py | 3 ++- scrapy/VERSION | 1 + scrapy/__init__.py | 6 +++--- setup.py | 8 +++++--- 6 files changed, 13 insertions(+), 8 deletions(-) create mode 100644 scrapy/VERSION diff --git a/MANIFEST.in b/MANIFEST.in index dfa3d15df..c9b608a43 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -3,6 +3,7 @@ include AUTHORS include INSTALL include LICENSE include MANIFEST.in +include scrapy/VERSION include scrapy/mime.types recursive-include scrapy/templates * recursive-include scrapy/tests/sample_data * diff --git a/Makefile.buildbot b/Makefile.buildbot index 611260b2a..227fe3e8a 100644 --- a/Makefile.buildbot +++ b/Makefile.buildbot @@ -14,5 +14,5 @@ build: python extras/makedeb.py build clean: - git checkout debian scrapy/__init__.py + git checkout debian scrapy/VERSION git clean -dfq diff --git a/extras/makedeb.py b/extras/makedeb.py index 14ed4dcd6..04dea2cb0 100644 --- a/extras/makedeb.py +++ b/extras/makedeb.py @@ -1,5 +1,6 @@ import sys, os, glob, shutil from subprocess import check_call +from scrapy import version_info def build(suffix): for ifn in glob.glob("debian/scrapy.*"): @@ -29,7 +30,7 @@ def clean(suffix): def main(): cmd = sys.argv[1] - suffix = '%s.%s' % __import__('scrapy').version_info[:2] + suffix = '%s.%s' % version_info[:2] if cmd == 'build': build(suffix) elif cmd == 'clean': diff --git a/scrapy/VERSION b/scrapy/VERSION new file mode 100644 index 000000000..c5523bd09 --- /dev/null +++ b/scrapy/VERSION @@ -0,0 +1 @@ +0.17.0 diff --git a/scrapy/__init__.py b/scrapy/__init__.py index 0d169683c..762106c59 100644 --- a/scrapy/__init__.py +++ b/scrapy/__init__.py @@ -1,9 +1,9 @@ """ Scrapy - a screen scraping framework written in Python """ - -version_info = (0, 17, 0) -__version__ = "0.17.0" +import pkgutil +__version__ = pkgutil.get_data(__package__, 'VERSION').strip() +version_info = tuple(__version__.split('.')[:3]) import sys, os, warnings diff --git a/setup.py b/setup.py index 1c2a610d8..eaca7b369 100644 --- a/setup.py +++ b/setup.py @@ -82,9 +82,11 @@ if os.name == 'nt': if os.environ.get('SCRAPY_VERSION_FROM_GIT'): v = Popen("git describe", shell=True, stdout=PIPE).communicate()[0] - with open('scrapy/__init__.py', 'a') as f: - f.write("\n__version__ = '%s'" % v.strip()) -version = __import__('scrapy').__version__ + with open('scrapy/VERSION', 'w+') as f: + f.write(v.strip()) +with open(os.path.join(os.path.dirname(__file__), 'scrapy/VERSION')) as f: + version = f.read().strip() + setup_args = { 'name': 'Scrapy',