Skip to content

Commit

Permalink
Upgrade V8 to the 7.8 release branch
Browse files Browse the repository at this point in the history
The build system of V8 has significantly changed. It now uses LLVM on
all platforms and a dedicated Debian (sid) based sysroot on Linux.  In
order to simplify the extension build process, it is now part of the V8
build system and uses GN. It comes with several enhancements like being
able to use C++14 in the extension. It also add support for Windows.
  • Loading branch information
nizox committed Oct 15, 2019
1 parent ec8f7de commit e0a541c
Show file tree
Hide file tree
Showing 11 changed files with 418 additions and 294 deletions.
14 changes: 12 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,17 @@ docs/_build/
target/

# V8 vendor
py_mini_racer/extension/v8/
vendor/
py_mini_racer/extension/.cipd
py_mini_racer/extension/.gclient*
py_mini_racer/extension/v8
py_mini_racer/extension/out
py_mini_racer/extension/depot_tools
py_mini_racer/extension/build
py_mini_racer/extension/build_overrides
py_mini_racer/extension/buildtools
py_mini_racer/extension/old_v8_test_wasm-js.git/
py_mini_racer/extension/testing
py_mini_racer/extension/third_party
py_mini_racer/extension/tools

*.iml
1 change: 1 addition & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ include CONTRIBUTING.rst
include HISTORY.rst
include LICENSE
include README.rst
include py_mini_racer/extension/*.gn

recursive-include tests *
recursive-include requirements *
Expand Down
18 changes: 5 additions & 13 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ The PyMiniRacer binary builds have been tested on x86_64 with:
* Debian >= 7
* CentOS >= 6
* The latest Alpine Linux Docker image
* Windows 10

You need pip >= 8.1 to install the wheels - you can check and upgrade yours in this way:

Expand All @@ -131,8 +132,7 @@ If you have a up-to-date pip and it doesn't use a wheel, you might have an envir
Installation
------------

We built Python wheels (prebuilt binaries) for OSX 64 bits and Linux 64 bits -
most recent distributions. You need pip >= 1.4 and setuptools >= 0.8.
We built Python wheels (prebuilt binaries) for OSX 64 bits, Linux 64 bits and Windows 64 bits. You need pip >= 1.4 and setuptools >= 0.8.

.. code:: bash
Expand All @@ -156,25 +156,17 @@ by the V8 build system.
$ python --version
Python 2.7.16
You can then build V8 with the command:

.. code:: bash
$ python setup.py build_v8
You can also build the ctype extension:
You can build the extension with the following command:

.. code:: bash
$ python setup.py build_ext
Which automatically builds v8.

You can generate a wheel for whatever Python version with the command:

.. code:: bash
$ python setup.py build_v8 # (for Python 2 and Python 3)
$ python setup.py build_ext # (for Python 2 and Python 3)
$ python setup.py bdist_wheel # (for Python 2 only)
$ python3 setup.py bdist_wheel # (for Python 3 only)
Expand All @@ -198,7 +190,7 @@ If you're having build issues, you may either have to run the build a second tim
Tests
-----

If you want to run the tests, you need to build V8 first, then launch:
If you want to run the tests, you need to build the extension first, then launch:

.. code:: bash
Expand Down
17 changes: 11 additions & 6 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,20 @@ jobs:
versionSpec: '3.6'
architecture: x64
- checkout: self
- bash: python3 setup.py sdist --dist-dir wheelhouse
- bash: python setup.py sdist --dist-dir wheelhouse
- template: helpers/release.yml
- job: mac
pool: {vmImage: 'macOS-10.13'}
steps:
- bash: sudo xcode-select -s /Applications/Xcode_8.3.3.app/Contents/Developer
- task: UsePythonVersion@0
inputs:
versionSpec: '3.6'
architecture: x64
- checkout: self
- template: helpers/release.yml
- job: windows
pool: {vmImage: 'vs2017-win2016'}
steps:
- script: git config --global core.symlinks true
- checkout: self
- powershell: |
Remove-Item C:\ProgramData\Chocolatey\bin\python2.7.exe -force
Remove-Item C:\ProgramData\Chocolatey\bin\python2.exe -force
displayName: Remove extraneous Python Interpreters
- template: helpers/release.yml
31 changes: 13 additions & 18 deletions helpers/release.yml
Original file line number Diff line number Diff line change
@@ -1,27 +1,22 @@
steps:
- task: UsePythonVersion@0
inputs:
versionSpec: '2.7'
architecture: x64
- task: CacheBeta@0
inputs:
key: v8_libraries | $(Agent.OS) | py_mini_racer/extension/v8_build.py
path: py_mini_racer/extension/v8/v8/out.gn/x64.release/obj
- task: CacheBeta@0
inputs:
key: v8_includes | $(Agent.OS) | py_mini_racer/extension/v8_build.py
path: py_mini_racer/extension/v8/v8/include
- bash: python setup.py build_v8
- bash: |
- {task: UsePythonVersion@0, inputs: {versionSpec: '2.7', architecture: x64}}
- bash: echo "##vso[task.prependpath]$(Build.SourcesDirectory)\\py_mini_racer\\extension\\depot_tools\\"
- script: python setup.py build_ext
displayName: Build the extension
- {task: UsePythonVersion@0, inputs: {versionSpec: '3.6', architecture: x64}}
- script: |
pip install cibuildwheel==0.12.0
cibuildwheel --output-dir wheelhouse .
env:
CIBW_SKIP: "*-manylinux1_i686"
CIBW_BEFORE_BUILD: "git clean -ffdx -e py_mini_racer/extension/out py_mini_racer/extension || true"
CIBW_SKIP: "*-manylinux1_i686 *-win32"
CIBW_TEST_REQUIRES: mock pytest pytest-azurepipelines
CIBW_TEST_COMMAND: pytest {project}/tests
- bash: |
pip3 install auditwheel
python3 helpers/wheel_pymalloc.py wheelhouse
displayName: Build the Wheelhouse
- script: |
pip install auditwheel
python helpers/wheel_pymalloc.py wheelhouse
displayName: Patch the Wheelhouse
- task: PublishBuildArtifacts@1
inputs: {pathtoPublish: "wheelhouse"}
- task: S3Upload@1
Expand Down
1 change: 1 addition & 0 deletions py_mini_racer/extension/.gn
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
buildconfig = "//build/config/BUILDCONFIG.gn"
45 changes: 45 additions & 0 deletions py_mini_racer/extension/BUILD.gn
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import("//v8/gni/v8.gni")

config("py_mini_racer_config") {
include_dirs = [ "//v8" ]
configs = [ "//v8:external_config" ]
cflags = []
}

v8_source_set("v8") {
deps = [
"//v8:v8",
"//v8:v8_libbase",
"//v8:v8_libplatform",
"//v8:v8_libsampler",
]
configs = [ ":py_mini_racer_config" ]
}

v8_source_set("py_mini_racer") {
sources = [
"mini_racer_extension.cc",
]
deps = [
":v8",
]
configs = [ ":py_mini_racer_config" ]
}

v8_static_library("py_mini_racer_static_lib") {
output_name = "mini_racer"
deps = [
":py_mini_racer",
"//build/config:shared_library_deps",
]
configs = [ ":py_mini_racer_config" ]
}

shared_library("py_mini_racer_shared_lib") {
output_name = "mini_racer"
deps = [
":py_mini_racer",
"//build/config:shared_library_deps",
]
configs += [ ":py_mini_racer_config" ]
}
Loading

0 comments on commit e0a541c

Please sign in to comment.