Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Jonas Plewinski
pystencils
Commits
690a0ed8
Commit
690a0ed8
authored
Jul 01, 2019
by
Martin Bauer
Browse files
Fixed Cython deployment issues
parent
eb7e77eb
Changes
4
Expand all
Hide whitespace changes
Inline
Side-by-side
pystencils/boundaries/createindexlist.py
View file @
690a0ed8
...
...
@@ -3,17 +3,25 @@ import itertools
import
warnings
try
:
import
pyximport
pyximport
.
install
(
language_level
=
3
)
# Try to import right away - assume compiled code is available
# compile with: python setup.py build_ext --inplace --use-cython
from
pystencils.boundaries.createindexlistcython
import
create_boundary_neighbor_index_list_2d
,
\
create_boundary_neighbor_index_list_3d
,
create_boundary_cell_index_list_2d
,
create_boundary_cell_index_list_3d
cython_funcs_available
=
True
except
Exception
:
cython_funcs_available
=
False
create_boundary_index_list_2d
=
None
create_boundary_index_list_3d
=
None
except
ImportError
:
try
:
# If not, try development mode and import via pyximport
import
pyximport
pyximport
.
install
(
language_level
=
3
)
cython_funcs_available
=
True
except
ImportError
:
cython_funcs_available
=
False
if
cython_funcs_available
:
from
pystencils.boundaries.createindexlistcython
import
create_boundary_neighbor_index_list_2d
,
\
create_boundary_neighbor_index_list_3d
,
create_boundary_cell_index_list_2d
,
\
create_boundary_cell_index_list_3d
boundary_index_array_coordinate_names
=
[
"x"
,
"y"
,
"z"
]
direction_member_name
=
"dir"
...
...
pystencils/boundaries/createindexlistcython.c
0 → 100644
View file @
690a0ed8
This diff is collapsed.
Click to expand it.
pystencils/boundaries/createindexlistcython.pyx
View file @
690a0ed8
# distutils: language=c
# Workaround for cython bug
# see https://stackoverflow.com/questions/8024805/cython-compiled-c-extension-importerror-dynamic-module-does-not-define-init-fu
WORKAROUND
=
"Something"
...
...
setup.py
View file @
690a0ed8
...
...
@@ -3,11 +3,18 @@ import sys
import
io
from
setuptools
import
setup
,
find_packages
import
distutils
from
distutils.extension
import
Extension
from
contextlib
import
redirect_stdout
from
importlib
import
import_module
sys
.
path
.
insert
(
0
,
os
.
path
.
abspath
(
'doc'
))
from
version_from_git
import
version_number_from_git
if
'--use-cython'
in
sys
.
argv
:
USE_CYTHON
=
True
sys
.
argv
.
remove
(
'--use-cython'
)
else
:
USE_CYTHON
=
False
quick_tests
=
[
'test_datahandling.test_kernel'
,
...
...
@@ -52,6 +59,15 @@ def readme():
return
f
.
read
()
def
cython_extensions
(
*
extensions
):
ext
=
'.pyx'
if
USE_CYTHON
else
'.c'
result
=
[
Extension
(
e
,
[
e
.
replace
(
'.'
,
'/'
)
+
ext
])
for
e
in
extensions
]
if
USE_CYTHON
:
from
Cython.Build
import
cythonize
result
=
cythonize
(
result
,
language_level
=
3
)
return
result
setup
(
name
=
'pystencils'
,
version
=
version_number_from_git
(),
description
=
'Speeding up stencil computations on CPUs and GPUs'
,
...
...
@@ -64,6 +80,7 @@ setup(name='pystencils',
packages
=
[
'pystencils'
]
+
[
'pystencils.'
+
s
for
s
in
find_packages
(
'pystencils'
)],
install_requires
=
[
'sympy>=1.1'
,
'numpy'
,
'appdirs'
,
'joblib'
],
package_data
=
{
'pystencils'
:
[
'include/*.h'
]},
ext_modules
=
cython_extensions
(
"pystencils.boundaries.createindexlistcython"
),
classifiers
=
[
'Development Status :: 4 - Beta'
,
'Framework :: Jupyter'
,
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment