Skip to content

Commit

Permalink
Merge pull request #117 from sqreen/feature/plat-names
Browse files Browse the repository at this point in the history
Build universal wheels
  • Loading branch information
nizox authored Sep 21, 2020
2 parents 0d3c6cd + 64cdc43 commit 1cef9d4
Show file tree
Hide file tree
Showing 13 changed files with 319 additions and 294 deletions.
174 changes: 174 additions & 0 deletions .azure/pipelines/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,174 @@
trigger:
- master

stages:
- stage: build
jobs:
- job: linux
displayName: Build on Linux
pool: {vmImage: 'Ubuntu-16.04'}
variables:
plat_name: "manylinux1_x86_64"
steps:
- checkout: self
- {task: UsePythonVersion@0, inputs: {versionSpec: '3.6', architecture: x64}}
- {task: UsePythonVersion@0, inputs: {versionSpec: '2.7', architecture: x64}}
- script: |
python3 -m pip install setuptools wheel
mkdir wheelhouse
python3 helpers/build_package.py wheel wheelhouse
displayName: Build the Wheelhouse
- script: |
python3 -m pip install auditwheel
for i in wheelhouse/*.whl; do auditwheel show $i; done
displayName: Patch the Wheelhouse
- script: |
python -m pip install twine readme_renderer[md]
twine check wheelhouse/*.whl
displayName: Check the wheels
- publish: wheelhouse
- job: mac
displayName: Build on macOS
pool: {vmImage: 'macOS-10.14'}
variables:
plat_name: "macosx_10_9_x86_64"
steps:
- checkout: self
- {task: UsePythonVersion@0, inputs: {versionSpec: '3.6', architecture: x64}}
- {task: UsePythonVersion@0, inputs: {versionSpec: '2.7', architecture: x64}}
- script: |
python3 -m pip install setuptools wheel
mkdir wheelhouse
python3 helpers/build_package.py wheel wheelhouse
displayName: Build the wheelhouse
- publish: wheelhouse
- job: windows
displayName: Build on Windows
pool: {vmImage: 'vs2017-win2016'}
variables:
plat_name: "win_amd64"
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
- {task: UsePythonVersion@0, inputs: {versionSpec: '2.7', architecture: x64}}
- bash: echo "##vso[task.prependpath]$(Build.SourcesDirectory)\\py_mini_racer\\extension\\depot_tools\\"
- script: |
python helpers/v8_build.py --target py_mini_racer_shared_lib
cp py_mini_racer/extension/out/mini_racer.dll py_mini_racer/mini_racer.dll
displayName: Build the extension
- {task: UsePythonVersion@0, inputs: {versionSpec: '3.6', architecture: x64}}
- script: |
python -m pip install wheel
mkdir wheelhouse
python setup.py bdist_wheel --dist-dir wheelhouse --python-tag py2.py3 --plat-name $(plat_name)
displayName: Build the Wheelhouse
- publish: wheelhouse
- job: alpine
displayName: Build on Alpine Linux
pool: {vmImage: 'Ubuntu-16.04'}
container: nicolassqreen/azure-pipelines-container-alpine-python:latest
steps:
- checkout: self
- bash: python helpers/v8_build.py --no-build --no-sysroot
displayName: Download V8 sources
target: host
- bash: |
sudo apk add ninja llvm lld linux-headers
cp -f /usr/local/bin/gn py_mini_racer/extension/v8/buildtools/linux64/gn
rm -f py_mini_racer/extension/depot_tools/ninja
displayName: Prepare Aline Linux build environment
- bash: |
python helpers/v8_build.py --no-update --no-sysroot --target py_mini_racer_shared_lib
cp py_mini_racer/extension/out/libmini_racer.so py_mini_racer/libmini_racer.muslc.so
displayName: Build the extension
- bash: |
/opt/python/cp36-cp36m/bin/python -m pip install wheel
mkdir wheelhouse
/opt/python/cp36-cp36m/bin/python setup.py bdist_wheel --dist-dir wheelhouse --python-tag py2.py3 --plat-name linux_x86_64
displayName: Build the Wheelhouse
- bash: /opt/python/cp36-cp36m/bin/python setup.py sdist --dist-dir wheelhouse
displayName: Build the source package
- publish: wheelhouse

- stage: test
jobs:
- job: linux
displayName: Test on Linux
pool: {vmImage: 'Ubuntu-16.04'}
variables:
plat_name: "manylinux1_x86_64"
steps:
- checkout: self
- {task: UsePythonVersion@0, inputs: {versionSpec: '3.6', architecture: x64}}
- download: current
artifact: build.linux
- script: |
python -m pip install $(Pipeline.Workspace)/build.linux/*.whl
python -m pip install pytest
pytest $(Build.SourcesDirectory)/tests
displayName: Test the Wheel
- job: mac
displayName: Test on macOS
pool: {vmImage: 'macOS-10.14'}
variables:
plat_name: "macosx_10_9_x86_64"
steps:
- checkout: self
- {task: UsePythonVersion@0, inputs: {versionSpec: '3.6', architecture: x64}}
- download: current
artifact: build.mac
- script: |
python -m pip install $(Pipeline.Workspace)/build.mac/*.whl
python -m pip install pytest
pytest $(Build.SourcesDirectory)/tests
displayName: Test the Wheel
- job: windows
displayName: Test on Windows
pool: {vmImage: 'vs2017-win2016'}
variables:
plat_name: "win_amd64"
steps:
- script: git config --global core.symlinks true
- checkout: self
- {task: UsePythonVersion@0, inputs: {versionSpec: '3.6', architecture: x64}}
- download: current
artifact: build.windows
- bash: |
python -m pip install ../build.windows/*.whl
python -m pip install pytest
pytest tests
displayName: Test the Wheel
- job: alpine
displayName: Test on Alpine Linux
container: nicolassqreen/azure-pipelines-container-alpine-python:latest
steps:
- checkout: self
- download: current
artifact: build.alpine
- bash: |
sudo /opt/python/cp36-cp36m/bin/python -m pip install $(Pipeline.Workspace)/build.alpine/*.tar.gz
sudo /opt/python/cp36-cp36m/bin/python -m pip install pytest
/opt/python/cp36-cp36m/bin/pytest $(Build.SourcesDirectory)/tests
displayName: Test the Source Dist
- stage: release
condition: and(succeeded(), startsWith(variables['build.sourceBranch'], 'refs/tags/'))
jobs:
- job: release
steps:
- download: current
- task: S3Upload@1
displayName: Publish Wheelhouse to S3
inputs:
awsCredentials: AWS
bucketName: sqreen-download-private
globExpressions: |
**/py_mini_racer-*.whl
**/py_mini_racer-*.tar.gz
targetFolder: python/py-mini-racer/
sourceFolder: $(Pipeline.Workspace)
flattenFolders: true
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ __pycache__/

