Skip to content

Commit b7e84c0

Browse files
authored
Merge pull request #143 from RemiLehe/robust_install
Close #142: pip install fails
2 parents 4437085 + 8ae74fd commit b7e84c0

File tree

7 files changed

+32
-17
lines changed

7 files changed

+32
-17
lines changed

.travis.yml

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,10 @@ matrix:
88
include:
99
- os: linux
1010
python: "2.7"
11-
- os: linux
12-
python: "3.4"
1311
- os: linux
1412
python: "3.5"
15-
- os: osx
16-
language: cpp
17-
env: TRAVIS_PYTHON_VERSION=2.7
13+
- os: linux
14+
python: "3.6"
1815

1916
before_install:
2017
# Setup anaconda

MANIFEST.in

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
include README.md
22
include requirements.txt
3+
include opmd_viewer/openpmd_timeseries/cython_function.pyx
34
include opmd_viewer/notebook_starter/openPMD_notebook
4-
include opmd_viewer/notebook_starter/Template_notebook.ipynb
5+
include opmd_viewer/notebook_starter/Template_notebook.ipynb

conda_recipe/meta.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
{% set version = "0.5.1" %}
1+
{% set version = "0.5.2" %}
22

33
package:
44
name: openpmd_viewer

opmd_viewer/__version__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = "0.5.1"
1+
__version__ = "0.5.2"

opmd_viewer/openpmd_timeseries/particle_tracker.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
Authors: Remi Lehe
88
License: 3-Clause-BSD-LBNL
99
"""
10+
import warnings
1011
import numpy as np
1112
from .data_reader.particle_reader import read_species_data
1213
try:
@@ -103,6 +104,15 @@ def __init__(self, ts, species=None, t=None,
103104
self.species = species
104105
self.preserve_particle_index = preserve_particle_index
105106

107+
# Print a warning if the Cython function is unavailable
108+
if not cython_function_available:
109+
warnings.warn(
110+
"\nUnable to compile particle tracking with Cython. \n"
111+
"The ParticleTracker will still work, but will be slow. \n"
112+
"For faster particle tracking: \n"
113+
" - make sure that Cython is installed \n"
114+
" - then reinstall openPMD-viewer")
115+
106116
def extract_tracked_particles( self, file_handle, data_list,
107117
species, extensions ):
108118
"""

requirements.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
numpy
22
scipy
3-
Cython
43
matplotlib
54
h5py

setup.py

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
import sys
22
from setuptools import setup, find_packages
33
from setuptools.command.test import test as TestCommand
4-
from Cython.Build import cythonize
5-
import numpy
64

75
# Get the long description
86
# If possible, use pypandoc to convert the README from Markdown
@@ -29,6 +27,18 @@ def run_tests(self):
2927
errcode = pytest.main([])
3028
sys.exit(errcode)
3129

30+
# Try to compile the Cython function
31+
try:
32+
import numpy
33+
include_dirs = [numpy.get_include()]
34+
from Cython.Build import cythonize
35+
ext_modules = cythonize(
36+
"opmd_viewer/openpmd_timeseries/cython_function.pyx")
37+
except ImportError:
38+
# If the compilation fails, still install the package in a robust way
39+
include_dirs = []
40+
ext_modules = []
41+
3242
# Main setup command
3343
setup(name='openPMD-viewer',
3444
version=__version__,
@@ -42,10 +52,8 @@ def run_tests(self):
4252
package_data={'opmd_viewer': ['notebook_starter/*.ipynb']},
4353
scripts=['opmd_viewer/notebook_starter/openPMD_notebook'],
4454
tests_require=['pytest', 'jupyter'],
45-
setup_requires=['Cython', 'numpy'],
46-
ext_modules = cythonize(
47-
"opmd_viewer/openpmd_timeseries/cython_function.pyx"),
48-
include_dirs=[numpy.get_include()],
55+
ext_modules=ext_modules,
56+
include_dirs=include_dirs,
4957
install_requires=install_requires,
5058
cmdclass={'test': PyTest},
5159
platforms='any',
@@ -60,6 +68,6 @@ def run_tests(self):
6068
'Topic :: Scientific/Engineering :: Visualization',
6169
'Topic :: Database :: Front-Ends',
6270
'Programming Language :: Python :: 2.7',
63-
'Programming Language :: Python :: 3.4',
64-
'Programming Language :: Python :: 3.5'],
71+
'Programming Language :: Python :: 3.5',
72+
'Programming Language :: Python :: 3.6'],
6573
)

0 commit comments

Comments
 (0)