Skip to content

Commit 184b951

Browse files
committed
Test use uv for building wheels
1 parent 1ffc7f7 commit 184b951

File tree

2 files changed

+24
-65
lines changed

2 files changed

+24
-65
lines changed

.github/actions/setup-binary-builds/action.yml

Lines changed: 14 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -84,75 +84,34 @@ runs:
8484
# and "/" is not allowed in artifact names. //\//_ is to replace all forward slashes,
8585
# not just the first one
8686
echo "ARTIFACT_NAME=${REPOSITORY//\//_}_${REF//\//_}_${PYTHON_VERSION}_${CU_VERSION}_${ARCH}" >> "${GITHUB_ENV}"
87-
- name: Setup miniconda (for pytorch_pkg_helpers)
88-
if: ${{ inputs.setup-miniconda == 'true' }}
89-
uses: conda-incubator/[email protected]
90-
with:
91-
miniconda-version: "latest"
92-
python-version: 3.9
93-
- name: Clean conda environment
94-
shell: bash -l {0}
95-
run: |
96-
set -euxo pipefail
97-
conda info | grep -i 'base environment'
98-
conda clean --all --quiet --yes
99-
- name: Reset channel priority
87+
88+
- name: Install uv environment
10089
shell: bash -l {0}
10190
run: |
10291
set -euxo pipefail
103-
conda config --set channel_priority false
92+
curl -LsSf https://astral.sh/uv/install.sh | sh
93+
10494
- name: Generate file from pytorch_pkg_helpers
10595
working-directory: ${{ inputs.repository }}
10696
shell: bash -l {0}
10797
run: |
10898
set -euxo pipefail
109-
CONDA_ENV="${RUNNER_TEMP}/pytorch_pkg_helpers_${GITHUB_RUN_ID}"
110-
conda create \
111-
--yes --quiet \
112-
--prefix "${CONDA_ENV}" \
113-
"python=3.9"
114-
CONDA_ENV="${CONDA_ENV}"
115-
CONDA_RUN="conda run -p ${CONDA_ENV}"
116-
${CONDA_RUN} python -m pip install ${GITHUB_WORKSPACE}/test-infra/tools/pkg-helpers
99+
uv venv --python 3.9
100+
source .venv/bin/activate
101+
102+
python -m pip install ${GITHUB_WORKSPACE}/test-infra/tools/pkg-helpers
117103
BUILD_ENV_FILE="${RUNNER_TEMP}/build_env_${GITHUB_RUN_ID}"
118-
${CONDA_RUN} python -m pytorch_pkg_helpers > "${BUILD_ENV_FILE}"
104+
python -m pytorch_pkg_helpers > "${BUILD_ENV_FILE}"
119105
cat "${BUILD_ENV_FILE}"
120106
echo "BUILD_ENV_FILE=${BUILD_ENV_FILE}" >> "${GITHUB_ENV}"
121-
- name: Setup conda environment for build
107+
108+
- name: Setup uv environment for build
122109
shell: bash -l {0}
123110
env:
124111
PYTHON_VERSION: ${{ inputs.python-version }}
125112
run: |
126113
set -euxo pipefail
127-
CONDA_ENV="${RUNNER_TEMP}/conda_environment_${GITHUB_RUN_ID}"
128-
export CONDA_EXTRA_PARAM=""
129-
130-
if [[ "${PYTHON_VERSION:-}" == "3.13t" ]]; then
131-
export PYTHON_VERSION=3.13
132-
export CONDA_EXTRA_PARAM=" python-freethreading -c conda-forge"
133-
134-
# downgrade conda version for python 3.13t install.
135-
# TODO: remove this once python 3.13t is fully supported on conda
136-
# Please see : https://github.com/conda/conda/issues/14554
137-
if [[ "$(uname)" == Darwin ]]; then
138-
# required to be able to downgrade on MacOS arm64
139-
conda install -y python=3.9
140-
if [[ -n "$(conda list | grep conda-anaconda-telemetry)" ]]; then
141-
conda uninstall -y conda-anaconda-telemetry conda-anaconda-tos
142-
fi
143-
fi
144-
conda install -y conda=24.7.1 conda-libmamba-solver=24.1.0
145-
fi
146-
147-
conda create \
148-
--yes --quiet \
149-
--prefix "${CONDA_ENV}" \
150-
"python=${PYTHON_VERSION}" \
151-
cmake=3.31.2 \
152-
ninja=1.12.1 \
153-
pkg-config=0.29 \
154-
wheel=0.37 \
155-
${CONDA_EXTRA_PARAM}
156114
157-
echo "CONDA_ENV=${CONDA_ENV}" >> "${GITHUB_ENV}"
158-
echo "CONDA_RUN=conda run -p ${CONDA_ENV}" >> "${GITHUB_ENV}"
115+
uv venv py${PYTHON_VERSION} --python ${PYTHON_VERSION}
116+
source ./py${PYTHON_VERSION}/bin/activate
117+
uv pip install cmake==3.31.2 ninja wheel==0.37

