Skip to content

Commit d977865

Browse files
authored
Supporting building k2 on Windows (#946)
1 parent 8c28c86 commit d977865

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

56 files changed

+1261
-1165
lines changed
+117
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
# Copyright 2021 Xiaomi Corp. (author: Fangjun Kuang)
2+
3+
# See ../../LICENSE for clarification regarding multiple authors
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
17+
# refer to https://github.com/actions/starter-workflows/pull/47/files
18+
19+
20+
# Note, we have to set
21+
#
22+
# export DYLD_LIBRARY_PATH=$CONDA_PREFIX/lib/python3.8/site-packages:$DYLD_LIBRARY_PATH
23+
#
24+
# before running `python3 -m k2.version`
25+
#
26+
# See https://github.com/openPMD/openPMD-api/issues/593#issuecomment-552690470
27+
28+
29+
name: build_conda_cpu_macos
30+
31+
on:
32+
push:
33+
tags:
34+
- '*'
35+
36+
env:
37+
K2_BUILD_TYPE: Release
38+
39+
jobs:
40+
generate_build_matrix:
41+
# see https://github.com/pytorch/pytorch/pull/50633
42+
runs-on: ubuntu-latest
43+
outputs:
44+
matrix: ${{ steps.set-matrix.outputs.matrix }}
45+
steps:
46+
- uses: actions/checkout@v2
47+
with:
48+
fetch-depth: 0
49+
- name: Generating build matrix
50+
id: set-matrix
51+
run: |
52+
# outputting for debugging purposes
53+
python scripts/github_actions/generate_build_matrix.py
54+
MATRIX=$(python scripts/github_actions/generate_build_matrix.py)
55+
echo "::set-output name=matrix::${MATRIX}"
56+
57+
build_conda_cpu_macos:
58+
needs: generate_build_matrix
59+
runs-on: macos-10.15
60+
strategy:
61+
fail-fast: false
62+
matrix:
63+
${{ fromJson(needs.generate_build_matrix.outputs.matrix) }}
64+
65+
steps:
66+
# refer to https://github.com/actions/checkout
67+
- uses: actions/checkout@v2
68+
with:
69+
fetch-depth: 0
70+
71+
- uses: conda-incubator/setup-miniconda@v2
72+
with:
73+
auto-update-conda: true
74+
python-version: ${{ matrix.python-version }}
75+
activate-environment: k2
76+
77+
- name: Display Python version
78+
shell: bash -l {0}
79+
run: |
80+
python3 -c "import sys; print(sys.version)"
81+
which python3
82+
83+
- name: Install conda dependencies
84+
shell: bash -l {0}
85+
run: |
86+
conda install -y -q anaconda-client
87+
conda install -y -q conda-build
88+
conda install -y -q -c pytorch pytorch=${{ matrix.torch }} cpuonly
89+
90+
- name: Display conda info
91+
shell: bash -l {0}
92+
run: |
93+
which conda
94+
conda env list
95+
conda info
96+
97+
- name: Build k2
98+
shell: bash -l {0}
99+
env:
100+
K2_PYTHON_VERSION: ${{ matrix.python-version}}
101+
K2_TORCH_VERSION: ${{ matrix.torch }}
102+
K2_CONDA_TOKEN: ${{ secrets.K2_CONDA_TOKEN}}
103+
K2_IS_GITHUB_ACTIONS: 1
104+
K2_IS_FOR_CONDA: 1
105+
run: |
106+
export K2_BUILD_TYPE=$K2_BUILD_TYPE
107+
./scripts/build_conda_cpu.sh
108+
109+
- name: Display generated files
110+
run: |
111+
ls -lh /usr/local/miniconda/envs/k2/conda-bld/osx-64
112+
113+
- name: Upload generated files
114+
uses: actions/upload-artifact@v2
115+
with:
116+
name: torch-${{ matrix.torch }}-python-${{ matrix.python-version }}-${{ matrix.os }}
117+
path: /usr/local/miniconda/envs/k2/conda-bld/osx-64/*.tar.bz2

.github/workflows/build_conda_cpu.yml .github/workflows/build-conda-cpu-ubuntu.yml

+24-65
Original file line numberDiff line numberDiff line change
@@ -26,68 +26,41 @@
2626
# See https://github.com/openPMD/openPMD-api/issues/593#issuecomment-552690470
2727

2828

29-
name: build_conda_cpu
29+
name: build_conda_cpu_ubuntu
3030

3131
on:
3232
push:
33-
branches:
34-
- conda-cpu
33+
tags:
34+
- '*'
3535

3636
env:
3737
K2_BUILD_TYPE: Release
3838

3939
jobs:
40-
build_conda_cpu:
41-
runs-on: ${{ matrix.os }}
40+
generate_build_matrix:
41+
# see https://github.com/pytorch/pytorch/pull/50633
42+
runs-on: ubuntu-latest
43+
outputs:
44+
matrix: ${{ steps.set-matrix.outputs.matrix }}
45+
steps:
46+
- uses: actions/checkout@v2
47+
with:
48+
fetch-depth: 0
49+
- name: Generating build matrix
50+
id: set-matrix
51+
run: |
52+
# outputting for debugging purposes
53+
python scripts/github_actions/generate_build_matrix.py
54+
MATRIX=$(python scripts/github_actions/generate_build_matrix.py)
55+
echo "::set-output name=matrix::${MATRIX}"
56+
57+
build_conda_cpu_ubuntu:
58+
needs: generate_build_matrix
59+
runs-on: ubuntu-18.04
4260
strategy:
4361
fail-fast: false
4462
matrix:
45-
os: [ubuntu-18.04, macos-10.15]
46-
python-version: ["3.6", "3.7", "3.8", "3.9", "3.10"]
47-
# from https://download.pytorch.org/whl/torch_stable.html
48-
#
49-
# PyTorch 1.11.x supports 3.7, 3.8, 3.9, 3.10
50-
# PyTorch 1.10, 1.9.x, 1.8.x, and 1.7.1 support 3.6, 3.7, 3.8, 3.9
51-
# PyTorch 1.7.0, 1.6.0, and 1.5.x support 3.6, 3.7, 3.8
52-
#
53-
# Other PyTorch versions are not tested
54-
#
55-
torch: ["1.5.0", "1.5.1", "1.6.0", "1.7.0", "1.7.1", "1.8.0", "1.8.1", "1.9.0", "1.9.1", "1.10.0", "1.10.1", "1.10.2", "1.11.0"]
56-
exclude:
57-
- python-version: "3.9" # exclude Python 3.9 for [1.5.0, 1.5.1, 1.6.0, 1.7.0]
58-
torch: "1.5.0"
59-
- python-version: "3.9"
60-
torch: "1.5.1"
61-
- python-version: "3.9"
62-
torch: "1.6.0"
63-
- python-version: "3.9"
64-
torch: "1.7.0"
65-
- python-version: "3.10" # exclude Python 3.10 for [1.5.0, 1.5.1, 1.6.0, 1.7.0, 1.7.1, 1.8.0, 1.8.1, 1.9.0, 1.9.1, 1.10.0, 1.10.1, 1.10.2]
66-
torch: "1.5.0"
67-
- python-version: "3.10"
68-
torch: "1.5.1"
69-
- python-version: "3.10"
70-
torch: "1.6.0"
71-
- python-version: "3.10"
72-
torch: "1.7.0"
73-
- python-version: "3.10"
74-
torch: "1.7.1"
75-
- python-version: "3.10"
76-
torch: "1.8.0"
77-
- python-version: "3.10"
78-
torch: "1.8.1"
79-
- python-version: "3.10"
80-
torch: "1.9.0"
81-
- python-version: "3.10"
82-
torch: "1.9.1"
83-
- python-version: "3.10"
84-
torch: "1.10.0"
85-
- python-version: "3.10"
86-
torch: "1.10.1"
87-
- python-version: "3.10"
88-
torch: "1.10.2"
89-
- python-version: "3.6" # exclude Python 3.6 for [1.11.0]
90-
torch: "1.11.0"
63+
${{ fromJson(needs.generate_build_matrix.outputs.matrix) }}
9164

9265
steps:
9366
# refer to https://github.com/actions/checkout
@@ -134,25 +107,11 @@ jobs:
134107
./scripts/build_conda_cpu.sh
135108
136109
- name: Display generated files
137-
if: startsWith(matrix.os, 'ubuntu')
138110
run: |
139111
ls -lh /usr/share/miniconda/envs/k2/conda-bld/linux-64
140112
141-
- name: Display generated files
142-
if: startsWith(matrix.os, 'macos')
143-
run: |
144-
ls -lh /usr/local/miniconda/envs/k2/conda-bld/osx-64
145-
146113
- name: Upload generated files
147-
if: startsWith(matrix.os, 'ubuntu')
148114
uses: actions/upload-artifact@v2
149115
with:
150116
name: torch-${{ matrix.torch }}-python-${{ matrix.python-version }}-${{ matrix.os }}
151117
path: /usr/share/miniconda/envs/k2/conda-bld/linux-64/*.tar.bz2
152-
153-
- name: Upload generated files
154-
if: startsWith(matrix.os, 'macos')
155-
uses: actions/upload-artifact@v2
156-
with:
157-
name: torch-${{ matrix.torch }}-python-${{ matrix.python-version }}-${{ matrix.os }}
158-
path: /usr/local/miniconda/envs/k2/conda-bld/osx-64/*.tar.bz2

.github/workflows/windows-conda.yml .github/workflows/build-conda-cpu-windows.yml

+24-18
Original file line numberDiff line numberDiff line change
@@ -15,36 +15,42 @@
1515
# limitations under the License.
1616

1717

18-
name: build-windows-conda
18+
name: build_conda_cpu_windows
1919

2020
on:
2121
push:
22-
branches:
23-
- conda-win
22+
tags:
23+
- '*'
2424

2525
env:
2626
BUILD_TYPE: Release
2727

2828
jobs:
29-
build-windows-conda:
29+
generate_build_matrix:
30+
# see https://github.com/pytorch/pytorch/pull/50633
31+
runs-on: ubuntu-latest
32+
outputs:
33+
matrix: ${{ steps.set-matrix.outputs.matrix }}
34+
steps:
35+
- uses: actions/checkout@v2
36+
with:
37+
fetch-depth: 0
38+
- name: Generating build matrix
39+
id: set-matrix
40+
run: |
41+
# outputting for debugging purposes
42+
python scripts/github_actions/generate_build_matrix.py
43+
MATRIX=$(python scripts/github_actions/generate_build_matrix.py)
44+
echo "::set-output name=matrix::${MATRIX}"
45+
46+
build_conda_cpu_windows:
3047
# see https://github.com/actions/virtual-environments/blob/win19/20210525.0/images/win/Windows2019-Readme.md
31-
runs-on: ${{ matrix.os }}
48+
needs: generate_build_matrix
49+
runs-on: windows-2019
3250
strategy:
3351
fail-fast: false
3452
matrix:
35-
os: [windows-2019]
36-
# Python 3.9 is for PyTorch 1.7.1, 1.8.x, 1.9.0,
37-
python-version: [3.6, 3.7, 3.8, 3.9]
38-
torch: ["1.5.0", "1.5.1", "1.6.0", "1.7.0", "1.7.1", "1.8.0", "1.8.1", "1.9.0"]
39-
exclude:
40-
- python-version: 3.9 # exclude Python 3.9 for [1.5.0, 1.5.1, 1.6.0, 1.7.0]
41-
torch: "1.5.0"
42-
- python-version: 3.9
43-
torch: "1.5.1"
44-
- python-version: 3.9
45-
torch: "1.6.0"
46-
- python-version: 3.9
47-
torch: "1.7.0"
53+
${{ fromJson(needs.generate_build_matrix.outputs.matrix) }}
4854

4955
steps:
5056
- uses: actions/checkout@v2

0 commit comments

Comments
 (0)