Skip to content

Commit

Permalink
Merge pull request #143 from RemiLehe/robust_install
Browse files Browse the repository at this point in the history
Close #142: pip install fails
  • Loading branch information
RemiLehe authored Feb 17, 2017
2 parents 4437085 + 8ae74fd commit b7e84c0
Show file tree
Hide file tree
Showing 7 changed files with 32 additions and 17 deletions.
7 changes: 2 additions & 5 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,10 @@ matrix:
include:
- os: linux
python: "2.7"
- os: linux
python: "3.4"
- os: linux
python: "3.5"
- os: osx
language: cpp
env: TRAVIS_PYTHON_VERSION=2.7
- os: linux
python: "3.6"

before_install:
# Setup anaconda
Expand Down
3 changes: 2 additions & 1 deletion MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
include README.md
include requirements.txt
include opmd_viewer/openpmd_timeseries/cython_function.pyx
include opmd_viewer/notebook_starter/openPMD_notebook
include opmd_viewer/notebook_starter/Template_notebook.ipynb
include opmd_viewer/notebook_starter/Template_notebook.ipynb
2 changes: 1 addition & 1 deletion conda_recipe/meta.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{% set version = "0.5.1" %}
{% set version = "0.5.2" %}

package:
name: openpmd_viewer
Expand Down
2 changes: 1 addition & 1 deletion opmd_viewer/__version__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "0.5.1"
__version__ = "0.5.2"
10 changes: 10 additions & 0 deletions opmd_viewer/openpmd_timeseries/particle_tracker.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
Authors: Remi Lehe
License: 3-Clause-BSD-LBNL
"""
import warnings
import numpy as np
from .data_reader.particle_reader import read_species_data
try:
Expand Down Expand Up @@ -103,6 +104,15 @@ def __init__(self, ts, species=None, t=None,
self.species = species
self.preserve_particle_index = preserve_particle_index

# Print a warning if the Cython function is unavailable
if not cython_function_available:
warnings.warn(
"\nUnable to compile particle tracking with Cython. \n"
"The ParticleTracker will still work, but will be slow. \n"
"For faster particle tracking: \n"
" - make sure that Cython is installed \n"
" - then reinstall openPMD-viewer")

def extract_tracked_particles( self, file_handle, data_list,
species, extensions ):
"""
Expand Down
1 change: 0 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
numpy
scipy
Cython
matplotlib
h5py
24 changes: 16 additions & 8 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import sys
from setuptools import setup, find_packages
from setuptools.command.test import test as TestCommand
from Cython.Build import cythonize
import numpy

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

# Try to compile the Cython function
try:
import numpy
include_dirs = [numpy.get_include()]
from Cython.Build import cythonize
ext_modules = cythonize(
"opmd_viewer/openpmd_timeseries/cython_function.pyx")
except ImportError:
# If the compilation fails, still install the package in a robust way
include_dirs = []
ext_modules = []

# Main setup command
setup(name='openPMD-viewer',
version=__version__,
Expand All @@ -42,10 +52,8 @@ def run_tests(self):
package_data={'opmd_viewer': ['notebook_starter/*.ipynb']},
scripts=['opmd_viewer/notebook_starter/openPMD_notebook'],
tests_require=['pytest', 'jupyter'],
setup_requires=['Cython', 'numpy'],
ext_modules = cythonize(
"opmd_viewer/openpmd_timeseries/cython_function.pyx"),
include_dirs=[numpy.get_include()],
ext_modules=ext_modules,
include_dirs=include_dirs,
install_requires=install_requires,
cmdclass={'test': PyTest},
platforms='any',
Expand All @@ -60,6 +68,6 @@ def run_tests(self):
'Topic :: Scientific/Engineering :: Visualization',
'Topic :: Database :: Front-Ends',
'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3.4',
'Programming Language :: Python :: 3.5'],
'Programming Language :: Python :: 3.5',
'Programming Language :: Python :: 3.6'],
)

0 comments on commit b7e84c0

Please sign in to comment.