Skip to content

Commit

Permalink
Compiler can now be passed into the python setup as well (via the CC=…
Browse files Browse the repository at this point in the history
…/path/to/CC). common.mk will be updated to use this new CC value.
  • Loading branch information
manodeep committed Aug 4, 2016
1 parent 7b1f6c0 commit 4b44511
Show file tree
Hide file tree
Showing 3 changed files with 346 additions and 141 deletions.
47 changes: 47 additions & 0 deletions Corrfunc/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from __future__ import (division, print_function, absolute_import,
unicode_literals)
import sys
import os

__all__ = ["_countpairs", "_countpairs_mocks", "utils"]

Expand Down Expand Up @@ -49,3 +50,49 @@ def write_text_file(filename, contents, encoding="utf-8"):
f.write(contents)


def which(program, mode=os.F_OK | os.X_OK, path=None):
"""
Mimics the Unix utility which.
For python3.3+, shutil.which provides all of the required functionality.
An implementation is provided in case shutil.which does
not exist.
:param program: (required) string
Name of program (can be fully-qualified path as well)
:param mode: (optional) integer flag bits
Permissions to check for in the executable
Default: os.F_OK (file exists) | os.X_OK (executable file)
:param path: (optional) string
A custom path list to check against. Implementation taken from
shutil.py.
Returns:
A fully qualified path to program as resolved by path or
user environment.
Returns None when program can not be resolved.
"""
try:
from shutil import which as shwhich
return shwhich(program, mode, path)
except ImportError:
def is_exe(fpath):
return os.path.isfile(fpath) and os.access(fpath, os.X_OK)

fpath, fname = os.path.split(program)
if fpath:
if is_exe(program):
return program
else:
if path is None:
path = os.environ.get("PATH", os.defpath)
if not path:
return None

path = path.split(os.pathsep)
for pathdir in path:
pathdir = pathdir.strip('"')
exe_file = os.path.join(pathdir, program)
if is_exe(exe_file):
return exe_file

return None
1 change: 0 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ tests:
$(MAKE) -C xi_theory tests
$(MAKE) -C xi_mocks tests


.PHONY: clean celna clena celan xi_theory xi_mocks install distclean realclean

distclean:realclean
Expand Down

0 comments on commit 4b44511

Please sign in to comment.