windng
Artifact Content
Not logged in

Artifact f60159af439abd961abb8d634f98f61d09d56181:


#!/usr/bin/env python
#-*- coding: utf-8 -*-
#
# setup.py
#
# Copyright 2012-2015 Goyo <goyodiaz@gmail.com>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
# MA 02110-1301, USA.


"""Wind package setup script."""


from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals

from distutils.core import setup
from distutils.command.bdist import bdist
import os

import windng
try:
    import windng.version
except ImportError:
    pass
import windng.version_handling as version_handling


def create_version_module(fname, version):
    import io
    with io.open(fname, 'w') as f:
        f.write('#-*- coding: utf-8 -*-\n')
        f.write('# File generated by setup.py.\n\n')
        f.write('version = \'%s\'\n' % version)


class mybdist(bdist):
    def run(self):
        version = self.distribution.metadata.version
        if 'msi' in self.formats:
            version = version_handling.strict_version(version)
        # py2 bdist (msi) needs this to be a string.
        self.distribution.metadata.version = str(version)
        bdist.run(self)


def main():
    # XXX This should be done by subclassing Distribution?
    try:
        version = str(version_handling.get_full_version(windng._version))
    except IOError:
        version = windng.version.version
    else:
        fname = os.path.join('windng', 'version.py')
        create_version_module(fname, version)

    setup(
        name=str('windng'),  # py2 bdist (msi) needs this to be a string.
        description='Wind data analysis library.',
        author=str('Goyo'),  # py2 bdist (msi) needs this to be a string.
        author_email='goyodiaz@gmail.com',
        version=version,
        url='http://chiselapp.com/user/goyo/repository/windng',
        # distutils (python 2.7.9) needs these to be str. Probably a bug.
        packages=[str('windng'), str('windng.plot'), str('windng.tkgui')],
        # looks like pip requires str here (python 2.7.9)
        package_data={str('windng'): ['tkgui/icons/extremes_app.gif']},
        scripts=['scripts/wind_extremes'],
        requires=['numpy', 'pandas'],
        provides=['windng'],
        license='GPL v2',
        classifiers=[
            'License :: OSI Approved :: GNU General Public License v2 or later (GPLv2+)',
            'Programming Language :: Python :: 2.7'
            'Programming Language :: Python :: 3.4'
        ],
        cmdclass=dict(bdist=mybdist)
    )


if __name__ == '__main__':
    main()