.github/workflows/build_wheels_linux.yml

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ jobs:
216216
# shellcheck disable=SC1090
217217
source "${BUILD_ENV_FILE}"
218218
# shellcheck disable=SC2086
219-
${CONDA_RUN} ${PIP_INSTALL_TORCH} ${{ inputs.pip-install-torch-extra-args }}
219+
uv ${PIP_INSTALL_TORCH} ${{ inputs.pip-install-torch-extra-args }}
220220
- name: Run Pre-Script with Caching
221221
if: ${{ inputs.pre-script != '' }}
222222
uses: ./test-infra/.github/actions/run-script-with-cache
@@ -232,8 +232,8 @@ jobs:
232232
run: |
233233
set -euxo pipefail
234234
source "${BUILD_ENV_FILE}"
235-
export PYTORCH_VERSION="$(${CONDA_RUN} pip show torch | grep ^Version: | sed 's/Version: *//' | sed 's/+.\+//')"
236-
${CONDA_RUN} python -m pip install build==1.2.2
235+
export PYTORCH_VERSION="$(uv pip show torch | grep ^Version: | sed 's/Version: *//' | sed 's/+.\+//')"
236+
uv python -m pip install build==1.2.2
237237
echo "Successfully installed Python build package"
238238
${CONDA_RUN} ${{ inputs.build-command }}
239239
- name: Build the wheel (setup-py)
@@ -243,10 +243,10 @@ jobs:
243243
run: |
244244
set -euxo pipefail
245245
source "${BUILD_ENV_FILE}"
246-
export PYTORCH_VERSION="$(${CONDA_RUN} pip show torch | grep ^Version: | sed 's/Version: *//' | sed 's/+.\+//')"
247-
${CONDA_RUN} python setup.py clean
246+
export PYTORCH_VERSION="$(uv pip show torch | grep ^Version: | sed 's/Version: *//' | sed 's/+.\+//')"
247+
uv python setup.py clean
248248
echo "Successfully ran `python setup.py clean`"
249-
${CONDA_RUN} python setup.py bdist_wheel
249+
uv python setup.py bdist_wheel
250250
- name: Repair Manylinux_2_28 Wheel
251251
shell: bash -l {0}
252252
env:
@@ -280,7 +280,7 @@ jobs:
280280
WHEEL_NAME=$(ls "${{ inputs.repository }}/dist/")
281281
echo "$WHEEL_NAME"
282282
283-
${CONDA_RUN} pip install "${{ inputs.repository }}/dist/$WHEEL_NAME"
283+
uv pip install "${{ inputs.repository }}/dist/$WHEEL_NAME"
284284
# Checking that we have a pinned version of torch in our dependency tree
285285
(
286286
pushd "${RUNNER_TEMP}"
@@ -295,13 +295,13 @@ jobs:
295295
# Special case for torchrec temporarily since __version__ does not
296296
# work correctly on main in torchrec. This block will be
297297
# removed once we fix it.
298-
${CONDA_RUN} python -c "import ${PACKAGE_NAME}"
298+
uv python -c "import ${PACKAGE_NAME}"
299299
else
300-
${CONDA_RUN} python -c "import ${PACKAGE_NAME}; print('package version is ', ${PACKAGE_NAME}.__version__)"
300+
uv python -c "import ${PACKAGE_NAME}; print('package version is ', ${PACKAGE_NAME}.__version__)"
301301
fi
302302
else
303303
echo "${{ inputs.repository }}/${SMOKE_TEST_SCRIPT} found"
304-
${CONDA_RUN} python "${{ inputs.repository }}/${SMOKE_TEST_SCRIPT}"
304+
uv python "${{ inputs.repository }}/${SMOKE_TEST_SCRIPT}"
305305
fi
306306
# NB: Only upload to GitHub after passing smoke tests
307307

0 commit comments

Comments
 (0)