Skip to content

Commit

Permalink
Replace calls to python setup.py sdist with `python -m build --sdis…
Browse files Browse the repository at this point in the history
…t` (#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 <[email protected]>
  • Loading branch information
loadams authored Feb 24, 2025
1 parent 4b7e2c9 commit 1d30b58
Show file tree
Hide file tree
Showing 8 changed files with 10 additions and 8 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/no-torch.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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') }}
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion build_win.bat
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion docs/_tutorials/advanced-install.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion docs/_tutorials/ds-sequence.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
2 changes: 1 addition & 1 deletion install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion release/release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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?"
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ def op_enabled(op_name):
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'):
Expand Down

0 comments on commit 1d30b58

Please sign in to comment.