From 970e350ba741500bfb41effbf1f6b86be951b066 Mon Sep 17 00:00:00 2001 From: Ben Thompson Date: Mon, 6 Jun 2016 19:44:59 -0400 Subject: [PATCH] Added tox script. --- .gitignore | 1 + MANIFEST.in | 3 +++ cppimport/checksum.py | 11 ++++++++++- setup.py | 2 +- tox.ini | 10 ++++++++++ 5 files changed, 25 insertions(+), 2 deletions(-) create mode 100644 MANIFEST.in create mode 100644 tox.ini diff --git a/.gitignore b/.gitignore index 4afb3fe..e1484c6 100644 --- a/.gitignore +++ b/.gitignore @@ -9,3 +9,4 @@ build cppimport.egg-info dist .cache +.tox diff --git a/MANIFEST.in b/MANIFEST.in new file mode 100644 index 0000000..6ded34c --- /dev/null +++ b/MANIFEST.in @@ -0,0 +1,3 @@ +include tox.ini +include README.md +recursive-include tests * diff --git a/cppimport/checksum.py b/cppimport/checksum.py index 2783d19..bfeee2e 100644 --- a/cppimport/checksum.py +++ b/cppimport/checksum.py @@ -1,8 +1,10 @@ import os import pickle import hashlib +import traceback import cppimport.find +import cppimport.config # I use .${filename}.cppimporthash as the checksum file for each module. def get_checksum_filepath(filepath): @@ -24,7 +26,14 @@ def is_checksum_current(module_data): if not os.path.exists(checksum_filepath): return False - deps, old_checksum = pickle.load(open(checksum_filepath, 'rb')) + try: + deps, old_checksum = pickle.load(open(checksum_filepath, 'rb')) + except ValueError as e: + cppimport.config.quiet_print( + "Failed to load checksum due to exception" + traceback.format_exc() + ) + return False + cur_checksum = calc_cur_checksum(deps, module_data) if old_checksum != cur_checksum: return False diff --git a/setup.py b/setup.py index 1432c18..1141fde 100644 --- a/setup.py +++ b/setup.py @@ -10,7 +10,7 @@ packages = ['cppimport'], install_requires = [ - 'mako', 'pybind11', 'pytest' + 'mako', 'pybind11' ], zip_safe = False, entry_points = { diff --git a/tox.ini b/tox.ini new file mode 100644 index 0000000..3e4b100 --- /dev/null +++ b/tox.ini @@ -0,0 +1,10 @@ +[tox] +envlist = py27, py35 + +[testenv] +deps = + pytest + mako + pybind11 +commands = + py.test