Skip to content

Commit 0e4b5b3

Browse files
committed
Use cmake for third party
1 parent 4daf2fb commit 0e4b5b3

File tree

10 files changed

+155
-400
lines changed

10 files changed

+155
-400
lines changed

.circleci/config.yml

Lines changed: 31 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,17 @@ commands:
3838
our_upload_channel=test
3939
fi
4040
echo "export UPLOAD_CHANNEL=${our_upload_channel}" >> ${BASH_ENV}
41+
install_cmake_macos:
42+
description: "installs cmake on macOS. Use binary distribution as brew is slow"
43+
steps:
44+
- run:
45+
name: Install cmake
46+
command: |
47+
curl -L -o cmake.tar.gz https://github.com/Kitware/CMake/releases/download/v3.16.5/cmake-3.16.5-Darwin-x86_64.tar.gz
48+
mkdir cmake
49+
tar -xf cmake.tar.gz --strip 3 -C cmake
50+
rm cmake.tar.gz
51+
echo 'export PATH='"${PWD}/cmake/bin"':${PATH}' >> ${BASH_ENV}
4152
4253
binary_common: &binary_common
4354
parameters:
@@ -82,28 +93,30 @@ jobs:
8293
8394
download_third_parties_nix:
8495
docker:
85-
- image: "centos:8"
96+
- image: "pytorch/torchaudio_unittest_base:manylinux"
8697
resource_class: small
8798
steps:
8899
- checkout
89100
- generate_cache_key
90101
- restore_cache:
91102

92103
keys:
93-
- tp-nix-{{ checksum ".cachekey" }}-{{ checksum "./build_tools/setup_helpers/build_third_party.sh" }}-{{ checksum "./build_tools/setup_helpers/build_third_party_helper.sh" }}
104+
- tp-nix-v2-{{ checksum ".cachekey" }}
94105

95106
- run:
96-
command: ./build_tools/setup_helpers/build_third_party.sh $PWD --download-only
107+
command: |
108+
mkdir -p third_party/archives/
109+
wget --no-clobber --directory-prefix=third_party/archives/ $(awk '/URL /{print $2}' third_party/CMakeLists.txt)
97110
- save_cache:
98111

99-
key: tp-nix-{{ checksum ".cachekey" }}-{{ checksum "./build_tools/setup_helpers/build_third_party.sh" }}-{{ checksum "./build_tools/setup_helpers/build_third_party_helper.sh" }}
112+
key: tp-nix-v2-{{ checksum ".cachekey" }}
100113

101114
paths:
102-
- third_party/tmp
115+
- third_party/archives
103116
- persist_to_workspace:
104117
root: third_party
105118
paths:
106-
- tmp
119+
- archives
107120

108121
binary_linux_wheel:
109122
<<: *binary_common
@@ -145,6 +158,7 @@ jobs:
145158
xcode: "9.0"
146159
steps:
147160
- checkout
161+
- install_cmake_macos
148162
- attach_workspace:
149163
at: third_party
150164
- run:
@@ -169,6 +183,7 @@ jobs:
169183
xcode: "9.0"
170184
steps:
171185
- checkout
186+
- install_cmake_macos
172187
- attach_workspace:
173188
at: third_party
174189
- run:
@@ -383,19 +398,21 @@ jobs:
383398
- restore_cache:
384399

385400
keys:
386-
- env-v2-linux-{{ arch }}-py<< parameters.python_version >>-{{ checksum ".circleci/unittest/linux/scripts/environment.yml" }}-{{ checksum ".cachekey" }}
401+
- env-v3-linux-{{ arch }}-py<< parameters.python_version >>-{{ checksum ".circleci/unittest/linux/scripts/environment.yml" }}-{{ checksum ".cachekey" }}
387402

388403
- run:
389404
name: Setup
390405
command: .circleci/unittest/linux/scripts/setup_env.sh
391406
- save_cache:
392407

393-
key: env-v2-linux-{{ arch }}-py<< parameters.python_version >>-{{ checksum ".circleci/unittest/linux/scripts/environment.yml" }}-{{ checksum ".cachekey" }}
408+
key: env-v3-linux-{{ arch }}-py<< parameters.python_version >>-{{ checksum ".circleci/unittest/linux/scripts/environment.yml" }}-{{ checksum ".cachekey" }}
394409

395410
paths:
396411
- conda
397412
- env
398413
- third_party/build
414+
- third_party/install
415+
- third_party/src
399416
- run:
400417
name: Install torchaudio
401418
command: .circleci/unittest/linux/scripts/install.sh
@@ -423,19 +440,21 @@ jobs:
423440
- restore_cache:
424441

