22

Every time I boot up terminal on VSCode, I get the following prompt. This does not happen on Terminal.app.

    /usr/local/lib/python3.9/site-packages/setuptools/command/install.py:34:
SetuptoolsDeprecationWarning: setup.py install is deprecated. Use build and pip
and other standards-based tools.

How do I resolve this?

xjcl
  • 12,848
  • 6
  • 67
  • 89
ric.row
  • 505
  • 1
  • 6
  • 18

7 Answers7

23

I assume you stumbled across this issue when you was building your .whl-file doing something like python Setup.py bdist_wheel --dist-dir .. (If not: This answer probably not applies to your problem.) The warning you see wants to say that calling python Setup.py ... is obsolete now.

Solution, in short:

Replace setup.py with pyproject.toml. In pyproject.toml you enter all values from setup.py in an INI-file-like-structure. Then you create your .whl-file using the command python -m build.

Further information about python-packages and pyproject.toml: https://packaging.python.org/en/latest/tutorials/packaging-projects/

Further information about how to use pyproject.toml using setuptools: https://setuptools.pypa.io/en/latest/userguide/pyproject_config.html

anion
  • 1,516
  • 1
  • 21
  • 35
22

Install the setuptools 58.2.0 version using the following command

pip install setuptools==58.2.0
JialeDu
  • 6,021
  • 2
  • 5
  • 24
  • 17
    I can confirm this works, but it would be nice to solve this issue even with using the latest version of setuptools (currently 65.5.0). So your answer seems to be a workaround, not a solution. – anion Oct 17 '22 at 21:09
  • 1
    this is helpful when I build ros2 on windows by `colcon build --merge-install` – Felix F Xu May 19 '23 at 08:17
4

Calling setup.py directly is being deprecated, as explained here.

I did as the message told me and now build the wheel using pip (it still calls setup.py internally):

pip wheel --no-deps -w dist .

This replaced my old equivalent code:

python setup.py bdist_wheel

Note that the pip wheel command creates the wheel into your current directory by default, which is why I specify -w/--wheel_dir to match the old behavior of using the ./dist directory.

I also specify --no-deps so pip does not download the wheel files of all dependencies.

xjcl
  • 12,848
  • 6
  • 67
  • 89
2

Upgrade the setuptools. The versions greater than 58.2.0 is not showing the deprecation warning as of Oct 18, 2022.

pip install -U setuptools

Note, there are many ways to package Python. You will want to evaluate where your target deployment is. Working with the TOML files is a trend that allows better integration with many software languages. Reference: Overview of Packaging for Python

zerocog
  • 1,703
  • 21
  • 32
2

You can use pip to install setup.py.

pip install .

This command assumes that you are in the root directory of the project where the setup.py file is located. The . specifies the current directory as the source for installation.

1

Install the setuptools 58.2.0 version using the following command

pip install setuptools==58.2.0

Don't upgrade the setuptools. Only the version 58.2.0 worked for me. Though I tried upgrading the version to 65.5.0 but it was showing the deprecation warning.

Mansi
  • 11
  • 3
  • 2
    This answer conflicts with another answer which states the newer versions no longer have the said warning. Either has to be corrected. Please consider providing link to resources or additional documentation to support your answer. – Azhar Khan Dec 17 '22 at 09:39
0

In addition to what JialeDu says here, also make sure that you use the build module (which you will need to install first) to build your project:

python -m build  # builds both sdist and wheel

You can read more in the official documentation:

https://setuptools.pypa.io/en/latest/deprecated/commands.html

While it is true that direct install via setup.py is deprecated because of disutils [source: https://docs.python.org/3/library/distutils.html], you can still use setup.py for packaging purposes. setuptools absorbed portions of the code it dependent on from disutils, and is still actively maintained on GitHub.

Stefan
  • 115
  • 2
  • 7