From 6c0866efb8eecca23bfe4ae5e1ca224b79dafe1b Mon Sep 17 00:00:00 2001 From: "Bryan W. Weber" Date: Fri, 1 Feb 2019 16:46:31 -0500 Subject: [PATCH] Add Cython language_level directive to _cantera.pyx This fixes the warnings generated by recent versions of Cython that the language_level will be changed in the future. By setting this directive, all the code in the .pyx files should be written in Python 3 syntax. This required several changes to the import syntax in the files to fix relative vs. absolute imports --- interfaces/cython/cantera/_cantera.pxd | 1 + interfaces/cython/cantera/_cantera.pyx | 2 +- interfaces/cython/cantera/onedim.pyx | 4 ++-- interfaces/cython/cantera/reactionpath.pyx | 2 +- 4 files changed, 5 insertions(+), 4 deletions(-) diff --git a/interfaces/cython/cantera/_cantera.pxd b/interfaces/cython/cantera/_cantera.pxd index c40e0b39e..6db718c55 100644 --- a/interfaces/cython/cantera/_cantera.pxd +++ b/interfaces/cython/cantera/_cantera.pxd @@ -1,5 +1,6 @@ # This file is part of Cantera. See License.txt in the top-level directory or # at http://www.cantera.org/license.txt for license and copyright information. +# cython: language_level=3 from libcpp.vector cimport vector from libcpp.string cimport string diff --git a/interfaces/cython/cantera/_cantera.pyx b/interfaces/cython/cantera/_cantera.pyx index 0282402c7..98ec9fd7e 100644 --- a/interfaces/cython/cantera/_cantera.pyx +++ b/interfaces/cython/cantera/_cantera.pyx @@ -7,7 +7,7 @@ import math from cython.operator cimport dereference as deref, preincrement as inc -from _cantera cimport * +from ._cantera cimport * include "utils.pyx" include "constants.pyx" diff --git a/interfaces/cython/cantera/onedim.pyx b/interfaces/cython/cantera/onedim.pyx index 1b7ca5093..4a31534c6 100644 --- a/interfaces/cython/cantera/onedim.pyx +++ b/interfaces/cython/cantera/onedim.pyx @@ -1,7 +1,7 @@ # This file is part of Cantera. See License.txt in the top-level directory or # at http://www.cantera.org/license.txt for license and copyright information. -import interrupts +from .interrupts import no_op import warnings # Need a pure-python class to store weakrefs to @@ -589,7 +589,7 @@ cdef class Sim1D: self.sim = new CxxSim1D(D) self.domains = tuple(domains) - self.set_interrupt(interrupts.no_op) + self.set_interrupt(no_op) self._initialized = False self._initial_guess_args = () self._initial_guess_kwargs = {} diff --git a/interfaces/cython/cantera/reactionpath.pyx b/interfaces/cython/cantera/reactionpath.pyx index 613114c0b..0dbe9fe93 100644 --- a/interfaces/cython/cantera/reactionpath.pyx +++ b/interfaces/cython/cantera/reactionpath.pyx @@ -181,7 +181,7 @@ cdef class ReactionPathDiagram: self.diagram, True) self.built = True if verbose: - print self.log + print(self.log) property log: """