425442
keys:
426-
- env-v2-linux-{{ arch }}-py<< parameters.python_version >>-{{ checksum ".circleci/unittest/linux/scripts/environment.yml" }}-{{ checksum ".cachekey" }}
443+
- env-v3-linux-{{ arch }}-py<< parameters.python_version >>-{{ checksum ".circleci/unittest/linux/scripts/environment.yml" }}-{{ checksum ".cachekey" }}
427444

428445
- run:
429446
name: Setup
430447
command: docker run -t --gpus all -v $PWD:$PWD -w $PWD "${image_name}" .circleci/unittest/linux/scripts/setup_env.sh
431448
- save_cache:
432449

433-
key: env-v2-linux-{{ arch }}-py<< parameters.python_version >>-{{ checksum ".circleci/unittest/linux/scripts/environment.yml" }}-{{ checksum ".cachekey" }}
450+
key: env-v3-linux-{{ arch }}-py<< parameters.python_version >>-{{ checksum ".circleci/unittest/linux/scripts/environment.yml" }}-{{ checksum ".cachekey" }}
434451

435452
paths:
436453
- conda
437454
- env
438455
- third_party/build
456+
- third_party/install
457+
- third_party/src
439458
- run:
440459
name: Install torchaudio
441460
command: docker run -t --gpus all -v $PWD:$PWD -w $PWD "${image_name}" .circleci/unittest/linux/scripts/install.sh
@@ -542,6 +561,8 @@ jobs:
542561
- conda
543562
- env
544563
- third_party/build
564+
- third_party/install
565+
- third_party/src
545566
- run:
546567
name: Run style check
547568
command: .circleci/unittest/linux/scripts/run_style_checks.sh

.circleci/config.yml.in

Lines changed: 31 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,17 @@ commands:
3838
our_upload_channel=test
3939
fi
4040
echo "export UPLOAD_CHANNEL=${our_upload_channel}" >> ${BASH_ENV}
41+
install_cmake_macos:
42+
description: "installs cmake on macOS. Use binary distribution as brew is slow"
43+
steps:
44+
- run:
45+
name: Install cmake
46+
command: |
47+
curl -L -o cmake.tar.gz https://github.com/Kitware/CMake/releases/download/v3.16.5/cmake-3.16.5-Darwin-x86_64.tar.gz
48+
mkdir cmake
49+
tar -xf cmake.tar.gz --strip 3 -C cmake
50+
rm cmake.tar.gz
51+
echo 'export PATH='"${PWD}/cmake/bin"':${PATH}' >> ${BASH_ENV}
4152

4253
binary_common: &binary_common
4354
parameters:
@@ -82,28 +93,30 @@ jobs:
8293

8394
download_third_parties_nix:
8495
docker:
85-
- image: "centos:8"
96+
- image: "pytorch/torchaudio_unittest_base:manylinux"
8697
resource_class: small
8798
steps:
8899
- checkout
89100
- generate_cache_key
90101
- restore_cache:
91102
{% raw %}
92103
keys:
93-
- tp-nix-{{ checksum ".cachekey" }}-{{ checksum "./build_tools/setup_helpers/build_third_party.sh" }}-{{ checksum "./build_tools/setup_helpers/build_third_party_helper.sh" }}
104+
- tp-nix-v2-{{ checksum ".cachekey" }}
94105
{% endraw %}
95106
- run:
96-
command: ./build_tools/setup_helpers/build_third_party.sh $PWD --download-only
107+
command: |
108+
mkdir -p third_party/archives/
109+
wget --no-clobber --directory-prefix=third_party/archives/ $(awk '/URL /{print $2}' third_party/CMakeLists.txt)
97110
- save_cache:
98111
{% raw %}
99-
key: tp-nix-{{ checksum ".cachekey" }}-{{ checksum "./build_tools/setup_helpers/build_third_party.sh" }}-{{ checksum "./build_tools/setup_helpers/build_third_party_helper.sh" }}
112+
key: tp-nix-v2-{{ checksum ".cachekey" }}
100113
{% endraw %}
101114
paths:
102-
- third_party/tmp
115+
- third_party/archives
103116
- persist_to_workspace:
104117
root: third_party
105118
paths:
106-
- tmp
119+
- archives
107120

