Skip to content

Commit d560639

Browse files
seemetherevincentqb
authored andcommitted
Add Python 3.9 support (#1242)
Signed-off-by: Eli Uriegas <[email protected]>
1 parent 8115fbf commit d560639

File tree

10 files changed

+338
-18
lines changed

10 files changed

+338
-18
lines changed

.circleci/config.yml

Lines changed: 247 additions & 2 deletions
Large diffs are not rendered by default.

.circleci/config.yml.in

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,16 @@ commands:
4545
name: Install pkg-config
4646
command: HOMEBREW_NO_AUTO_UPDATE=1 brew install pkg-config wget
4747
# Disable brew auto update which is very slow
48+
load_conda_channel_flags:
49+
description: "Determines whether we need extra conda channels"
50+
steps:
51+
- run:
52+
name: Adding CONDA_CHANNEL_FLAGS to BASH_ENV
53+
command: |
54+
CONDA_CHANNEL_FLAGS=""
55+
if [[ "${PYTHON_VERSION}" = *3.9* ]]; then
56+
echo "export CONDA_CHANNEL_FLAGS=-c=conda-forge" >> ${BASH_ENV}
57+
fi
4858

4959
binary_common: &binary_common
5060
parameters:
@@ -117,7 +127,7 @@ jobs:
117127
binary_linux_wheel:
118128
<<: *binary_common
119129
docker:
120-
- image: "pytorch/manylinux-cuda100"
130+
- image: "pytorch/manylinux-cuda102"
121131
resource_class: 2xlarge+
122132
steps:
123133
- checkout
@@ -138,6 +148,7 @@ jobs:
138148
resource_class: 2xlarge+
139149
steps:
140150
- checkout
151+
- load_conda_channel_flags
141152
- attach_workspace:
142153
at: third_party
143154
- run: packaging/build_conda.sh
@@ -155,6 +166,7 @@ jobs:
155166
steps:
156167
- checkout
157168
- install_build_tools_macos
169+
- load_conda_channel_flags
158170
- attach_workspace:
159171
at: third_party
160172
- run:
@@ -180,6 +192,7 @@ jobs:
180192
steps:
181193
- checkout
182194
- install_build_tools_macos
195+
- load_conda_channel_flags
183196
- attach_workspace:
184197
at: third_party
185198
- run:
@@ -202,6 +215,7 @@ jobs:
202215
name: windows-cpu
203216
steps:
204217
- checkout
218+
- load_conda_channel_flags
205219
- run:
206220
name: build
207221
command: |
@@ -221,6 +235,7 @@ jobs:
221235
name: windows-cpu
222236
steps:
223237
- checkout
238+
- load_conda_channel_flags
224239
- run:
225240
name: build
226241
command: |
@@ -278,6 +293,7 @@ jobs:
278293
- attach_workspace:
279294
at: ~/workspace
280295
- designate_upload_channel
296+
- load_conda_channel_flags
281297
- run:
282298
name: install binaries
283299
command: |
@@ -297,6 +313,7 @@ jobs:
297313
- attach_workspace:
298314
at: ~/workspace
299315
- designate_upload_channel
316+
- load_conda_channel_flags
300317
- run:
301318
name: install binaries
302319
command: |
@@ -317,6 +334,7 @@ jobs:
317334
- attach_workspace:
318335
at: ~/workspace
319336
- designate_upload_channel
337+
- load_conda_channel_flags
320338
- run:
321339
name: install binaries
322340
command: |
@@ -342,6 +360,7 @@ jobs:
342360
- attach_workspace:
343361
at: ~/workspace
344362
- designate_upload_channel
363+
- load_conda_channel_flags
345364
- run:
346365
name: install binaries
347366
command: |
@@ -395,6 +414,7 @@ jobs:
395414
- attach_workspace:
396415
at: third_party
397416
- designate_upload_channel
417+
- load_conda_channel_flags
398418
- run:
399419
name: Setup
400420
command: .circleci/unittest/linux/scripts/setup_env.sh
@@ -423,6 +443,7 @@ jobs:
423443
- attach_workspace:
424444
at: third_party
425445
- designate_upload_channel
446+
- load_conda_channel_flags
426447
- run:
427448
name: Pull Docker image
428449
command: docker pull --quiet "${image_name}"
@@ -431,7 +452,7 @@ jobs:
431452
command: docker run -t --gpus all -e PYTHON_VERSION -v $PWD:$PWD -w $PWD "${image_name}" .circleci/unittest/linux/scripts/setup_env.sh
432453
- run:
433454
name: Install torchaudio
434-
command: docker run -t --gpus all -e UPLOAD_CHANNEL -v $PWD:$PWD -w $PWD "${image_name}" .circleci/unittest/linux/scripts/install.sh
455+
command: docker run -t --gpus all -e UPLOAD_CHANNEL -e CONDA_CHANNEL_FLAGS -v $PWD:$PWD -w $PWD "${image_name}" .circleci/unittest/linux/scripts/install.sh
435456
- run:
436457
name: Run tests
437458
command: docker run -t --gpus all -v $PWD:$PWD -w $PWD "${image_name}" .circleci/unittest/linux/scripts/run_test.sh
@@ -448,6 +469,7 @@ jobs:
448469
steps:
449470
- checkout
450471
- designate_upload_channel
472+
- load_conda_channel_flags
451473
- run:
452474
name: Setup
453475
command: .circleci/unittest/windows/scripts/setup_env.sh
@@ -473,6 +495,7 @@ jobs:
473495
steps:
474496
- checkout
475497
- designate_upload_channel
498+
- load_conda_channel_flags
476499
- run:
477500
name: Setup
478501
command: .circleci/unittest/windows/scripts/setup_env.sh
@@ -496,6 +519,7 @@ jobs:
496519
steps:
497520
- checkout
498521
- install_build_tools_macos
522+
- load_conda_channel_flags
499523
- attach_workspace:
500524
at: third_party
501525
- designate_upload_channel
@@ -522,6 +546,7 @@ jobs:
522546
steps:
523547
- checkout
524548
- designate_upload_channel
549+
- load_conda_channel_flags
525550
- run:
526551
name: Setup
527552
command: .circleci/unittest/linux/scripts/setup_env.sh
@@ -538,6 +563,7 @@ jobs:
538563
- attach_workspace:
539564
at: ~/workspace
540565
- checkout
566+
- load_conda_channel_flags
541567
- run:
542568
name: Install pytorch-audio
543569
command: .circleci/build_docs/install_wheels.sh

.circleci/regenerate.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
import os.path
2020

2121

22-
PYTHON_VERSIONS = ["3.6", "3.7", "3.8"]
22+
PYTHON_VERSIONS = ["3.6", "3.7", "3.8", "3.9"]
2323

2424
DOC_VERSION = ('linux', '3.8')
2525

.circleci/unittest/linux/scripts/install.sh

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,11 @@ else
3434
cudatoolkit="cudatoolkit=${version}"
3535
fi
3636
printf "Installing PyTorch with %s\n" "${cudatoolkit}"
37-
conda install -y -c "pytorch-${UPLOAD_CHANNEL}" pytorch ${cudatoolkit}
37+
(
38+
set -x
39+
conda install ${CONDA_CHANNEL_FLAGS:-} -y defaults::numpy
40+
conda install ${CONDA_CHANNEL_FLAGS:-} -y -c "pytorch-${UPLOAD_CHANNEL}" "pytorch-${UPLOAD_CHANNEL}::pytorch" ${cudatoolkit}
41+
)
3842

3943
# 2. Install torchaudio
4044
printf "* Installing torchaudio\n"
@@ -43,11 +47,15 @@ BUILD_TRANSDUCER=0 BUILD_SOX=1 python setup.py install
4347

4448
# 3. Install Test tools
4549
printf "* Installing test tools\n"
46-
if [ "${os}" == Linux ] ; then
47-
conda install -y -c conda-forge codecov pytest pytest-cov
48-
pip install kaldi-io 'librosa>=0.8.0' parameterized SoundFile scipy 'requests>=2.20'
49-
else
50-
# Note: installing librosa via pip fail because it will try to compile numba.
51-
conda install -y -c conda-forge codecov pytest pytest-cov 'librosa>=0.8.0' parameterized scipy
52-
pip install kaldi-io SoundFile 'requests>=2.20'
50+
NUMBA_DEV_CHANNEL=""
51+
if [[ "$(python --version)" = *3.9* ]]; then
52+
# Numba isn't available for Python 3.9 except on the numba dev channel and building from source fails
53+
# See https://github.com/librosa/librosa/issues/1270#issuecomment-759065048
54+
NUMBA_DEV_CHANNEL="-c numba/label/dev"
5355
fi
56+
# Note: installing librosa via pip fail because it will try to compile numba.
57+
(
58+
set -x
59+
conda install -y -c conda-forge ${NUMBA_DEV_CHANNEL} 'librosa>=0.8.0' parameterized 'requests>=2.20'
60+
pip install kaldi-io SoundFile codecov pytest pytest-cov scipy
61+
)
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
channels:
2+
- conda-forge
3+
- defaults
4+
dependencies:
5+
- flake8
6+
- pytest
7+
- pytest-cov
8+
- codecov
9+
- scipy >= 1.4.1
10+
- pip
11+
- pip:
12+
- kaldi-io
13+
- PySoundFile
14+
- future
15+
- parameterized
16+
- dataclasses

.circleci/unittest/windows/scripts/install.sh

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,23 @@ else
2525
cudatoolkit="cudatoolkit=${version}"
2626
fi
2727
printf "Installing PyTorch with %s\n" "${cudatoolkit}"
28-
conda install -y -c "pytorch-${UPLOAD_CHANNEL}" pytorch "${cudatoolkit}"
28+
conda install ${CONDA_CHANNEL_FLAGS:-} -y -c "pytorch-${UPLOAD_CHANNEL}" "pytorch-${UPLOAD_CHANNEL}::pytorch" ${cudatoolkit}
2929

3030
# 2. Install torchaudio
3131
printf "* Installing torchaudio\n"
3232
python setup.py install
3333

3434
# 3. Install Test tools
3535
printf "* Installing test tools\n"
36-
conda install -y -c conda-forge codecov pytest pytest-cov
37-
pip install kaldi-io 'librosa>=0.8.0' parameterized PySoundFile scipy
36+
NUMBA_DEV_CHANNEL=""
37+
if [[ "$(python --version)" = *3.9* ]]; then
38+
# Numba isn't available for Python 3.9 except on the numba dev channel and building from source fails
39+
# See https://github.com/librosa/librosa/issues/1270#issuecomment-759065048
40+
NUMBA_DEV_CHANNEL="-c numba/label/dev"
41+
fi
42+
# Note: installing librosa via pip fail because it will try to compile numba.
43+
(
44+
set -x
45+
conda install -y -c conda-forge ${NUMBA_DEV_CHANNEL} 'librosa>=0.8.0' parameterized 'requests>=2.20'
46+
pip install kaldi-io SoundFile codecov pytest pytest-cov scipy
47+
)

.circleci/unittest/windows/scripts/setup_env.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,3 +37,9 @@ if [ ! -d "${env_dir}" ]; then
3737
conda create --prefix "${env_dir}" -y python="${PYTHON_VERSION}"
3838
fi
3939
conda activate "${env_dir}"
40+
NUMPY_PIN="1.11"
41+
if [[ "${PYTHON_VERSION}" = "3.9" ]]; then
42+
NUMPY_PIN="1.20"
43+
fi
44+
printf "* Installing numpy>=%s\n" "${NUMPY_PIN}\n"
45+
conda install -y -c conda-forge numpy>="${NUMPY_PIN}"

packaging/pkg_helpers.bash

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,7 @@ setup_wheel_python() {
141141
3.6) python_abi=cp36-cp36m ;;
142142
3.7) python_abi=cp37-cp37m ;;
143143
3.8) python_abi=cp38-cp38 ;;
144+
3.9) python_abi=cp39-cp39 ;;
144145
*)
145146
echo "Unrecognized PYTHON_VERSION=$PYTHON_VERSION"
146147
exit 1
@@ -176,11 +177,16 @@ setup_pip_pytorch_version() {
176177
#
177178
# You MUST have populated PYTORCH_VERSION_SUFFIX before hand.
178179
setup_conda_pytorch_constraint() {
180+
CONDA_CHANNEL_FLAGS="${CONDA_CHANNEL_FLAGS}"
179181
if [[ -z "$PYTORCH_VERSION" ]]; then
180-
export CONDA_CHANNEL_FLAGS="-c pytorch-nightly"
182+
export CONDA_CHANNEL_FLAGS="${CONDA_CHANNEL_FLAGS} -c pytorch-nightly"
181183
export PYTORCH_VERSION="$(conda search --json 'pytorch[channel=pytorch-nightly]' | python -c "import sys, json, re; print(re.sub(r'\\+.*$', '', json.load(sys.stdin)['pytorch'][-1]['version']))")"
182184
else
183-
export CONDA_CHANNEL_FLAGS="-c pytorch -c pytorch-${UPLOAD_CHANNEL}"
185+
export CONDA_CHANNEL_FLAGS="${CONDA_CHANNEL_FLAGS} -c pytorch -c pytorch-test -c pytorch-nightly"
186+
fi
187+
# Some dependencies for Python 3.9 are only on conda-forge
188+
if [[ "${PYTHON_VERSION}" = "3.9" ]]; then
189+
export CONDA_CHANNEL_FLAGS="${CONDA_CHANNEL_FLAGS} -c conda-forge"
184190
fi
185191
if [[ "$CU_VERSION" == cpu ]]; then
186192
export CONDA_PYTORCH_BUILD_CONSTRAINT="- pytorch==$PYTORCH_VERSION${PYTORCH_VERSION_SUFFIX}"

packaging/torchaudio/meta.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,12 @@ requirements:
1616
- cpuonly
1717
- cmake
1818
- ninja
19+
- defaults::numpy >=1.11
1920
{{ environ.get('CONDA_PYTORCH_BUILD_CONSTRAINT') }}
2021

2122
run:
2223
- python
24+
- defaults::numpy >=1.11
2325
{{ environ.get('CONDA_PYTORCH_CONSTRAINT') }}
2426

2527
build:

setup.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ def run(self):
7676
"Programming Language :: Python :: 3.6",
7777
"Programming Language :: Python :: 3.7",
7878
"Programming Language :: Python :: 3.8",
79+
"Programming Language :: Python :: 3.9",
7980
"Programming Language :: Python :: Implementation :: CPython",
8081
"Topic :: Multimedia :: Sound/Audio",
8182
"Topic :: Scientific/Engineering :: Artificial Intelligence"

0 commit comments

Comments
 (0)