-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.py
109 lines (91 loc) · 3.11 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
##############################
# 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.0.1"
# Place install_requires into the text file "requirements.txt"
with open("requirements.txt") as f2:
requirements = f2.read().strip().splitlines()
packs = find_packages(include=["plateinputs", "plateinputs.*"])
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()
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="plateinputs",
author="Tristan Salles",
author_email="[email protected]",
url="https://github.com/Geodels/plateInputs",
version=PYPI_VERSION,
license="GPLv3",
description="A Python interface to build paleogeography forcing in goSPL",
keywords=["python", "paleogeography", "science",],
long_description_content_type="text/markdown",
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",
"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},
)