diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..b989be6 --- /dev/null +++ b/.gitignore @@ -0,0 +1,105 @@ +# Byte-compiled / optimized / DLL files +__pycache__/ +*.py[cod] +*$py.class + +# C extensions +*.so + +# Distribution / packaging +.Python +build/ +develop-eggs/ +dist/ +downloads/ +eggs/ +.eggs/ +lib/ +lib64/ +parts/ +sdist/ +var/ +wheels/ +*.egg-info/ +.installed.cfg +*.egg +MANIFEST + +# PyInstaller +# Usually these files are written by a python script from a template +# before PyInstaller builds the exe, so as to inject date/other infos into it. +*.manifest +*.spec + +# Installer logs +pip-log.txt +pip-delete-this-directory.txt + +# Unit test / coverage reports +htmlcov/ +.tox/ +.coverage +.coverage.* +.cache +nosetests.xml +coverage.xml +*.cover +.hypothesis/ +.pytest_cache/ + +# Translations +*.mo +*.pot + +# Django stuff: +*.log +.static_storage/ +.media/ +local_settings.py + +# Flask stuff: +instance/ +.webassets-cache + +# Scrapy stuff: +.scrapy + +# Sphinx documentation +docs/_build/ + +# PyBuilder +target/ + +# Jupyter Notebook +.ipynb_checkpoints + +# pyenv +.python-version + +# celery beat schedule file +celerybeat-schedule + +# SageMath parsed files +*.sage.py + +# Environments +.env +.venv +env/ +venv/ +ENV/ +env.bak/ +venv.bak/ + +# Spyder project settings +.spyderproject +.spyproject + +# Rope project settings +.ropeproject + +# mkdocs documentation +/site + +# mypy +.mypy_cache/ diff --git a/.travis.yml b/.travis.yml index aae271f..6e7ed39 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,26 +1,42 @@ -language: python -python: - # We don't actually use the Travis Python, but this keeps it organized. - - "3.5" - - "3.6" +language: generic + +matrix: + include: + - os: linux + python: 3.5 + env: + - PYTHON_VERSION=3.5 + - MINICONDA_URL=https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh + - os: linux + python: 3.6 + env: + - PYTHON_VERSION=3.6 + - MINICONDA_URL=https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh + - os: osx + python: 3.5 + env: + - PYTHON_VERSION=3.5 + - MINICONDA_URL=https://repo.continuum.io/miniconda/Miniconda3-latest-MacOSX-x86_64.sh + - DYLD_LIBRARY_PATH=$HOME/miniconda/envs/pz/lib/python3.5/site-packages/protozfitsreader + - os: osx + python: 3.6 + env: + - PYTHON_VERSION=3.6 + - MINICONDA_URL=https://repo.continuum.io/miniconda/Miniconda3-latest-MacOSX-x86_64.sh + - DYLD_LIBRARY_PATH=$HOME/miniconda/envs/pz/lib/python3.6/site-packages/protozfitsreader + install: - - sudo apt-get update - - wget https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh -O miniconda.sh + - wget $MINICONDA_URL -O miniconda.sh - bash miniconda.sh -b -p $HOME/miniconda - export PATH="$HOME/miniconda/bin:$PATH" - hash -r - conda config --set always_yes yes --set changeps1 no - conda update -q conda - conda info -a - - conda create -q -n pz python=$TRAVIS_PYTHON_VERSION pip numpy protobuf pytest + - conda create -q -n pz python=$PYTHON_VERSION pip numpy protobuf # pytest - source activate pz - - pip install . + - pip install -r requirements.txt + - pip install pytest script: - pytest -vv - - echo "trying to show, that deinstall works" - - cd /home/travis - - find . | grep "rawzfitsreader.cpython-35m-x86_64-linux-gnu.so" - - pip uninstall protozfitsreader --yes - - find . | grep "rawzfitsreader.cpython-35m-x86_64-linux-gnu.so" - diff --git a/README.md b/README.md index a38ce34..c29d12f 100644 --- a/README.md +++ b/README.md @@ -2,8 +2,75 @@ ## installation: - conda install numpy protobuf libgcc - pip install https://github.com/cta-sst-1m/protozfitsreader/archive/v0.43.1.tar.gz +We all use [Anaconda](https://www.anaconda.com/) and this package is tested +against Anaconda. You can [download anaconda](https://www.anaconda.com/download) for your system for free. + +You do not have to use a [conda environment](https://conda.io/docs/user-guide/tasks/manage-environments.html) to use this package. It cleanly installs and uninstalls with [pip](https://docs.python.org/3.6/installing/). If you plan to play around with different versions of this package your might want to use environments though. + +### Faster installation? + +If you use Anaconda this is not interesting for you. + +You can just `pip install` this, but it will use `pip` to install all the dependencies. +`pip install ` is sometimes much slower than `conda install `. + +If you use "miniconda" or if you install this in a fresh conda environment, then +numpy and protobuf might not be there, so we recommend to + + conda install numpy protobuf + +for your convenience. + +### Linux (with anaconda) + + pip install https://github.com/cta-sst-1m/protozfitsreader/archive/v0.44.0.tar.gz + +### OSX (with anaconda) + + pip install https://github.com/cta-sst-1m/protozfitsreader/archive/v0.44.0.tar.gz + +To use it you'll have to find your `site-packages` folder, e.g. like this: + + dneise@lair:~$ python -m site + sys.path = [ + '/home/dneise', + '/home/dneise/Downloads/rootfoo/build_root/lib', + '/home/dneise/anaconda3/lib/python36.zip', + '/home/dneise/anaconda3/lib/python3.6', + '/home/dneise/anaconda3/lib/python3.6/lib-dynload', + '/home/dneise/anaconda3/lib/python3.6/site-packages', <----- this one <----- + ] + +And then you'll have to (put it in your .bashrc for example) + + export DYLD_LIBRARY_PATH=$DYLD_LIBRARY_PATH:/home/dneise/anaconda3/lib/python3.6/site-packages + +### To developers: No `pip --editable` + +This package contains pre-build binaries, which (at the moment) are required to be installed +into your "site-packages" folder. +Developers like to install packages they are currently developing like this: + + pip install --editable . + +Because then they can modify code and try it out without constant uninstall/install cycles. +Unfortunately this nice development workcycle is not possible at the moment. + +I personally do: + + git clone https://github.com/cta-sst-1m/protozfitsreader + pip install protozfitsreader + # play around ... modify ... + pip uninstall protozfitsreader --yes && pip install protozfitsreader + # play around ... modify ... + pip uninstall protozfitsreader --yes && pip install protozfitsreader + # and so on + +The uninstall/install takes 1..2sec ... so it is rather ok... not perfect though. + + + +# Where does this come from? The contents of this repo come entirely from: http://www.isdc.unige.ch/~lyard/repo/ diff --git a/protozfitsreader/libACTLCore.dylib b/protozfitsreader/libACTLCore.dylib new file mode 100755 index 0000000..bdb2747 Binary files /dev/null and b/protozfitsreader/libACTLCore.dylib differ diff --git a/protozfitsreader/libZFitsIO.dylib b/protozfitsreader/libZFitsIO.dylib new file mode 100755 index 0000000..e1270b1 Binary files /dev/null and b/protozfitsreader/libZFitsIO.dylib differ diff --git a/protozfitsreader/libprotobuf.13.dylib b/protozfitsreader/libprotobuf.13.dylib new file mode 100755 index 0000000..421af05 Binary files /dev/null and b/protozfitsreader/libprotobuf.13.dylib differ diff --git a/protozfitsreader/libprotobuf.9.dylib b/protozfitsreader/libprotobuf.9.dylib new file mode 100755 index 0000000..f97b063 Binary files /dev/null and b/protozfitsreader/libprotobuf.9.dylib differ diff --git a/protozfitsreader/libzmq.4.dylib b/protozfitsreader/libzmq.4.dylib new file mode 100755 index 0000000..9b3a6f4 Binary files /dev/null and b/protozfitsreader/libzmq.4.dylib differ diff --git a/protozfitsreader/rawzfitsreader.cpython-35m-darwin.so b/protozfitsreader/rawzfitsreader.cpython-35m-darwin.so new file mode 100755 index 0000000..9944d1d Binary files /dev/null and b/protozfitsreader/rawzfitsreader.cpython-35m-darwin.so differ diff --git a/protozfitsreader/rawzfitsreader.cpython-35m-x86_64-linux-gnu.so b/protozfitsreader/rawzfitsreader.cpython-35m-x86_64-linux-gnu.so index d28c6e3..2640bb5 100755 Binary files a/protozfitsreader/rawzfitsreader.cpython-35m-x86_64-linux-gnu.so and b/protozfitsreader/rawzfitsreader.cpython-35m-x86_64-linux-gnu.so differ diff --git a/protozfitsreader/rawzfitsreader.cpython-36m-darwin.so b/protozfitsreader/rawzfitsreader.cpython-36m-darwin.so new file mode 100755 index 0000000..90a76ee Binary files /dev/null and b/protozfitsreader/rawzfitsreader.cpython-36m-darwin.so differ diff --git a/protozfitsreader/rawzfitsreader.cpython-36m-x86_64-linux-gnu.so b/protozfitsreader/rawzfitsreader.cpython-36m-x86_64-linux-gnu.so index e50c1ce..aa4d3d2 100755 Binary files a/protozfitsreader/rawzfitsreader.cpython-36m-x86_64-linux-gnu.so and b/protozfitsreader/rawzfitsreader.cpython-36m-x86_64-linux-gnu.so differ diff --git a/protozfitsreader/tests/__pycache__/test_rawzfitsreader.cpython-36-PYTEST.pyc b/protozfitsreader/tests/__pycache__/test_rawzfitsreader.cpython-36-PYTEST.pyc deleted file mode 100644 index 3cf69f1..0000000 Binary files a/protozfitsreader/tests/__pycache__/test_rawzfitsreader.cpython-36-PYTEST.pyc and /dev/null differ diff --git a/protozfitsreader/tests/test_rawzfitsreader.py b/protozfitsreader/tests/test_rawzfitsreader.py index aa1ab15..73c7960 100644 --- a/protozfitsreader/tests/test_rawzfitsreader.py +++ b/protozfitsreader/tests/test_rawzfitsreader.py @@ -240,3 +240,20 @@ def test_trigger_output_patch19(): trigger_output_patch19 = to_numpy(e.trigger_output_patch19) assert trigger_output_patch19.shape == (2700, ) assert trigger_output_patch19.dtype == np.uint8 + + +def test_no_crash_when_iterating_too_far(): + from protozfitsreader import rawzfitsreader + from protozfitsreader import L0_pb2 + + rawzfitsreader.open(example_file_path + ':Events') + for i in range(rawzfitsreader.getNumRows()): + event = L0_pb2.CameraEvent() + event.ParseFromString(rawzfitsreader.readEvent()) + + # At this point we iterated through the entire file. + # In version 0.43 we got a crash (seg fault or so) when iterating too + # far. This test should ensure this behaviour is fixed in 0.44 + + with pytest.raises(EOFError): + rawzfitsreader.readEvent() diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..4274df3 --- /dev/null +++ b/requirements.txt @@ -0,0 +1,3 @@ +--index-url https://pypi.python.org/simple/ + +. diff --git a/setup.cfg b/setup.cfg new file mode 100644 index 0000000..c0b054a --- /dev/null +++ b/setup.cfg @@ -0,0 +1,5 @@ +[aliases] +test=pytest + +[tool:pytest] +addopts = --verbose diff --git a/setup.py b/setup.py index 8346e88..effbce2 100644 --- a/setup.py +++ b/setup.py @@ -3,13 +3,18 @@ setup( name='protozfitsreader', packages=['protozfitsreader'], - version='0.43.1', + version='0.44.0', description='Basic python bindings for protobuf zfits reader', author="Etienne Lyard et al.", author_email="etienne.lyard@unige.ch", package_data={ - 'protozfitsreader': ['*.so*'], + 'protozfitsreader': [ + '*.so*', + '*.dylib' + ], '': ['tests/resources/*'], }, install_requires=['numpy', 'protobuf'], + setup_requires=['pytest-runner'], + tests_require=['pytest'], )