#67 Declined
Repository
Deleted repository
Branch
default (7eb44aa590a2)
Repository
pypy/pypy pypy
Branch
default

added implementation of Py_Initialize,Py_Finalize,Py_SetPythonHome,Py_SetProgramName as cpyext

Author
  1. Roberto De Ioris avatarRoberto De Ioris
Reviewers
Description

This commit add support for a series o cpython-compatible api functions required for embedding libpypy in c apps. They are all written in rpython (as cpyext) except for Py_Initialize requiring a call to RPython_StartupCode. Tested with uWSGI tip.

Comments (7)

  1. Amaury Forgeot d'Arc

    Very nice! Especially for the RPython implementation of PyPy_Initialize().

    Do the cpyext unit tests still pass? I suspect that RPython_StartupCode is not defined in the C stub library we compile for testing cpyext with an interpreted pypy.

    1. Roberto De Ioris author

      would be great to reuse that code, but i think both will require refactoring to support PYTHONHOME env var and custom sys.prefix (required by Py_SetPythonHome)

      1. Amaury Forgeot d'Arc

        I'm OK to leave it simple to begin with; but pypy.file will hardcode the path of the pypy source tree, at translation time. Is sys.path correctly set if one donwloads the nightly builds and unpack it anywhere? Should the code use sys.executable somehow?

        1. Roberto De Ioris author

          honestly it is not clear to me how to make 'srcdir' independent from pypy.file Apps embeding python normally set sys.executable to their binary path, so following that value could lead to problems. Maybe we could take the absolute path of libpypy-c with dladdr() trick, but this is glibc specific.

          1. Amaury Forgeot d'Arc

            You are right of course. I did embed a Python interpreter several times, but I forgot that PythonHome and Path should almost always be overridden. Since pypy does not use sys.prefix, defaulting to the original source path is the right thing to do.

Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.