File: setup.py

package info (click to toggle)
python-dendropy 4.5.1-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, sid
  • size: 73,556 kB
  • sloc: python: 25,827; xml: 1,400; sh: 17; makefile: 11
file content (196 lines) | stat: -rw-r--r-- 7,465 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
#! /usr/bin/env python
# -*- coding: utf-8 -*-

##############################################################################
##  DendroPy Phylogenetic Computing Library.
##
##  Copyright 2010-2015 Jeet Sukumaran and Mark T. Holder.
##  All rights reserved.
##
##  See "LICENSE.rst" for terms and conditions of usage.
##
##  If you use this work or any portion thereof in published work,
##  please cite it as:
##
##     Sukumaran, J. and M. T. Holder. 2010. DendroPy: a Python library
##     for phylogenetic computing. Bioinformatics 26: 1569-1571.
##
##############################################################################

"""
Package setup and installation.
"""

import sys
import re
import os
import io

###############################################################################
### "highly-discouraged" workaround to deal with Python 2.8+ and 3.4+ verifying
### certificates by default; this breaks PyPI uploads ...
import ssl
if hasattr(ssl, '_create_unverified_context'):
    ssl._create_default_https_context = ssl._create_unverified_context

###############################################################################
## Utility

def _read(names, **kwargs):
    path = os.path.join(os.path.dirname(__file__), *names)
    if sys.version_info.major < 3:
        return open(path, "rU").read()
    else:
        with open(path, encoding=kwargs.get('encoding', 'utf8')) as src:
            s = src.read()
        return s

def _compose_list(values, prefix=None):
    if prefix is None:
        prefix = ""
    s = []
    max_len = max(len(i) for i in values)
    template = "{}{{value:<{}}}".format(prefix,max_len)
    for v in values:
        s.append(template.format(value=v))
    return "\n".join(s)

###############################################################################
# Identification

__version__ = re.match(r".*^__version__\s*=\s*['\"](.*?)['\"]\s*$.*", _read(["src", "dendropy", "__init__.py"]), re.S | re.M).group(1)
sys.stderr.write("-setup.py: DendroPy version {}\n".format(__version__))

###############################################################################
# setuptools/distutils/etc. import and configuration

try:
    import setuptools
    try:
        setuptools_path = " ('" +  os.path.abspath(setuptools.__file__) + "')"
    except OSError:
        setuptools_path = ""
    sys.stderr.write("-setup.py: using setuptools{}\n".format(setuptools_path))
    from setuptools import setup, find_packages
except ImportError as e:
    sys.stderr.write("-setup.py: using distutils\n")
    from distutils.core import setup
    sys.stderr.write("-setup.py: using canned package list\n")
    PACKAGES = [
            "dendropy",
            "dendropy.calculate",
            "dendropy.dataio",
            "dendropy.datamodel",
            "dendropy.interop",
            "dendropy.legacy",
            "dendropy.mathlib",
            "dendropy.model",
            "dendropy.simulate",
            "dendropy.utility",
            "dendropy.utility.libexec",
            ]
else:
    sys.stderr.write("-setup.py: searching for packages\n")
    PACKAGES = find_packages("src")
EXTRA_KWARGS = dict(
    install_requires = ['setuptools'],
    include_package_data = True,
#    test_suite = "tests",
    zip_safe = True,
    )

sys.stderr.write("-setup.py: packages identified:\n{}\n".format(_compose_list(PACKAGES, prefix="           - ")))
ENTRY_POINTS = {}

###############################################################################
# Script paths

SCRIPT_SUBPATHS = [
    ['applications', 'sumtrees', 'sumtrees.py'],
    ['applications', 'sumlabels', 'sumlabels.py'],
    ['applications', 'dendropy-format', 'dendropy-format'],
    # ['scripts', 'sumtrees', 'cattrees.py'],
    # ['scripts', 'calculators', 'strict_consensus_merge.py'],
    # ['scripts', 'calculators', 'long_branch_symmdiff.py'],
]
SCRIPTS = [os.path.join(*i) for i in SCRIPT_SUBPATHS]
sys.stderr.write("-setup.py: scripts identified:\n{}\n".format(_compose_list(SCRIPTS, prefix="           - ")))

###############################################################################
# setuptools/distuils command extensions

try:
    from setuptools import Command
except ImportError:
    sys.stderr.write("-setup.py: setuptools.Command could not be imported: setuptools extensions not available\n")
else:
    sys.stderr.write("-setup.py: setuptools command extensions are available\n")
    command_hook = "distutils.commands"
    ENTRY_POINTS[command_hook] = []

    ###########################################################################
    # coverage
    # from dendropy.test.support import coverage_analysis
    # if coverage_analysis.DENDROPY_COVERAGE_ANALYSIS_AVAILABLE:
    #     sys.stderr.write("-setup.py: coverage analysis available ('python setup.py coverage')\n")
    #     ENTRY_POINTS[command_hook].append("coverage = dendropy.test.support.coverage_analysis:CoverageAnalysis")
    # else:
    #     sys.stderr.write("-setup.py: coverage analysis not available\n")


###############################################################################
# Main setup

### compose long description ###
long_description = _read(["README.rst"])
long_description = long_description.replace("DendroPy-4.x.x", "DendroPy-{}".format(__version__))
long_description = long_description.replace("""download the source code archive""",
    """`download the source code archive <http://pypi.python.org/packages/source/D/DendroPy/DendroPy-{}.tar.gz>`_""".format(__version__))

long_description = long_description + ("""\

Current Release
===============

The current release of DendroPy is version {}.

""".format(__version__))

setup(name='DendroPy',
      version=__version__,
      author='Jeet Sukumaran and Mark T. Holder',
      author_email='jeetsukumaran@gmail.com, mtholder@ku.edu',
      url='http://packages.python.org/DendroPy/',
      description="A Python library for phylogenetics and phylogenetic computing: reading, writing, simulation, processing and manipulation of phylogenetic trees (phylogenies) and characters.",
      license='BSD',
      packages=PACKAGES,
      package_dir={"": "src"},
      # not needed?
      # package_data={
      #     # "dendropy.utility" : ["libexec/*"],
      #     },
      scripts = SCRIPTS,
      long_description=long_description,
      entry_points = ENTRY_POINTS,
      classifiers = [
            "Intended Audience :: Developers",
            "Intended Audience :: Science/Research",
            "License :: OSI Approved :: BSD License",
            "Natural Language :: English",
            "Operating System :: OS Independent",
            "Programming Language :: Python :: 2.7",
            "Programming Language :: Python :: 3",
            "Programming Language :: Python :: 3.1",
            "Programming Language :: Python :: 3.2",
            "Programming Language :: Python :: 3.3",
            "Programming Language :: Python :: 3.4",
            "Programming Language :: Python :: 3.5",
            "Programming Language :: Python :: 3.6",
            "Programming Language :: Python :: 3.7",
            "Programming Language :: Python :: 3.8",
            "Programming Language :: Python",
            "Topic :: Scientific/Engineering :: Bio-Informatics",
            ],
      keywords='phylogenetics phylogeny phylogenies phylogeography evolution evolutionary biology systematics coalescent population genetics phyloinformatics bioinformatics',
      **EXTRA_KWARGS
      )