# C extensions
*.so
*.dylib
*.dll

# Distribution / packaging
.Python
Expand Down Expand Up @@ -68,7 +70,6 @@ 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
Expand Down
6 changes: 4 additions & 2 deletions MANIFEST.in
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,12 @@ include CONTRIBUTING.rst
include HISTORY.rst
include LICENSE
include README.rst
include py_mini_racer/extension/*.gn

include py_mini_racer/libmini_racer.glibc.so py_mini_racer/libmini_racer.muslc.so
include py_mini_racer/libmini_racer.dylib
include py_mini_racer/mini_racer.dll

recursive-include tests *
recursive-include requirements *
recursive-exclude * __pycache__
recursive-exclude * *.py[co]

Expand Down
27 changes: 11 additions & 16 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -138,14 +138,6 @@ We built Python wheels (prebuilt binaries) for macOS 64 bits, Linux 64 bits and
$ pip install py-mini-racer
If you're running Alpine, Pypi isn't able to host the dedicated wheels.
We're making them available with the following command.

.. code:: bash
$ pip install --index-url https://download.sqreen.io/python/alpine py-mini-racer
Build
-----

Expand All @@ -161,20 +153,17 @@ You can build the extension with the following command:

.. code:: bash
$ python setup.py build_ext
$ python helpers/v8_build.py
You can generate a wheel for whatever Python version with the command:

.. code:: bash
$ 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)
$ python3 helpers/build_package.py wheel dist
It will then build V8, the extension, and generates a wheel for your current
Python version. The V8 builds are cached in the ``py_mini_racer/extension/v8/``
directory. Please note that you can build Python 3 wheels by reusing the
cached version of V8 built with Python 2.7.
directory.

Notes for building on macOS
'''''''''''''''''''''''''''
Expand All @@ -187,11 +176,17 @@ They will allow to build a wheel compatible with former OSX versions.
Tests
-----

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

.. code-block:: bash
$ python -m pip install pytest
Then launch:

.. code:: bash
$ python setup.py test --addopts tests
$ python -m pytest tests
Credits
-------
Expand Down
80 changes: 0 additions & 80 deletions azure-pipelines.yml

This file was deleted.

Loading

0 comments on commit 1cef9d4

Please # to comment.