forked from facebookincubator/ft_utils
-
Notifications
You must be signed in to change notification settings - Fork 0
134 lines (119 loc) · 4.59 KB
/
build.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
# Copyright (c) Meta Platforms, Inc. and affiliates.
name: Build and Test
on:
push:
branches:
- main
# This build configuration uses a matrix to build and test multiple Python versions.
# Each version is actioned across on multiple operating systems (Ubuntu, Windows, macOS).
# For standard Python builds, we use pre-built binary releases for efficiency.
# However, since nogil-enabled Python binaries are not readily available,
# we build Python from source with nogil (free threaded) builds.
# This approach allows us to test our extension with different Python configurations.
# Our goals are to ensure compatibility and reliability across various environments,
# and to create platform-specific wheels for distribution on PyPi.
jobs:
build:
strategy:
fail-fast: false
matrix:
include:
# Add below those versions we want as Gil Based releases.
# Note that 3.12.7 is only availible with the Gil enabled.
#- os: ubuntu-latest
# python-version: '3.12.7'
# build-from-source: false
#- os: ubuntu-latest
# python-version: '3.13.0'
# build-from-source: false
#- os: windows-latest
# python-version: '3.13.0'
# build-from-source: false
#- os: macos-latest
# python-version: '3.13.0'
# build-from-source: false
#- os: ubuntu-latest
# python-version: '3.14.0-alpha.0'
# build-from-source: false
# Add below those versions we want as Free Threaded releases.
# For these you will need the tag name see: https://github.com/python/cpython/tags
#- os: ubuntu-latest
# python-version: 'v3.13.0'
# build-from-source: true
# nogil: true
- os: windows-latest
python-version: 'v3.13.0'
build-from-source: true
nogil: true
#- os: macos-latest
# python-version: 'v3.13.0'
# build-from-source: true
# nogil: true
#- os: ubuntu-latest
# python-version: '3.14.0-alpha.0'
# build-from-source: true
# nogil: true
runs-on: ${{ matrix.os }}
steps:
# Checkout the code from the repository.
- name: Checkout code
uses: actions/checkout@v4
# Set up Python using pre-built binary releases or building from source.
- name: Set up Python
if: matrix.build-from-source == false
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Build Python from Source
if: matrix.build-from-source == true
uses: ./.github/actions/build-python-from-source
with:
python-version: ${{ matrix.python-version }}
nogil: ${{ matrix.nogil }}
# Make sure we use our version of python, this is set in the build-from-source
# action os set it here for consistency if not building from source.
- name: Set LOCAL_PYTHON envvar
if: matrix.build-from-source == false
shell: bash
run: echo "LOCAL_PYTHON=python" >> $GITHUB_ENV
# Upgrade pip to the latest version.
- name: Install/Upgrade pip
shell: bash
run: |
$LOCAL_PYTHON -m ensurepip
$LOCAL_PYTHON -m pip install --upgrade pip
# Make sure Visual Studio build is all in place on Windows.
- name: Setup MSVC
if: runner.os == 'Windows'
uses: ilammy/msvc-dev-cmd@v1
# Install dependencies required for building and testing.
- name: Install dependencies
shell: bash
run: |
$LOCAL_PYTHON -m pip install --upgrade setuptools wheel
# Build the wheel package with or without nogil suffix.
- name: Build
shell: bash
run: |
$LOCAL_PYTHON -P setup.py bdist_wheel
#if [ "${{ matrix.build-from-source }}" = "true" ]; then
#cd ${{github.workspace}}
## There is only one so we don't need a loop but - meh.
#for file in build/dist/*.whl; do
# mv "$file" "${file%.whl}_nogil.whl"
#done
#fi
# Install the built wheel package so we can test it.
- name: Install wheel
shell: bash
run: |
$LOCAL_PYTHON -m pip install build/dist/*.whl
working-directory: ${{github.workspace}}
# Run all the tests and benchmarks.
- name: Test
shell: bash
run: |
mkdir test_dir
cd test_dir
$LOCAL_PYTHON -m ft_utils.tests.test_run_all
working-directory: ${{github.workspace}}