Skip to content

Commit

Permalink
Add required files to check astropy is installed
Browse files Browse the repository at this point in the history
  • Loading branch information
timj committed May 4, 2016
1 parent bbf3751 commit 9cef7bd
Show file tree
Hide file tree
Showing 5 changed files with 76 additions and 0 deletions.
Empty file added .tap_package
Empty file.
2 changes: 2 additions & 0 deletions README.md
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.
58 changes: 58 additions & 0 deletions scripts/check_python_module
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)
1 change: 1 addition & 0 deletions ups/astropy.table
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
setupRequired(python)
15 changes: 15 additions & 0 deletions ups/eupspkg.cfg.sh
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() { :; }

0 comments on commit 9cef7bd

Please sign in to comment.