Skip to content

Commit 7fbb868

Browse files
Modernize build commands for setuptools 80+ compatibility
Replace deprecated setup.py develop commands with modern pip equivalents: - Replace 'setup.py develop --uninstall' with 'pip uninstall -y monai' - Replace 'setup.py develop' with 'pip install -e .' - Remove setuptools upper bound for Python 3.12+ (previously <=79.0.1) - Add BUILD_MONAI=1 explicitly in compile_cpp to ensure C++/CUDA extensions build - Remove --user flag from editable installs for virtualenv compatibility In setuptools 80+, the 'setup.py develop --uninstall' command was removed as part of PEP 660 modernization. The build system now delegates to pip for all installation and uninstallation operations. When using 'pip install -e .', the BUILD_MONAI environment variable must be set explicitly to trigger C++/CUDA compilation, as it's not automatically inherited due to pip's build isolation. The --user flag is removed from editable installs because it breaks inside virtualenvs (the modern development standard). Without --user, pip installs into the active virtualenv when present, or prompts for sudo when needed. Changes made: - runtests.sh: Updated compile_cpp() and clean_py() to use pip commands, set BUILD_MONAI=1 explicitly, and removed --user flag - requirements-min.txt: Removed setuptools <=79.0.1 upper bound for Python 3.12+ - docs/source/installation.md: Updated editable installation examples - .github/workflows/pythonapp.yml: Updated CI workflow to use pip commands Fixes #8439 Signed-off-by: Mohamed Salah <eng.mohamed.tawab@gmail.com>
1 parent b106a4c commit 7fbb868

File tree

4 files changed

+12
-12
lines changed

4 files changed

+12
-12
lines changed

.github/workflows/pythonapp.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,8 @@ jobs:
9191
shell: bash
9292
- name: Run compiled (${{ runner.os }})
9393
run: |
94-
python setup.py develop --uninstall
95-
BUILD_MONAI=1 python setup.py develop # compile the cpp extensions
94+
python -m pip uninstall -y monai
95+
BUILD_MONAI=1 python -m pip install -e . # compile the cpp extensions
9696
shell: bash
9797
- name: Run quick tests (CPU ${{ runner.os }})
9898
run: |

docs/source/installation.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -135,23 +135,23 @@ You can install it by running:
135135

136136
```bash
137137
cd MONAI/
138-
python setup.py develop
138+
pip install -e .
139139
```
140140

141141
or, to build with MONAI C++/CUDA extensions and install:
142142

143143
```bash
144144
cd MONAI/
145-
BUILD_MONAI=1 python setup.py develop
145+
BUILD_MONAI=1 pip install -e .
146146
# for MacOS
147-
BUILD_MONAI=1 CC=clang CXX=clang++ python setup.py develop
147+
BUILD_MONAI=1 CC=clang CXX=clang++ pip install -e .
148148
```
149149

150150
To uninstall the package please run:
151151

152152
```bash
153153
cd MONAI/
154-
python setup.py develop --uninstall
154+
pip uninstall -y monai
155155

156156
# to further clean up the MONAI/ folder (Bash script)
157157
./runtests.sh --clean

requirements-min.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Requirements for minimal tests
22
-r requirements.txt
33
setuptools>=50.3.0,<66.0.0,!=60.6.0 ; python_version < "3.12"
4-
setuptools>=70.2.0,<=79.0.1; python_version >= "3.12"
4+
setuptools>=70.2.0; python_version >= "3.12"
55
coverage>=5.5
66
parameterized
77
packaging

runtests.sh

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ function print_usage {
7373
echo "./runtests.sh -f # run coding style and static type checking."
7474
echo "./runtests.sh --quick --unittests # run minimal unit tests, for quick verification during code developments."
7575
echo "./runtests.sh --autofix # run automatic code formatting using \"isort\" and \"black\"."
76-
echo "./runtests.sh --clean # clean up temporary files and run \"${PY_EXE} setup.py develop --uninstall\"."
76+
echo "./runtests.sh --clean # clean up temporary files and uninstall MONAI development package."
7777
echo "./runtests.sh --formatfix -p /my/code # run automatic code formatting using \"isort\" and \"black\" in specified path."
7878
echo ""
7979
echo "Code style check options:"
@@ -143,12 +143,12 @@ function compile_cpp {
143143
echo "Compiling and installing MONAI cpp extensions..."
144144
# depends on setup.py behaviour for building
145145
# currently setup.py uses environment variables: BUILD_MONAI and FORCE_CUDA
146-
${cmdPrefix}"${PY_EXE}" setup.py develop --user --uninstall
146+
${cmdPrefix}"${PY_EXE}" -m pip uninstall -y monai
147147
if [[ "$OSTYPE" == "darwin"* ]];
148148
then # clang for mac os
149-
CC=clang CXX=clang++ ${cmdPrefix}"${PY_EXE}" setup.py develop --user
149+
BUILD_MONAI=1 CC=clang CXX=clang++ ${cmdPrefix}"${PY_EXE}" -m pip install -e .
150150
else
151-
${cmdPrefix}"${PY_EXE}" setup.py develop --user
151+
BUILD_MONAI=1 ${cmdPrefix}"${PY_EXE}" -m pip install -e .
152152
fi
153153
}
154154

@@ -179,7 +179,7 @@ function clean_py {
179179

180180
# uninstall the development package
181181
echo "Uninstalling MONAI development files..."
182-
${cmdPrefix}"${PY_EXE}" setup.py develop --user --uninstall
182+
${cmdPrefix}"${PY_EXE}" -m pip uninstall -y monai
183183

184184
# remove temporary files (in the directory of this script)
185185
TO_CLEAN="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"

0 commit comments

Comments
 (0)