108121
binary_linux_wheel:
109122
<<: *binary_common
@@ -145,6 +158,7 @@ jobs:
145158
xcode: "9.0"
146159
steps:
147160
- checkout
161+
- install_cmake_macos
148162
- attach_workspace:
149163
at: third_party
150164
- run:
@@ -169,6 +183,7 @@ jobs:
169183
xcode: "9.0"
170184
steps:
171185
- checkout
186+
- install_cmake_macos
172187
- attach_workspace:
173188
at: third_party
174189
- run:
@@ -383,19 +398,21 @@ jobs:
383398
- restore_cache:
384399
{% raw %}
385400
keys:
386-
- env-v2-linux-{{ arch }}-py<< parameters.python_version >>-{{ checksum ".circleci/unittest/linux/scripts/environment.yml" }}-{{ checksum ".cachekey" }}
401+
- env-v3-linux-{{ arch }}-py<< parameters.python_version >>-{{ checksum ".circleci/unittest/linux/scripts/environment.yml" }}-{{ checksum ".cachekey" }}
387402
{% endraw %}
388403
- run:
389404
name: Setup
390405
command: .circleci/unittest/linux/scripts/setup_env.sh
391406
- save_cache:
392407
{% raw %}
393-
key: env-v2-linux-{{ arch }}-py<< parameters.python_version >>-{{ checksum ".circleci/unittest/linux/scripts/environment.yml" }}-{{ checksum ".cachekey" }}
408+
key: env-v3-linux-{{ arch }}-py<< parameters.python_version >>-{{ checksum ".circleci/unittest/linux/scripts/environment.yml" }}-{{ checksum ".cachekey" }}
394409
{% endraw %}
395410
paths:
396411
- conda
397412
- env
398413
- third_party/build
414+
- third_party/install
415+
- third_party/src
399416
- run:
400417
name: Install torchaudio
401418
command: .circleci/unittest/linux/scripts/install.sh
@@ -423,19 +440,21 @@ jobs:
423440
- restore_cache:
424441
{% raw %}
425442
keys:
426-
- env-v2-linux-{{ arch }}-py<< parameters.python_version >>-{{ checksum ".circleci/unittest/linux/scripts/environment.yml" }}-{{ checksum ".cachekey" }}
443+
- env-v3-linux-{{ arch }}-py<< parameters.python_version >>-{{ checksum ".circleci/unittest/linux/scripts/environment.yml" }}-{{ checksum ".cachekey" }}
427444
{% endraw %}
428445
- run:
429446
name: Setup
430447
command: docker run -t --gpus all -v $PWD:$PWD -w $PWD "${image_name}" .circleci/unittest/linux/scripts/setup_env.sh
431448
- save_cache:
432449
{% raw %}
433-
key: env-v2-linux-{{ arch }}-py<< parameters.python_version >>-{{ checksum ".circleci/unittest/linux/scripts/environment.yml" }}-{{ checksum ".cachekey" }}
450+
key: env-v3-linux-{{ arch }}-py<< parameters.python_version >>-{{ checksum ".circleci/unittest/linux/scripts/environment.yml" }}-{{ checksum ".cachekey" }}
434451
{% endraw %}
435452
paths:
436453
- conda
437454
- env
438455
- third_party/build
456+
- third_party/install
457+
- third_party/src
439458
- run:
440459
name: Install torchaudio
441460
command: docker run -t --gpus all -v $PWD:$PWD -w $PWD "${image_name}" .circleci/unittest/linux/scripts/install.sh
@@ -542,6 +561,8 @@ jobs:
542561
- conda
543562
- env
544563
- third_party/build
564+
- third_party/install
565+
- third_party/src
545566
- run:
546567
name: Run style check
547568
command: .circleci/unittest/linux/scripts/run_style_checks.sh

.circleci/unittest/linux/docker/Dockerfile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,8 @@ RUN apt update && apt install -y \
5858
sox \
5959
libsox-dev \
6060
libsox-fmt-all \
61+
cmake \
62+
ninja-build \
6163
&& rm -rf /var/lib/apt/lists/*
6264
COPY --from=builder /kaldi /kaldi
6365
COPY --from=builder /third_party /third_party

.circleci/unittest/linux/scripts/run_test.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,5 @@ eval "$(./conda/bin/conda shell.bash hook)"
66
conda activate ./env
77

88
python -m torch.utils.collect_env
9-
export PATH="${PWD}/third_party/build/bin/:${PATH}"
9+
export PATH="${PWD}/third_party/install/bin/:${PATH}"
1010
pytest --cov=torchaudio --junitxml=test-results/junit.xml -v --durations 20 test

.circleci/unittest/linux/scripts/setup_env.sh

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,5 +33,10 @@ conda activate "${env_dir}"
3333
printf "* Installing dependencies (except PyTorch)\n"
3434
conda env update --file "${this_dir}/environment.yml" --prune
3535

36-
# 4. Build codecs
37-
build_tools/setup_helpers/build_third_party.sh
36+
# 4. Buld codecs
37+
mkdir -p third_party/build
38+
(
39+
cd third_party/build
40+
cmake ..
41+
cmake --build .
42+
)

.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,3 +121,8 @@ gen.yml
121121
examples/interactive_asr/data/*.txt
122122
examples/interactive_asr/data/*.model
123123
examples/interactive_asr/data/*.pt
124+
125+
# third parties
126+
third_party/archives/
127+
third_party/install/
128+
third_party/src/

build_tools/setup_helpers/build_third_party.sh

Lines changed: 0 additions & 64 deletions
This file was deleted.

0 commit comments

Comments
 (0)