From 51de2e3530d11631be2b8baaaf615efa51919a61 Mon Sep 17 00:00:00 2001 From: "Per.Andreas.Brodtkorb" Date: Tue, 5 Oct 2010 09:08:56 +0000 Subject: [PATCH] Added version generation to setup.py Simplified __init__.py files to avoid duplicate inclusion of wafo. --- pywafo/setup.py | 170 ++++++++++++++++++-------- pywafo/src/Wafo.egg-info/SOURCES.txt | 20 +-- pywafo/src/wafo/__init__.py | 24 ++-- pywafo/src/wafo/data/__init__.py | 4 +- pywafo/src/wafo/spectrum/__init__.py | 6 +- pywafo/src/wafo/stats/__init__.py | 2 +- pywafo/src/wafo/transform/__init__.py | 4 +- 7 files changed, 156 insertions(+), 74 deletions(-) diff --git a/pywafo/setup.py b/pywafo/setup.py index 57b9d8e..36efd1a 100644 --- a/pywafo/setup.py +++ b/pywafo/setup.py @@ -14,9 +14,20 @@ python setup.py sdist bdist_wininst upload --show-response """ #!/usr/bin/env python -import os, sys -#sys.argv.append("develop") +import os +import sys +import subprocess +import re + +MAJOR = 0 +MINOR = 1 +MICRO = 1 +ISRELEASED = False +VERSION = '%d.%d.%d' % (MAJOR, MINOR, MICRO) + + +sys.argv.append("develop") #sys.argv.append("install") DISTUTILS_DEBUG = True pkg_name = 'wafo' @@ -33,52 +44,109 @@ if True: #__file__ == 'setupegg.py': else: from distutils.core import setup -t = find_packages('src') -subpackages = ('spectrum','data','transform','covariance') -#subpackagesfull = [os.path.join(pkg_name,f) for f in subpackages] - -subtests = [os.path.join(subpkg,'test') for subpkg in subpackages] - -testscripts = [os.path.join(subtst, f) for subtst in subtests - for f in os.listdir(os.path.join(root_dir, subtst)) - if not (f.startswith('.') or f.endswith('~') or - f.endswith('.old') or f.endswith('.bak'))] -datadir = 'data' -datafiles = [os.path.join(datadir, f) for f in os.listdir(os.path.join(root_dir, datadir)) - if not (f.startswith('.') or f.endswith('~') or - f.endswith('.old') or f.endswith('.bak') or - f.endswith('.py') or f.endswith('test') )] -libs = [f for f in os.listdir(os.path.join(root_dir)) if f.endswith('.pyd') ] -packagedata = testscripts + datafiles + libs #['c_library.pyd'] #,'disufq1.c','diffsumfunq.pyd','diffsumfunq.pyf','findrfc.c','rfc.pyd','rfc.pyf'] - - -setup( - version = '0.11', - author='WAFO-group', - author_email='wafo@maths.lth.se', - decription = 'Statistical analysis and simulation of random waves and random loads', - long_description = info.__doc__, - install_requires = ['numpy>=1.4','numdifftools>=0.2'], - license = "GPL", - url='http://code.google.com/p/pywafo/', - name = pkg_name, - package_dir = {'': 'src'}, - packages = find_packages('src'), - package_data = {'': packagedata}, - classifiers=[ - 'Development Status :: 4 - Beta', - 'Intended Audience :: Education', - 'Intended Audience :: Science/Research', - 'License :: OSI Approved :: GNU General Public License (GPL)', - 'Operating System :: Microsoft :: Windows', - 'Programming Language :: Python :: 2.6', - 'Topic :: Scientific/Engineering :: Mathematics', - ], - #packages = [package_name,] + list(subpackagesfull), - #package_data = {package_name: packagedata}, - #package_data = {'': ['wafo.cfg']}, - #scripts = [os.path.join('bin', f) - # for f in os.listdir('bin') - # if not (f.startswith('.') or f.endswith('~') or - # f.endswith('.old') or f.endswith('.bak'))], - ) + +# Return the svn version as a string, raise a ValueError otherwise +def svn_version(): + from numpy.compat import asstr + + env = os.environ.copy() + env['LC_ALL'] = 'C' + try: + out = subprocess.Popen(['svn', 'info'], stdout=subprocess.PIPE, + env=env).communicate()[0] + except OSError: + warnings.warn(" --- Could not run svn info --- ") + return "" + + r = re.compile('Revision: ([0-9]+)') + svnver = None + for line in asstr(out).split('\n'): + m = r.match(line) + if m: + svnver = m.group(1) + + if not svnver: + raise ValueError("Error while parsing svn version ?") + return svnver + +FULLVERSION = VERSION +if not ISRELEASED: + FULLVERSION += '.dev' + # If in git or something, bypass the svn rev + if os.path.exists('.svn'): + FULLVERSION += svn_version() + +def write_version_py(filename='version.py'): + cnt = """\ +# THIS FILE IS GENERATED FROM SETUP.PY +short_version='%(version)s' +version='%(version)s' +release=%(isrelease)s +""" + fid = open(os.path.join(rootdir,filename), 'w') + try: + fid.write(cnt % {'version': VERSION, 'isrelease': str(ISRELEASED)}) + finally: + fid.close() + +if __name__=='__main__': + write_version_py() + + packages = find_packages('src') + package_paths =[p.replace(pkg_name,+'.','').replace(pkg_name,'').replace('.',os.path.sep) + for p in packages] + test_paths = [os.path.join(pkg_path,'test') for pkg_path in package_paths + if os.path.exists(os.path.join(root_dir,pkg_path,'test'))] + testscripts = [os.path.join(subtst, f) for subtst in test_paths + for f in os.listdir(os.path.join(root_dir, subtst)) + if not (f.startswith('.') or f.endswith('~') or + f.endswith('.old') or f.endswith('.bak'))] + + #subpackages = ('spectrum','data','transform','covariance') + #subpackagesfull = [os.path.join(pkg_name,f) for f in subpackages] + + #subtests = [os.path.join(subpkg,'test') for subpkg in subpackages] + + #testscripts = [os.path.join(subtst, f) for subtst in subtests + # for f in os.listdir(os.path.join(root_dir, subtst)) + # if not (f.startswith('.') or f.endswith('~') or + # f.endswith('.old') or f.endswith('.bak'))] + datadir = 'data' + datafiles = [os.path.join(datadir, f) for f in os.listdir(os.path.join(root_dir, datadir)) + if not (f.startswith('.') or f.endswith('~') or + f.endswith('.old') or f.endswith('.bak') or + f.endswith('.py') or f.endswith('test') )] + libs = [f for f in os.listdir(os.path.join(root_dir)) if f.endswith('.pyd') ] + packagedata = testscripts + datafiles + libs #['c_library.pyd'] #,'disufq1.c','diffsumfunq.pyd','diffsumfunq.pyf','findrfc.c','rfc.pyd','rfc.pyf'] + + + setup( + version = VERSION, + author='WAFO-group', + author_email='wafo@maths.lth.se', + decription = 'Statistical analysis and simulation of random waves and random loads', + long_description = info.__doc__, + install_requires = ['numpy>=1.4','numdifftools>=0.2'], + license = "GPL", + url='http://code.google.com/p/pywafo/', + name = pkg_name, + package_dir = {'': 'src'}, + packages = packages, + package_data = {'': packagedata}, + classifiers=[ + 'Development Status :: 4 - Beta', + 'Intended Audience :: Education', + 'Intended Audience :: Science/Research', + 'License :: OSI Approved :: GNU General Public License (GPL)', + 'Operating System :: Microsoft :: Windows', + 'Programming Language :: Python :: 2.6', + 'Topic :: Scientific/Engineering :: Mathematics', + ], + #packages = [package_name,] + list(subpackagesfull), + #package_data = {package_name: packagedata}, + #package_data = {'': ['wafo.cfg']}, + #scripts = [os.path.join('bin', f) + # for f in os.listdir('bin') + # if not (f.startswith('.') or f.endswith('~') or + # f.endswith('.old') or f.endswith('.bak'))], + ) diff --git a/pywafo/src/Wafo.egg-info/SOURCES.txt b/pywafo/src/Wafo.egg-info/SOURCES.txt index b9e67fc..28a12be 100644 --- a/pywafo/src/Wafo.egg-info/SOURCES.txt +++ b/pywafo/src/Wafo.egg-info/SOURCES.txt @@ -4,6 +4,7 @@ gendocwafo.py manifest setup.py setup_old.py +test_all.py src/epydoc_wafo.prj src/Wafo.egg-info/PKG-INFO src/Wafo.egg-info/SOURCES.txt @@ -12,7 +13,6 @@ src/Wafo.egg-info/top_level.txt src/wafo/SpecData1D.mm src/wafo/__init__.py src/wafo/c_library.pyd -src/wafo/data_structures.py src/wafo/dctpack.py src/wafo/definitions.py src/wafo/definitions.~py @@ -25,18 +25,14 @@ src/wafo/kdetools.py src/wafo/meshgrid.py src/wafo/misc.py src/wafo/mvn.pyd -src/wafo/mvn.pyf -src/wafo/mvndst.f src/wafo/mvnprdmod.pyd src/wafo/namedtuple.py src/wafo/objects.py src/wafo/plotbackend.py src/wafo/polynomial.py src/wafo/polynomial_old.py -src/wafo/ppimport.py src/wafo/rindmod.pyd src/wafo/sg_filter.py -src/wafo/test_ppimport.py src/wafo/wafodata.py src/wafo.egg-info/SOURCES.txt src/wafo/covariance/__init__.py @@ -100,6 +96,10 @@ src/wafo/source/mreg/rintmod.mod src/wafo/source/mreg/sizemod.mod src/wafo/source/mreg/svd.mod src/wafo/source/mreg/tbrmod.mod +src/wafo/source/mvn/build_all.py +src/wafo/source/mvn/mvn.pyd +src/wafo/source/mvn/mvn.pyf +src/wafo/source/mvn/mvndst.f src/wafo/source/mvnprd/adaptivegausskronrod.mod src/wafo/source/mvnprd/build_all.py src/wafo/source/mvnprd/erfcoremod.mod @@ -264,9 +264,15 @@ src/wafo/stats/distributions.py src/wafo/stats/distributions_juli2010.py src/wafo/stats/estimation.py src/wafo/stats/misc.py -src/wafo/stats/plotbackend.py +src/wafo/stats/twolumps.py src/wafo/test/__init__.py +src/wafo/test/test_gaussian.py +src/wafo/test/test_misc.py +src/wafo/test/test_objects.py src/wafo/transform/__init__.py src/wafo/transform/core.py src/wafo/transform/models.py -src/wafo/transform/models.~py \ No newline at end of file +src/wafo/transform/models.~py +src/wafo/transform/test/__init__.py +src/wafo/transform/test/test_models.py +src/wafo/transform/test/test_trdata.py \ No newline at end of file diff --git a/pywafo/src/wafo/__init__.py b/pywafo/src/wafo/__init__.py index 472490b..e54ef8c 100644 --- a/pywafo/src/wafo/__init__.py +++ b/pywafo/src/wafo/__init__.py @@ -1,10 +1,18 @@ from info import __doc__ -import wafo.misc -import wafo.data -import wafo.objects -import wafo.spectrum -import wafo.transform -import wafo.definitions -import wafo.polynomial -import wafo.stats \ No newline at end of file +import misc +import data +import objects +import spectrum +import transform +import definitions +import polynomial +import stats + +try: + from wafo.version import version as __version__ +except ImportError: + __version__='nobuilt' + +from numpy.testing import Tester +test = Tester().test \ No newline at end of file diff --git a/pywafo/src/wafo/data/__init__.py b/pywafo/src/wafo/data/__init__.py index 011591c..c58c88e 100644 --- a/pywafo/src/wafo/data/__init__.py +++ b/pywafo/src/wafo/data/__init__.py @@ -1,3 +1,3 @@ -from wafo.data.info import __doc__ -from wafo.data.info import * +from info import __doc__ +from info import * diff --git a/pywafo/src/wafo/spectrum/__init__.py b/pywafo/src/wafo/spectrum/__init__.py index e56bd4c..c43b698 100644 --- a/pywafo/src/wafo/spectrum/__init__.py +++ b/pywafo/src/wafo/spectrum/__init__.py @@ -5,6 +5,6 @@ Spectrum package in WAFO Toolbox. """ -from wafo.spectrum.core import SpecData1D -import wafo.spectrum.models -import wafo.spectrum.dispersion_relation +from core import SpecData1D +import models +import dispersion_relation diff --git a/pywafo/src/wafo/stats/__init__.py b/pywafo/src/wafo/stats/__init__.py index 79d3265..08c9f6c 100644 --- a/pywafo/src/wafo/stats/__init__.py +++ b/pywafo/src/wafo/stats/__init__.py @@ -5,5 +5,5 @@ Statistics package in WAFO Toolbox. """ from scipy.stats import * -from wafo.stats.core import * +from core import * from wafo.stats.distributions import * diff --git a/pywafo/src/wafo/transform/__init__.py b/pywafo/src/wafo/transform/__init__.py index 735d08c..c89bb56 100644 --- a/pywafo/src/wafo/transform/__init__.py +++ b/pywafo/src/wafo/transform/__init__.py @@ -2,5 +2,5 @@ Transform package in WAFO Toolbox. """ -from wafo.transform.core import * -import wafo.transform.models +from core import * +import models