forked from Geodels/gospl
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup.py
136 lines (114 loc) · 3.76 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
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
##############################
# BUILDING CONDA ENVIRONMENT
##############################
#
# conda env export --from-history | grep -v "prefix" > conda-env.yml
# conda env create -f conda-env.yml
# conda activate gospl-package
#
##############################
# BUILDING PYTHON PACKAGE PYPI
##############################
#
# python3 -m pip install --user --upgrade setuptools wheel
# python3 setup.py sdist
# python3 -m pip install --user --upgrade twine
# /usr/local/bin/twine check dist/*
# /usr/local/bin/twine upload dist/*
#
##############################
import os
import io
import sys
import subprocess
from setuptools import find_packages
try:
subprocess.call([sys.executable, "-m", "pip", "install", "numpy"])
except ImportError:
pass
from numpy.distutils.core import setup, Extension
from distutils.command.sdist import sdist
try:
from distutils.command import bdist_conda
except ImportError:
pass
# in development set version to none and ...
PYPI_VERSION = "0.3.2"
# Place install_requires into the text file "requirements.txt"
with open("requirements.txt") as f2:
requirements = f2.read().strip().splitlines()
# class sdist(_sdist):
# def run(self):
# _sdist.run(self)
packs = find_packages(include=["gospl", "gospl.*"])
def git_version():
def _minimal_ext_cmd(cmd):
# construct minimal environment
env = {}
for k in ["SYSTEMROOT", "PATH"]:
v = os.environ.get(k)
if v is not None:
env[k] = v
# LANGUAGE is used on win32
env["LANGUAGE"] = "C"
env["LANG"] = "C"
env["LC_ALL"] = "C"
out = subprocess.Popen(cmd, stdout=subprocess.PIPE, env=env).communicate()[0]
return out
try:
out = _minimal_ext_cmd(["git", "rev-parse", "--short", "HEAD"])
GIT_REVISION = out.strip().decode("ascii")
except OSError:
GIT_REVISION = "Unknown"
return GIT_REVISION
if PYPI_VERSION is None:
PYPI_VERSION = git_version()
ext = Extension(
name="gospl._fortran", sources=["fortran/functions.pyf", "fortran/functions.F90"]
)
this_directory = os.path.abspath(os.path.dirname(__file__))
with io.open(os.path.join(this_directory, "README.rst"), encoding="utf-8") as f:
long_description = f.read()
if __name__ == "__main__":
setup(
name="gospl",
author="Tristan Salles",
author_email="tristan.salles@sydney.edu.au",
url="https://github.com/Geodels/gospl",
version=PYPI_VERSION,
license="GPLv3",
description="A Python interface to perform Global Landscape Evolution Model",
keywords=[
"python",
"paleogeography",
"sediment-transport",
"paleoclimate",
"model",
"landscape",
"landscape-evolution",
"basin-modeling",
"erosion-process",
"compaction",
"lithology",
"science",
],
long_description=long_description,
long_description_content_type="text/markdown",
ext_modules=[ext],
# packages=["gospl", "gospl.tools", "gospl.flow", "gospl.mesher", "gospl.sed"],
packages=packs,
install_requires=requirements,
setup_requires=[[p for p in requirements if p.startswith("numpy")][0]],
python_requires=">=3",
classifiers=[
"Intended Audience :: Science/Research",
"Programming Language :: Fortran",
"Operating System :: Unix",
"Operating System :: MacOS",
"Programming Language :: Python :: 3.6",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
],
cmdclass={"sdist": sdist},
)