Skip to content

Builds PyV8 binary artifact for use on Python3

Notifications You must be signed in to change notification settings

manhg/pyv8-python3

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 

Repository files navigation

pyv8 builder

This docker image has been created to simplify the process of building a pyv8 binary for Python3 and make it repeatable.

Usage

docker build -t pyv8 .
docker run -it --rm -v `pwd`/bin:/pyv8 pyv8

Resources

This image has been cobbled together with the help of many wonderful documents on the Internet:

The diff file from the buffer/thug repository fixes a bug in PyV8 that leads to a segmentation fault when attempting to leave a JSLocker in Python3.

Notes

There are variables at the top of the Dockerfile for the Python and Boost versions to download and install. Adjust them freely as newer versions come out.

Source modifications

The Dockerfile makes several modifications to the source code before compiling and building. These are probably the lines that will need the most modification as time goes on, at least if anything ever changes in the pyv8 source. Therefore, the reasoning behind each modification is documented below

Build PyV8 with BOOST_STATIC_LINK = True

This performs the PyV8 build with static linking so that the application container doesn't need the boost libraries to use PyV8

Link to python3 boost library

This is because PyV8 is setup to build for and link to python2.7

Add octal identifier for Python3 compatibility

Same as above. "0755" is not a valid octal literal in Python3.

Add indentation for Python3 compatibility

This is a block of code that imports from a Python2 only library. It gets tabbed in so that it joins a conditional block that only runs if it's being run under Python2.

Add "from ." to "import _PyV8" in line with the way PyV8 gets packaged here

This is not due to any bug, but I find it more useful to make PyV8 as a package that can be dropped into a directory that's in Python's path, and then it can be instantly imported and used. So when using PyV8 as a package, this import method is needed for PyV8 to be able to find its shared object library.

This is also why there's a command in the Dockerfile that does touch __init__.py

Fix bug in PyV8

This one IS due to a bug in PyV8. Without this fix, Python3 runs into a segmentation fault when you leave a JSLocker. Thanks to the buffer/thug repository for this fix!

About

Builds PyV8 binary artifact for use on Python3

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published