-
Notifications
You must be signed in to change notification settings - Fork 521
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Build modernization (GHA, wheels, setuptools) #407
Changes from all commits
0ba72f8
cfb1d7d
4327345
99568e5
cc9f531
a7de8d2
79bbe26
d2139d0
8d9be9e
dcb137a
3165b50
2a2bfc6
115228c
59bcd38
75ccf4c
3ad7bb0
3108af5
9803591
dee7252
57cb517
76d7f19
f69087c
46eed93
c0180aa
d6f7f87
cb71ba5
c2203e7
6269678
8e9cebe
393985f
ee1dc2b
b509351
54abbdc
02de749
6ecc19d
4f9aae0
71fe365
c781067
f6225d2
510d297
27a27ce
6656bd7
c577b2f
007869b
9dba870
473a885
6a292fa
6c9faab
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,236 @@ | ||
--- | ||
|
||
name: PyYAML CI | ||
on: | ||
push: | ||
pull_request: | ||
workflow_dispatch: | ||
|
||
env: | ||
LIBYAML_REPO: https://github.com/yaml/libyaml | ||
LIBYAML_REF: '0.2.5' | ||
jobs: | ||
python_sdist: | ||
name: pyyaml sdist | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: checkout pyyaml | ||
uses: actions/checkout@v2 | ||
|
||
- name: install a python | ||
uses: actions/setup-python@v2 | ||
with: | ||
python-version: 3.x | ||
|
||
- name: install build deps | ||
run: | | ||
python -V | ||
|
||
python -m pip install build | ||
|
||
- name: build sdist | ||
run: | | ||
export PYYAML_FORCE_CYTHON=1 # we DO want to force Cythoning, at least until 6.0 | ||
export PYYAML_FORCE_LIBYAML=0 # we don't actually want to build the lib | ||
|
||
python -m build . | ||
|
||
# ensure exactly one artifact was produced | ||
shopt -s nullglob | ||
DISTFILES=(dist/*.tar.gz) | ||
if [[ ${DISTFILES[@]} -ne 1 ]]; then | ||
echo "unexpected content in dist dir: $(ls dist/*.tar.gz)" | ||
exit 1 | ||
fi | ||
|
||
- name: test sdist | ||
run: | | ||
# install some libyaml headers | ||
# TODO: should we smoke test the sdist against the libyaml we built? | ||
sudo apt update | ||
sudo apt install libyaml-dev -y | ||
|
||
# ensure Cython is not present so we use only what's in the sdist | ||
python -m pip uninstall Cython -y || true | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This shouldn't matter because unless you disable pip PEP517 build env isolation, it'll be built in a separate clean virtualenv that does not have Cython unless you add it as a build dep via |
||
|
||
# pass no extra args- we should auto-install with libyaml since it's present | ||
python -m pip install dist/*.tar.gz -v | ||
|
||
python packaging/build/smoketest.py | ||
|
||
- name: upload sdist artifact | ||
uses: actions/upload-artifact@v2 | ||
with: | ||
name: dist | ||
path: dist/*.tar.gz | ||
|
||
|
||
linux_libyaml: | ||
name: libyaml ${{ matrix.arch }} ${{ matrix.platform }} | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
platform: | ||
# manylinux1 is forward-compatible to 2010/2014 | ||
#- manylinux2014 | ||
#- manylinux2010 | ||
- manylinux1 | ||
arch: | ||
- x86_64 | ||
env: | ||
DOCKER_IMAGE: quay.io/pypa/${{ matrix.platform }}_${{ matrix.arch }} | ||
steps: | ||
- name: check cached libyaml state | ||
id: cached_libyaml | ||
uses: actions/cache@v2 | ||
with: | ||
path: | | ||
libyaml | ||
key: libyaml_${{ matrix.platform }}_${{ matrix.arch }}_${{ env.LIBYAML_REF }} | ||
|
||
- name: checkout pyyaml | ||
uses: actions/checkout@v2 | ||
if: steps.cached_libyaml.outputs.cache-hit != 'true' | ||
|
||
- name: build libyaml | ||
run: | | ||
docker run --rm -v $(pwd):/io -e LIBYAML_REF -e LIBYAML_REPO --workdir /io "$DOCKER_IMAGE" /io/packaging/build/libyaml.sh | ||
if: steps.cached_libyaml.outputs.cache-hit != 'true' | ||
|
||
linux_pyyaml: | ||
needs: linux_libyaml | ||
name: pyyaml ${{ matrix.arch }} ${{ matrix.platform }} ${{ matrix.python_tag }} | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
platform: | ||
# so long as manylinux1 container builds work, they're forward-compatible to 2010/2014 | ||
# - manylinux2014 | ||
# - manylinux2010 | ||
- manylinux1 | ||
arch: | ||
- x86_64 | ||
python_tag: | ||
# NB: manylinux >=2014 containers don't have Python 2.7, so we have to use exclude to skip it | ||
- cp27-cp27mu | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @nitzmahone why only "mu"? py2 has two separate builds to link against There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You also need "cp27-cp27m" to cover that. |
||
- cp36-cp36m | ||
- cp37-cp37m | ||
- cp38-cp38 | ||
- cp39-cp39 | ||
# exclude: | ||
# - platform: manylinux2014 | ||
# arch: x86_64 | ||
# python_tag: cp27-cp27mu | ||
env: | ||
AW_PLAT: ${{ matrix.platform }}_${{ matrix.arch }} | ||
DOCKER_IMAGE: quay.io/pypa/${{ matrix.platform }}_${{ matrix.arch }} | ||
PYTHON_TAG: ${{ matrix.python_tag }} | ||
PYYAML_BUILD_WHEELS: 1 | ||
steps: | ||
- uses: actions/checkout@v2 | ||
|
||
- name: fetch cached libyaml | ||
id: cached_libyaml | ||
uses: actions/cache@v2 | ||
with: | ||
path: | | ||
libyaml | ||
key: libyaml_${{ matrix.platform }}_${{ matrix.arch }}_${{ env.LIBYAML_REF }} | ||
|
||
- name: ensure libyaml fetched | ||
run: exit 1 | ||
if: steps.cached_libyaml.outputs.cache-hit != 'true' | ||
|
||
- name: start container | ||
run: | | ||
docker run --name worker -t -d --rm -v $(pwd):/io "$DOCKER_IMAGE" bash | ||
|
||
- name: build/test/package | ||
run: | | ||
docker exec -e PYTHON_TAG -e PYYAML_RUN_TESTS -e PYYAML_BUILD_WHEELS -e AW_PLAT --workdir /io worker \ | ||
/io/packaging/build/manylinux.sh | ||
|
||
- uses: actions/upload-artifact@v2 | ||
with: | ||
name: dist | ||
path: dist/*.whl | ||
|
||
macos_libyaml: | ||
name: libyaml ${{ matrix.arch }} ${{ matrix.platform }} | ||
runs-on: ${{ matrix.platform }} | ||
strategy: | ||
matrix: | ||
platform: | ||
- macos-10.15 | ||
arch: | ||
- x86_64 | ||
steps: | ||
- name: check cached libyaml state | ||
id: cached_libyaml | ||
uses: actions/cache@v2 | ||
with: | ||
path: | | ||
libyaml | ||
key: libyaml_${{ matrix.platform }}_${{ matrix.arch }}_${{ env.LIBYAML_REF }} | ||
|
||
- name: checkout pyyaml | ||
uses: actions/checkout@v2 | ||
if: steps.cached_libyaml.outputs.cache-hit != 'true' | ||
|
||
- name: build libyaml | ||
env: | ||
MACOSX_DEPLOYMENT_TARGET: '10.9' | ||
run: | | ||
brew install automake coreutils | ||
bash ./packaging/build/libyaml.sh | ||
if: steps.cached_libyaml.outputs.cache-hit != 'true' | ||
|
||
|
||
macos_pyyaml: | ||
needs: macos_libyaml | ||
name: pyyaml ${{ matrix.arch }} ${{ matrix.platform }} ${{ matrix.python_tag }} | ||
runs-on: ${{ matrix.platform }} | ||
strategy: | ||
matrix: | ||
platform: | ||
- macos-10.15 | ||
arch: | ||
- x86_64 | ||
python_tag: | ||
- cp27* | ||
- cp36* | ||
- cp37* | ||
- cp38* | ||
- cp39* | ||
steps: | ||
- name: checkout pyyaml | ||
uses: actions/checkout@v2 | ||
|
||
- name: get cached libyaml state | ||
id: cached_libyaml | ||
uses: actions/cache@v2 | ||
with: | ||
path: | | ||
libyaml | ||
key: libyaml_${{ matrix.platform }}_${{ matrix.arch }}_${{ env.LIBYAML_REF }} | ||
|
||
- name: ensure libyaml fetched | ||
run: exit 1 | ||
if: steps.cached_libyaml.outputs.cache-hit != 'true' | ||
|
||
- name: install a python | ||
uses: actions/setup-python@v2 | ||
with: | ||
python-version: 3.x | ||
|
||
- name: build/test/package | ||
env: | ||
CIBW_BUILD: ${{ matrix.python_tag }} | ||
CIBW_BUILD_VERBOSITY: 1 | ||
run: | | ||
bash ./packaging/build/macos.sh | ||
|
||
- uses: actions/upload-artifact@v2 | ||
with: | ||
name: dist | ||
path: dist/*.whl |
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,10 @@ | ||
include README LICENSE CHANGES setup.py | ||
include CHANGES README LICENSE Makefile pyproject.toml setup.py | ||
recursive-include lib/yaml *.py | ||
recursive-include lib/_yaml *.py | ||
recursive-include lib3/yaml *.py | ||
recursive-include lib3/_yaml *.py | ||
recursive-include examples *.py *.cfg *.yaml | ||
recursive-include tests/data * | ||
recursive-include tests/lib *.py | ||
recursive-include tests/lib3 *.py | ||
recursive-include yaml * |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
# This is a stub package designed to roughly emulate the _yaml | ||
# extension module, which previously existed as a standalone module | ||
# and has been moved into the `yaml` package namespace. | ||
# It does not perfectly mimic its old counterpart, but should get | ||
# close enough for anyone who's relying on it even when they shouldn't. | ||
import yaml | ||
|
||
if not yaml.__with_libyaml__: | ||
from sys import version_info | ||
|
||
exc = ModuleNotFoundError if version_info >= (3, 6) else ImportError | ||
raise exc("No module named '_yaml'") | ||
else: | ||
from yaml._yaml import * | ||
import warnings | ||
warnings.warn( | ||
'The _yaml extension module is now located at yaml._yaml' | ||
' and its location is subject to change. To use the' | ||
' LibYAML-based parser and emitter, import from `yaml`:' | ||
' `from yaml import CLoader as Loader, CDumper as Dumper`.', | ||
DeprecationWarning | ||
) | ||
del warnings | ||
# Don't `del yaml` here because yaml is actually an existing | ||
# namespace member of _yaml. | ||
|
||
__name__ = '_yaml' | ||
# If the module is top-level (i.e. not a part of any specific package) | ||
# then the attribute should be set to ''. | ||
# https://docs.python.org/3.8/library/types.html | ||
__package__ = '' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@nitzmahone traditionally, it's common to include C-files generated from Cython in sdists.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With pyproject.toml it's not as important anymore, as you can specify Cython as a build dependency. (Not saying you can't)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@henryiii and it is specified there. I just remember that we tried to avoid that in aiohttp because at the time installing Cython required some extra system build deps.