-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add required files to check astropy is installed
- Loading branch information
Showing
5 changed files
with
76 additions
and
0 deletions.
There are no files selected for viewing
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,4 @@ | ||
# astropy | ||
EUPS pseudo package for Astropy | ||
|
||
Does not included Astropy, simply checks that Astropy is available with the correct version. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
#!/usr/bin/env python | ||
# | ||
# Check if a compatible version of a python module is installed | ||
# | ||
# usage: check_python_module <module> <min_version> | ||
# | ||
|
||
from __future__ import print_function | ||
import sys | ||
import importlib | ||
import argparse | ||
|
||
parser = argparse.ArgumentParser(description="Check presence and version of a Python module") | ||
parser.add_argument("module", help="python module to check") | ||
parser.add_argument("min_version", help="minimum version") | ||
parser.add_argument("-v", "--verbose", action="store_true") | ||
args = parser.parse_args() | ||
|
||
modname = args.module | ||
version = args.min_version | ||
|
||
# | ||
# See if numpy is installed in the first place | ||
# | ||
try: | ||
module = importlib.import_module(modname) | ||
except ImportError: | ||
print("error: %(module)s is not installed." | ||
" Please install %(module)s v%(needver)s or later and try again." % { | ||
'module': modname, | ||
'needver': version | ||
}, | ||
file=sys.stderr) | ||
exit(-1) | ||
|
||
# | ||
# Check version compatibility | ||
# | ||
needver = list(map(int, version.split('.'))) | ||
havever = list(map(int, module.__version__.split('.'))) + [0] * len(needver) | ||
for a, b in zip(needver, havever): | ||
if a > b: | ||
print("error: %(module)s version too old (v%(havever)s)." | ||
" Please install %(module)s v%(needver)s or later and try again." % { | ||
'module': modname, | ||
'havever': module.__version__, | ||
'needver': version | ||
}, | ||
file=sys.stderr) | ||
exit(-1) | ||
elif a < b: | ||
break | ||
|
||
if args.verbose: | ||
print("Using externally provided %s v%s." % (modname, module.__version__)) | ||
|
||
# OK. | ||
exit(0) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
setupRequired(python) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
_MODULE="astropy" | ||
_VERSION="1.1.1" | ||
|
||
config() | ||
{ | ||
# Verify that a compatible module can be found exists | ||
./scripts/check_python_module -v $_MODULE $_VERSION | eups_console | ||
|
||
if [[ ${PIPESTATUS[0]} -ne 0 ]]; then | ||
die "Failed to find a compatible externally provided $_MODULE." | ||
fi | ||
} | ||
|
||
prep() { :; } | ||
build() { :; } |