Skip to content

Commit

Permalink
allow pycbc to be installed in python3 (#2229)
Browse files Browse the repository at this point in the history
* allow pycbc to be installed in python3

* update

* fix typo, use six for PY3 checking

* ws
  • Loading branch information
ahnitz committed Jul 16, 2018
1 parent 70d54c4 commit f3c1e7d
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 10 deletions.
3 changes: 2 additions & 1 deletion pycbc/scheme.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,8 @@ def scheming_function(fn, *args, **kwds):
try:
backend = __import__(prefix + scheme_prefix[sch], fromlist=[fn.__name__])
schemed_fn = getattr(backend, fn.__name__)
except (ImportError, AttributeError):
except (ImportError, AttributeError) as e:
print(e)
continue

if mgr.state not in _import_cache:
Expand Down
7 changes: 4 additions & 3 deletions pycbc/waveform/waveform.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,10 @@
from pycbc.waveform import parameters
from pycbc.filter import interpolate_complex_frequency, resample_to_delta_t
import pycbc
from spa_tmplt import spa_tmplt, spa_tmplt_norm, spa_tmplt_end, \
from .spa_tmplt import spa_tmplt, spa_tmplt_norm, spa_tmplt_end, \
spa_tmplt_precondition, spa_amplitude_factor, \
spa_length_in_time
from six.moves import range as xrange

class NoWaveformError(Exception):
"""This should be raised if generating a waveform would just result in all
Expand Down Expand Up @@ -263,8 +264,8 @@ def _lalsim_sgburst_waveform(**p):
_cuda_fd_approximants["IMRPhenomC"] = imrphenomc_tmplt
_cuda_fd_approximants["SpinTaylorF2"] = cuda_spintaylorf2

cuda_td = dict(_lalsim_td_approximants.items() + _cuda_td_approximants.items())
cuda_fd = dict(_lalsim_fd_approximants.items() + _cuda_fd_approximants.items())
cuda_td = dict(list(_lalsim_td_approximants.items()) + list(_cuda_td_approximants.items()))
cuda_fd = dict(list(_lalsim_fd_approximants.items()) + list(_cuda_fd_approximants.items()))


# List the various available approximants ####################################
Expand Down
15 changes: 11 additions & 4 deletions pycbc/weave.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,11 @@
import logging
import shutil, atexit, signal
import fcntl
import weave.inline_tools as inline_tools
from six import PY3

_compile_function = inline_tools.compile_function
if not PY3:
import weave.inline_tools as inline_tools
_compile_function = inline_tools.compile_function

## Blatently taken from weave to implement a crude file locking scheme
def pycbc_compile_function(code,arg_names,local_dict,global_dict,
Expand Down Expand Up @@ -61,8 +63,13 @@ def pycbc_compile_function(code,arg_names,local_dict,global_dict,

return func

inline_tools.compile_function = pycbc_compile_function
from weave import inline
if not PY3:
inline_tools.compile_function = pycbc_compile_function
from weave import inline
else:
def inline(*args, **kwds):
raise RuntimeError("Oh no! You tried to use capabilities"
" we haven't ported to python3 yet")

def insert_weave_option_group(parser):
"""
Expand Down
7 changes: 5 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,15 @@
from setuptools import Extension, setup, Command
from setuptools.command.build_ext import build_ext as _build_ext

PY3 = sys.version_info[0] == 3

requires = []
setup_requires = ['numpy>=1.13.0',]
install_requires = setup_requires + ['Mako>=1.0.1',
'argparse>=1.3.0',
'cython',
'decorator>=3.4.2',
'scipy>=0.16.0',
'weave>=0.16.0',
'unittest2',
'matplotlib>=1.5.1',
'pillow',
Expand All @@ -64,6 +65,9 @@
'six>=1.10.0',
]

if not PY3:
install_requires += ['weave>=0.16.0']

def find_package_data(dirname):
def find_paths(dirname):
items = []
Expand Down Expand Up @@ -522,4 +526,3 @@ def run(self):
'License :: OSI Approved :: GNU General Public License v3 (GPLv3)',
],
)

0 comments on commit f3c1e7d

Please sign in to comment.