diff --git a/.travis.yml b/.travis.yml index 51865977..da1bd015 100644 --- a/.travis.yml +++ b/.travis.yml @@ -26,9 +26,9 @@ jobs: - name: Minimum Stable python: "3.7" env: TRAVIS_RUST_VERSION=1.39.0 - - name: PyPy3.5 7.0 # Tested via anaconda PyPy (since travis's PyPy version is too old) - python: "3.7" - env: FEATURES="pypy" PATH="$PATH:/opt/anaconda/envs/pypy3/bin" + - name: PyPy3.6 + python: "pypy3" + env: FEATURES="pypy" allow_failures: - python: 3.9-dev diff --git a/ci/travis/setup.sh b/ci/travis/setup.sh index c436691a..e9e67810 100755 --- a/ci/travis/setup.sh +++ b/ci/travis/setup.sh @@ -12,28 +12,8 @@ if [[ $RUN_LINT == 1 ]]; then rustup component add rustfmt fi -### Setup PyPy ################################################################ - -if [[ $FEATURES == *"pypy"* ]]; then - wget --quiet https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh && \ - /bin/bash Miniconda3-latest-Linux-x86_64.sh -f -b -p /opt/anaconda && \ - /opt/anaconda/bin/conda install --quiet --yes conda && \ - /opt/anaconda/bin/conda config --system --add channels conda-forge && \ - /opt/anaconda/bin/conda init bash && \ - /opt/anaconda/bin/conda create -n pypy3 pypy3.5 -y && \ - /opt/anaconda/envs/pypy3/bin/pypy3 -m ensurepip && \ - /opt/anaconda/envs/pypy3/bin/pypy3 -m pip install setuptools-rust pytest pytest-benchmark tox -fi - ### Setup python linker flags ################################################## - -if [[ $FEATURES == *"pypy"* ]]; then - PYTHON_BINARY="pypy3" -else - PYTHON_BINARY="python" -fi - -PYTHON_LIB=$($PYTHON_BINARY -c "import sysconfig; print(sysconfig.get_config_var('LIBDIR'))") +PYTHON_LIB=$(python -c "import sysconfig; print(sysconfig.get_config_var('LIBDIR'))") export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:$PYTHON_LIB:$HOME/rust/lib" diff --git a/ci/travis/test.sh b/ci/travis/test.sh index eb85e926..b10e55c4 100755 --- a/ci/travis/test.sh +++ b/ci/travis/test.sh @@ -7,7 +7,7 @@ if ! [[ $FEATURES == *"pypy"* ]]; then ( cd pyo3-derive-backend; cargo test ) else # check that pypy at least builds - PYTHON_SYS_EXECUTABLE="/opt/anaconda/envs/pypy3/bin/pypy3" cargo build; + cargo build; fi if [[ $RUN_LINT == 1 ]]; then diff --git a/examples/rustapi_module/src/datetime.rs b/examples/rustapi_module/src/datetime.rs index 14f4a071..3181ae79 100644 --- a/examples/rustapi_module/src/datetime.rs +++ b/examples/rustapi_module/src/datetime.rs @@ -77,7 +77,7 @@ fn get_time_tuple<'p>(py: Python<'p>, dt: &PyTime) -> &'p PyTuple { ) } -#[cfg(Py_3_6)] +#[cfg(all(Py_3_6, not(PyPy)))] #[pyfunction] fn get_time_tuple_fold<'p>(py: Python<'p>, dt: &PyTime) -> &'p PyTuple { PyTuple::new( @@ -156,7 +156,7 @@ fn get_datetime_tuple<'p>(py: Python<'p>, dt: &PyDateTime) -> &'p PyTuple { ) } -#[cfg(Py_3_6)] +#[cfg(all(Py_3_6, not(PyPy)))] #[pyfunction] fn get_datetime_tuple_fold<'p>(py: Python<'p>, dt: &PyDateTime) -> &'p PyTuple { PyTuple::new( @@ -230,8 +230,11 @@ fn datetime(_py: Python<'_>, m: &PyModule) -> PyResult<()> { #[cfg(Py_3_6)] { m.add_wrapped(wrap_pyfunction!(time_with_fold))?; - m.add_wrapped(wrap_pyfunction!(get_time_tuple_fold))?; - m.add_wrapped(wrap_pyfunction!(get_datetime_tuple_fold))?; + #[cfg(not(PyPy))] + { + m.add_wrapped(wrap_pyfunction!(get_time_tuple_fold))?; + m.add_wrapped(wrap_pyfunction!(get_datetime_tuple_fold))?; + } } m.add_wrapped(wrap_pyfunction!(issue_219))?; diff --git a/examples/rustapi_module/tests/test_datetime.py b/examples/rustapi_module/tests/test_datetime.py index 2f6e4019..fa9cb89a 100644 --- a/examples/rustapi_module/tests/test_datetime.py +++ b/examples/rustapi_module/tests/test_datetime.py @@ -69,7 +69,7 @@ else: MAX_DATETIME = pdt.datetime(9999, 12, 31, 18, 59, 59) PYPY = platform.python_implementation() == "PyPy" -HAS_FOLD = getattr(pdt.datetime, "fold", False) +HAS_FOLD = getattr(pdt.datetime, "fold", False) and not PYPY xfail_date_bounds = pytest.mark.xfail( diff --git a/examples/rustapi_module/tox.ini b/examples/rustapi_module/tox.ini index a6e31299..fa74ab8e 100644 --- a/examples/rustapi_module/tox.ini +++ b/examples/rustapi_module/tox.ini @@ -3,7 +3,7 @@ envlist = py35, py36, py37, py38, - pypy35 + pypy36 minversion = 3.4.0 skip_missing_interpreters = true isolated_build = true diff --git a/src/ffi/dictobject.rs b/src/ffi/dictobject.rs index 995e61f4..b591a5a6 100644 --- a/src/ffi/dictobject.rs +++ b/src/ffi/dictobject.rs @@ -1,5 +1,5 @@ use crate::ffi::object::*; -use crate::ffi::pyport::{Py_hash_t, Py_ssize_t}; +use crate::ffi::pyport::Py_ssize_t; use std::os::raw::{c_char, c_int}; #[cfg_attr(windows, link(name = "pythonXY"))] @@ -81,7 +81,7 @@ extern "C" { mp: *mut PyObject, key: *mut PyObject, item: *mut PyObject, - hash: Py_hash_t, + hash: crate::ffi::Py_hash_t, ) -> c_int; #[cfg_attr(PyPy, link_name = "PyPyDict_DelItem")] pub fn PyDict_DelItem(mp: *mut PyObject, key: *mut PyObject) -> c_int; @@ -100,7 +100,7 @@ extern "C" { pos: *mut Py_ssize_t, key: *mut *mut PyObject, value: *mut *mut PyObject, - hash: *mut Py_hash_t, + hash: *mut crate::ffi::Py_hash_t, ) -> c_int; #[cfg_attr(PyPy, link_name = "PyPyDict_Keys")] pub fn PyDict_Keys(mp: *mut PyObject) -> *mut PyObject;