Skip to content

Commit

Permalink
Merge 4dcd99f into ffc22c8
Browse files Browse the repository at this point in the history
  • Loading branch information
mwcraig committed Dec 30, 2015
2 parents ffc22c8 + 4dcd99f commit 10672f2
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 10 deletions.
5 changes: 5 additions & 0 deletions astroscrappy/utils/imutils.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@
#ifndef IMUTILS_H_
#define IMUTILS_H_

/* Including definitions of the standard int types is necesssary for Windows,
* and does no harm on other platforms.
*/
#include <stdint.h>

/* Define a bool type because there isn't one built in ANSI C */
typedef uint8_t bool;
#define true 1
Expand Down
5 changes: 5 additions & 0 deletions astroscrappy/utils/medutils.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@
#ifndef MEDUTILS_H_
#define MEDUTILS_H_

/* Including definitions of the standard int types is necesssary for Windows,
* and does no harm on other platforms.
*/
#include <stdint.h>

/* Define a bool type because there isn't one built in ANSI C */
typedef uint8_t bool;
#define true 1
Expand Down
36 changes: 26 additions & 10 deletions astroscrappy/utils/setup_package.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
from distutils.core import Extension
from distutils import log

from astropy_helpers import setup_helpers

UTIL_DIR = os.path.relpath(os.path.dirname(__file__))

CODELINES = """
Expand All @@ -19,12 +21,22 @@


def check_openmp():
s = subprocess.Popen([sys.executable], stdin=subprocess.PIPE,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
stdout, stderr = s.communicate(CODELINES.encode('utf-8'))
s.wait()
return bool(s.returncode), (stdout, stderr)
if setup_helpers.get_compiler_option() == 'msvc':
# The free version of the Microsoft compilers supports
# OpenMP in MSVC 2008 (python 2.7) and MSVC 2015 (python 3.5+),
# but not MSVC 2010 (python 3.4 and lower).
major, minor = sys.version_info[:2]
has_openmp = not (major == 3 and minor < 5)
# Empty return tuple is to match the alternative check, below.
return has_openmp, ("", "")
else:
# Unix-y compiler, use this check.
s = subprocess.Popen([sys.executable], stdin=subprocess.PIPE,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
stdout, stderr = s.communicate(CODELINES.encode('utf-8'))
s.wait()
return bool(s.returncode), (stdout, stderr)


def get_extensions():
Expand Down Expand Up @@ -56,10 +68,14 @@ def get_extensions():

has_openmp, outputs = check_openmp()
if has_openmp:
ext_med.extra_compile_args.append('-fopenmp')
ext_im.extra_compile_args.append('-fopenmp')
ext_med.extra_link_args = ['-g', '-fopenmp']
ext_im.extra_link_args = ['-g', '-fopenmp']
if setup_helpers.get_compiler_option() == 'msvc':
ext_med.extra_compile_args.append('-openmp')
ext_im.extra_compile_args.append('-openmp')
else:
ext_med.extra_compile_args.append('-fopenmp')
ext_im.extra_compile_args.append('-fopenmp')
ext_med.extra_link_args = ['-g', '-fopenmp']
ext_im.extra_link_args = ['-g', '-fopenmp']
else:
log.warn('OpenMP was not found. '
'astroscrappy will be compiled without OpenMP. '
Expand Down

0 comments on commit 10672f2

Please sign in to comment.