From 1d30b58cba83ea03c1e81d20c8c077467983d769 Mon Sep 17 00:00:00 2001 From: Logan Adams <114770087+loadams@users.noreply.github.com> Date: Mon, 24 Feb 2025 12:40:24 -0800 Subject: [PATCH] Replace calls to `python setup.py sdist` with `python -m build --sdist` (#7069) With future changes coming to pip/python/etc, we need to modify to no longer call `python setup.py ...` and replace it instead: https://packaging.python.org/en/latest/guides/modernize-setup-py-project/#should-setup-py-be-deleted ![image](https://github.com/user-attachments/assets/ea39ef7b-3cbe-4916-86f0-bc46a5fce96d) This means we need to install the build package which is added here as well. Additionally, we pass the `--sdist` flag to only build the sdist rather than the wheel as well here. --------- Signed-off-by: Logan Adams --- .github/workflows/no-torch.yml | 3 ++- .github/workflows/release.yml | 3 ++- build_win.bat | 2 +- docs/_tutorials/advanced-install.md | 2 +- docs/_tutorials/ds-sequence.md | 2 +- install.sh | 2 +- release/release.sh | 2 +- setup.py | 2 +- 8 files changed, 10 insertions(+), 8 deletions(-) diff --git a/.github/workflows/no-torch.yml b/.github/workflows/no-torch.yml index 5b89a6f36..75c4ecb85 100644 --- a/.github/workflows/no-torch.yml +++ b/.github/workflows/no-torch.yml @@ -32,11 +32,12 @@ jobs: run: | pip uninstall torch --yes pip install setuptools + pip install build pip list - name: Build deepspeed run: | - DS_BUILD_STRING=" " python setup.py sdist + DS_BUILD_STRING=" " python -m build --sdist - name: Open GitHub issue if nightly CI fails if: ${{ failure() && (github.event_name == 'schedule') }} diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index b2ccca69d..4bddbc26b 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -26,7 +26,8 @@ jobs: - name: Build DeepSpeed run: | pip install setuptools - DS_BUILD_STRING=" " python setup.py sdist + pip install build + DS_BUILD_STRING=" " python -m build --sdist - name: Publish to PyPI uses: pypa/gh-action-pypi-publish@release/v1 with: diff --git a/build_win.bat b/build_win.bat index 813874719..627694dbe 100644 --- a/build_win.bat +++ b/build_win.bat @@ -11,6 +11,6 @@ set DS_BUILD_GDS=0 set DS_BUILD_RAGGED_DEVICE_OPS=0 set DS_BUILD_SPARSE_ATTN=0 -python setup.py bdist_wheel +python -m build --wheel --no-isolation :end diff --git a/docs/_tutorials/advanced-install.md b/docs/_tutorials/advanced-install.md index d01378484..b251485f8 100755 --- a/docs/_tutorials/advanced-install.md +++ b/docs/_tutorials/advanced-install.md @@ -84,7 +84,7 @@ This should complete the full build 2-3 times faster. You can adjust `-j` to spe You can also build a binary wheel and install it on multiple machines that have the same type of GPUs and the same software environment (CUDA toolkit, PyTorch, Python, etc.) ```bash -DS_BUILD_OPS=1 python setup.py build_ext -j8 bdist_wheel +DS_BUILD_OPS=1 python -m build --wheel --no-isolation --config-setting="--build-option=build_ext" --config-setting="--build-option=-j8" ``` This will create a pypi binary wheel under `dist`, e.g., ``dist/deepspeed-0.3.13+8cd046f-cp38-cp38-linux_x86_64.whl`` and then you can install it directly on multiple machines, in our example: diff --git a/docs/_tutorials/ds-sequence.md b/docs/_tutorials/ds-sequence.md index 7a6041f39..41a76b784 100755 --- a/docs/_tutorials/ds-sequence.md +++ b/docs/_tutorials/ds-sequence.md @@ -111,7 +111,7 @@ pip install . cd ${WORK_DIR} git clone -b v1.0.4 https://github.com/HazyResearch/flash-attention cd flash-attention -python setup.py install +python -m pip install . ``` You may also want to ensure your model configuration is compliant with FlashAttention's requirements. For instance, to achieve optimal performance, the head size should be divisible by 8. Refer to the FlashAttention documentation for more details. diff --git a/install.sh b/install.sh index 8d56afe40..8be574c6e 100755 --- a/install.sh +++ b/install.sh @@ -152,7 +152,7 @@ if [ ! -f $hostfile ]; then fi echo "Building deepspeed wheel" -python setup.py $VERBOSE bdist_wheel +python -m build $VERBOSE --wheel --no-isolation if [ "$local_only" == "1" ]; then echo "Installing deepspeed" diff --git a/release/release.sh b/release/release.sh index a83fafcb9..cc3ee2fea 100644 --- a/release/release.sh +++ b/release/release.sh @@ -38,7 +38,7 @@ if [ $? != 0 ]; then exit 1 fi -DS_BUILD_STRING="" python setup.py sdist +DS_BUILD_STRING="" python -m build --sdist if [ ! -f dist/deepspeed-${version}.tar.gz ]; then echo "prepared version does not match version given ($version), bump version first?" diff --git a/setup.py b/setup.py index 6dc9afb8f..0ad54bb99 100755 --- a/setup.py +++ b/setup.py @@ -233,7 +233,7 @@ if sys.platform == "win32": version_str = open('version.txt', 'r').read().strip() # Build specifiers like .devX can be added at install time. Otherwise, add the git hash. -# Example: DS_BUILD_STRING=".dev20201022" python setup.py sdist bdist_wheel. +# Example: `DS_BUILD_STRING=".dev20201022" python -m build --no-isolation`. # Building wheel for distribution, update version file. if is_env_set('DS_BUILD_STRING'):