Skip to content

Commit 4a5c806

Browse files
author
Matthias Dusch
committed
first major commit
1 parent ebdc1ef commit 4a5c806

File tree

4 files changed

+473
-0
lines changed

4 files changed

+473
-0
lines changed

.gitignore

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
TRiCAN_GUI.egg-info
2+
.idea
3+
tricangui/__pycache__
4+
tricangui/version.py

setup.py

+169
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,169 @@
1+
"""Setup file for the Salem package.
2+
3+
Adapted from the Python Packaging Authority template."""
4+
5+
from setuptools import setup, find_packages # Always prefer setuptools
6+
from codecs import open # To use a consistent encoding
7+
from os import path, walk
8+
import sys, warnings, importlib, re
9+
10+
MAJOR = 0
11+
MINOR = 0
12+
MICRO = 1
13+
ISRELEASED = False
14+
VERSION = '%d.%d.%d' % (MAJOR, MINOR, MICRO)
15+
QUALIFIER = ''
16+
17+
DISTNAME = 'TRiCAN-GUI'
18+
LICENSE = 'MIT'
19+
AUTHOR = 'Matthias Dusch'
20+
AUTHOR_EMAIL = '[email protected]'
21+
URL = 'https://github.com/matthiasdusch/trican-gui'
22+
CLASSIFIERS = [
23+
# How mature is this project? Common values are
24+
# 3 - Alpha 4 - Beta 5 - Production/Stable
25+
'Development Status :: 3 - Beta',
26+
# Indicate who your project is intended for
27+
'Intended Audience :: Science/Research',
28+
'License :: OSI Approved :: MIT License' +
29+
'Programming Language :: Python :: 3.5',
30+
]
31+
32+
DESCRIPTION = 'GUI for TRiCAN'
33+
LONG_DESCRIPTION = """
34+
A Graphic user Interface for the TRiCAN
35+
https://github.com/matthiasdusch/trican-gui
36+
"""
37+
38+
# code to extract and write the version copied from pandas
39+
FULLVERSION = VERSION
40+
write_version = True
41+
42+
if not ISRELEASED:
43+
import subprocess
44+
FULLVERSION += '.dev'
45+
46+
pipe = None
47+
for cmd in ['git', 'git.cmd']:
48+
try:
49+
pipe = subprocess.Popen(
50+
[cmd, "describe", "--always", "--match", "v[0-9]*"],
51+
stdout=subprocess.PIPE)
52+
(so, serr) = pipe.communicate()
53+
if pipe.returncode == 0:
54+
break
55+
except:
56+
pass
57+
58+
if pipe is None or pipe.returncode != 0:
59+
# no git, or not in git dir
60+
if path.exists('tricangui/version.py'):
61+
warnings.warn("WARNING: Couldn't get git revision, using existing "
62+
"trican/version.py")
63+
write_version = False
64+
else:
65+
warnings.warn("WARNING: Couldn't get git revision, using generic "
66+
"version string")
67+
else:
68+
# have git, in git dir, but may have used a shallow clone (travis)
69+
rev = so.strip()
70+
# makes distutils blow up on Python 2.7
71+
if sys.version_info[0] >= 3:
72+
rev = rev.decode('ascii')
73+
74+
if not rev.startswith('v') and re.match("[a-zA-Z0-9]{7,9}", rev):
75+
# partial clone, manually construct version string
76+
# this is the format before we started using git-describe
77+
# to get an ordering on dev version strings.
78+
rev = "v%s.dev-%s" % (VERSION, rev)
79+
80+
# Strip leading v from tags format "vx.y.z" to get th version string
81+
FULLVERSION = rev.lstrip('v').replace(VERSION + '-', VERSION + '+')
82+
else:
83+
FULLVERSION += QUALIFIER
84+
85+
86+
def write_version_py(filename=None):
87+
cnt = """\
88+
version = '%s'
89+
short_version = '%s'
90+
isreleased = %s
91+
"""
92+
if not filename:
93+
filename = path.join(path.dirname(__file__), 'tricangui', 'version.py')
94+
95+
a = open(filename, 'w')
96+
try:
97+
a.write(cnt % (FULLVERSION, VERSION, ISRELEASED))
98+
finally:
99+
a.close()
100+
101+
102+
if write_version:
103+
write_version_py()
104+
105+
106+
def check_dependencies(package_names):
107+
"""Check if packages can be imported, if not throw a message."""
108+
not_met = []
109+
for n in package_names:
110+
try:
111+
_ = importlib.import_module(n)
112+
except ImportError:
113+
not_met.append(n)
114+
if len(not_met) != 0:
115+
errmsg = "Warning: the following packages could not be found: "
116+
print(errmsg + ', '.join(not_met))
117+
118+
119+
req_packages = ['numpy',
120+
'scipy',
121+
'pandas',
122+
'matplotlib',
123+
'trican'
124+
]
125+
check_dependencies(req_packages)
126+
127+
128+
def file_walk(top, remove=''):
129+
"""
130+
Returns a generator of files from the top of the tree, removing
131+
the given prefix from the root/file result.
132+
"""
133+
top = top.replace('/', path.sep)
134+
remove = remove.replace('/', path.sep)
135+
for root, dirs, files in walk(top):
136+
for file in files:
137+
yield path.join(root, file).replace(remove, '')
138+
139+
setup(
140+
# Project info
141+
name=DISTNAME,
142+
version=FULLVERSION,
143+
description=DESCRIPTION,
144+
long_description=LONG_DESCRIPTION,
145+
# The project's main homepage.
146+
url=URL,
147+
# Author details
148+
author=AUTHOR,
149+
author_email=AUTHOR_EMAIL,
150+
# License
151+
license=LICENSE,
152+
classifiers=CLASSIFIERS,
153+
# What does your project relate to?
154+
keywords=['geosciences', 'dendrochronology', 'climate'],
155+
# We are a python 3 only shop
156+
python_requires='>=3.4',
157+
# Find packages automatically
158+
packages=find_packages(exclude=['docs']),
159+
# Decided not to let pip install the dependencies, this is too brutal
160+
install_requires=[],
161+
# additional groups of dependencies here (e.g. development dependencies).
162+
extras_require={},
163+
# data files that need to be installed
164+
package_data={},
165+
# Old
166+
data_files=[],
167+
# Executable scripts
168+
entry_points={},
169+
)

tricangui/__init__.py

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
from .__main__ import main
2+
3+
if __name__ == '__main__':
4+
main()

0 commit comments

Comments
 (0)