forked from EC-Earth/ece2cmor3
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.py
More file actions
71 lines (61 loc) · 2.64 KB
/
setup.py
File metadata and controls
71 lines (61 loc) · 2.64 KB
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
import os
from setuptools import setup, find_packages
import distutils.command.build_py
from ece2cmor3 import __version__
name = "ece2cmor3"
# Utility function to read the README file.
def read(fname):
return open(os.path.join(os.path.dirname(__file__), fname)).read()
# Utility function to get the git hash, possibly with local changes flag
def get_git_hash():
import git
try:
repo = git.Repo(search_parent_directories=True)
sha = str(repo.head.object.hexsha)
if repo.is_dirty():
sha += "-changes"
except git.exc.InvalidGitRepositoryError:
sha = "local unknown branch"
return sha
# Overriden build command, appending git hash to version python file
class add_sha(distutils.command.build_py.build_py):
def run(self):
distutils.command.build_py.build_py.run(self)
if not self.dry_run:
filepath = os.path.join(self.build_lib, name, "__version__.py")
with open(filepath, "a") as version_file:
version_file.write("sha = \"{hash}\"\n".format(hash=get_git_hash()))
setup(name=name,
version=__version__.version,
author="Gijs van den Oord",
author_email="g.vandenoord@esciencecenter.nl",
description="CMORize and post-process EC-Earth output data",
license="Apache License, Version 2.0",
url="https://github.com/EC-Earth/ece2cmor3",
packages=find_packages(exclude=("tests", "examples")),
package_data={"ece2cmor3": ["resources/*.json",
"resources/*.xlsx",
"resources/*.txt",
"resources/tables/*.json",
"resources/metadata-templates/*.json",
"resources/lists-of-omitted-variables/*.xlsx"]},
include_package_data=True,
long_description=read("README.md"),
entry_points={"console_scripts": [
"ece2cmor = ece2cmor3.ece2cmor:main",
"checkvars = ece2cmor3.scripts.checkvars:main",
"drq2ppt = ece2cmor3.scripts.drq2ppt:main",
"drq2varlist = ece2cmor3.scripts.drq2varlist:main",
"fixmonths = ece2cmor3.scripts.fixmonths:main",
"splitbalance = ece2cmor3.scripts.splitbalance:main"
]},
classifiers=[
"Development Status :: 3 - Alpha",
"Intended Audience :: Science/Research",
"Programming Language :: Python",
"Operating System :: OS Independent",
"Topic :: Scientific/Engineering :: Atmospheric Science",
"License :: OSI Approved :: Apache Software License"
],
cmdclass={"build_py": add_sha}
)