Skip to content

Conversation

@lopuhin
Copy link

@lopuhin lopuhin commented Mar 8, 2019

Adapted from #1494 (it would enable pypy support for pytorch).

@mattip
Copy link
Contributor

mattip commented Mar 14, 2019

It seems PyPy lacks an implementation for _Py_fopen_obj (which is part of the Py_LIMITED_API, so I am not sure PyPy will ever implement it) and PyRun_FileEx (which is itself a simplified version of PyRun_FileExFlags, still lacking on PyPy).

@wjakob
Copy link
Member

wjakob commented Jun 10, 2019

Hi @mattip and @lopuhin,

how about putting an include guard and simply disabling the run-from-file features in eval.h (it being a fairly niche feature.)? It could simply throw an exception on that platform.

Best,
Wenzel

@bstaletic
Copy link
Collaborator

bstaletic commented Jun 18, 2019

There are only two errors here:

error: ‘_Py_fopen_obj’ was not declared in this scope
error: ‘PyRun_FileEx’ was not declared in this scope

The first one truly doesn't exist in pypy. The second one exists as PyRun_File and should be caught by #if PY_VERSION_HEX < 0x03000000 && defined(PYPY_VERSION) but it isn't.

Because of the first error, how about detecting if we're compiling for PYPY and then doing something like:

template <eval_mode mode = eval_statements>
object eval_file(str fname, object global = globals(), object local = object()) {
#ifndef pypy_macro
// current implementation
#else 
#error PyPy doesn't support eval_file(), use eval() instead
#endif 
}

An alternative is reading the file into a string in eval_file() and then invoking eval().

@wjakob
Copy link
Member

wjakob commented Jul 15, 2019

Hi -- any news here? It would be cool to support recent versions of PyPy in the CI.

@rwgk
Copy link
Collaborator

rwgk commented Jun 18, 2020

Hi Konstantin, there was a recent upgrade to use PyPy 7.3 on travis, e.g. here is a random recent result (bottom of page): https://travis-ci.org/github/pybind/pybind11/builds/698654908
Is this PR still relevant?

@lopuhin
Copy link
Author

lopuhin commented Jun 18, 2020

@rwgk great, thank you! No it's not relevant any more, any newer PyPy works

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants