Skip to content

Commit

Permalink
Emit build info of ChainerX
Browse files Browse the repository at this point in the history
  • Loading branch information
asi1024 committed Jun 18, 2019
1 parent 26bf587 commit 02e232a
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 8 deletions.
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -8,6 +8,7 @@
build
\#*\#
.\#*
_build_info.py
.coverage
.eggs/
_readthedocs_build
Expand Down
14 changes: 6 additions & 8 deletions chainerx/__init__.py
@@ -1,16 +1,14 @@
import os
import sys
import warnings

from chainerx import _build_info

if sys.version_info[0] < 3:
_available = False

if _build_info.build_chainerx:
from chainerx import _core
_available = True
else:
try:
from chainerx import _core
_available = True
except Exception:
_available = False
_available = False


if _available:
Expand Down
11 changes: 11 additions & 0 deletions chainerx_build_helper.py
Expand Up @@ -12,6 +12,13 @@
from setuptools.command import build_ext


def emit_build_info(build_chainerx):
dirname = os.path.dirname(__file__)
filename = os.path.join(dirname, 'chainerx/_build_info.py')
with open(filename, mode='w') as f:
f.write('build_chainerx = {}\n'.format(build_chainerx))


class CMakeExtension(setuptools.Extension):

def __init__(self, name, build_targets, sourcedir=''):
Expand Down Expand Up @@ -89,6 +96,10 @@ def build_extension(self, ext):


def config_setup_kwargs(setup_kwargs, build_chainerx):

# TODO(imanishi): Call this function with setuptools.
emit_build_info(build_chainerx)

if not build_chainerx:
# `chainerx` package needs to be able to be imported even if ChainerX
# is unavailable.
Expand Down

0 comments on commit 02e232a

Please sign in to comment.