forked from tsutterley/pyTMD
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup.py
92 lines (83 loc) · 3.14 KB
/
setup.py
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
import os
import sys
import logging
import subprocess
from setuptools import setup, find_packages
logging.basicConfig(stream=sys.stderr, level=logging.INFO)
log = logging.getLogger()
# package description and keywords
description = ('Tide Model Driver to read OTIS, GOT and FES formatted tidal '
'solutions and make tidal predictions')
keywords = 'Ocean Tides, Load Tides, Pole Tides, Tidal Prediction, OTIS, GOT, FES'
# get long_description from README.rst
with open("README.rst", "r") as fh:
long_description = fh.read()
long_description_content_type = "text/x-rst"
# get install requirements
with open('requirements.txt') as fh:
install_requires = [line.split().pop(0) for line in fh.read().splitlines()]
# dependency links (data readers)
dependency_links = ['https://github.com/tsutterley/read-ICESat-2/tarball/main',
'https://github.com/tsutterley/read-ATM1b-QFIT-binary/tarball/main']
# get version
with open('version.txt') as fh:
fallback_version = fh.read()
# list of all scripts to be included with package
scripts=[os.path.join('scripts',f) for f in os.listdir('scripts') if f.endswith('.py')]
# run cmd from the command line
def check_output(cmd):
return subprocess.check_output(cmd).decode('utf')
# check if GDAL is installed
gdal_output = [None] * 4
try:
for i, flag in enumerate(("--cflags", "--libs", "--datadir", "--version")):
gdal_output[i] = check_output(['gdal-config', flag]).strip()
except:
log.warning('Failed to get options via gdal-config')
else:
log.info("GDAL version from via gdal-config: {0}".format(gdal_output[3]))
# if setting GDAL version from via gdal-config
if gdal_output[3]:
# add version information to gdal in install_requires
gdal_index = install_requires.index('gdal')
install_requires[gdal_index] = 'gdal=={0}'.format(gdal_output[3])
elif any(install_requires):
# gdal version not found
gdal_index = install_requires.index('gdal')
install_requires.pop(gdal_index)
# semantic version configuration for setuptools-scm
setup_requires = ["setuptools_scm"]
use_scm_version = {
"relative_to": __file__,
"local_scheme": "node-and-date",
"version_scheme": "python-simplified-semver",
"fallback_version":fallback_version,
}
setup(
name='pyTMD',
description=description,
long_description=long_description,
long_description_content_type=long_description_content_type,
url='https://github.com/tsutterley/pyTMD',
author='Tyler Sutterley',
author_email='[email protected]',
license='MIT',
classifiers=[
'Development Status :: 3 - Alpha',
'Intended Audience :: Science/Research',
'Topic :: Scientific/Engineering :: Physics',
'License :: OSI Approved :: MIT License',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.6',
'Programming Language :: Python :: 3.7',
'Programming Language :: Python :: 3.8',
],
keywords=keywords,
packages=find_packages(),
install_requires=install_requires,
setup_requires=setup_requires,
dependency_links=dependency_links,
use_scm_version=use_scm_version,
scripts=scripts,
include_package_data=True,
)