matplotlib does pull in setuptools as a runtime dependency.
if setuptools is installed it uses the pkg_resources to look for resources.
Is this on purpose? The code in the setup.py apears to me to mean that the dependency should not be a dependency for production packages, or am i wrong?
I would like to get rid of this dependency.
Proposed fix
If possible the nicest solution would be to just drop the dependency.
I am unsure if there is really a use case for setuptools_scm at runtime (as opposed to setup time).
I second this. setuptools-scm being installed on your system will affect other packages being built. The check that .git directory exists to decide on the pull in as an install requirement is wrong.
Either setup.py needs to be changed - our when building packages in your CI - you must remove the .git directory.
I am sold on the wheels not depending on setuptools-scm as a matter of principle, but if it being installed or not is breaking other packages for you @epeisach my knee-jerk reaction is that there are bugs in the other packages!
try:
fromsetuptools_scmimportget_versionreturnget_version(root='../..', relative_to=__file__,
version_scheme='post-release')
except (ImportError, LookupError):
try:
fromimportlib.metadataimportPackageNotFoundError, versionexceptImportError: # Can remove when we require Python > 3.7fromimportlib_metadataimportPackageNotFoundError, versiontry:
returnversion(__package__)
exceptPackageNotFoundError:
return'Unknown'
and avoid polluting install_requires. I've also moved as much as possible to put metadata in setup.cfg, so I don't even have the option for this IMO anti-pattern of running code to determine install_requires.
I still have setuptools-scm as a dep of matplotlib 3.8.0 in my lock file. Can you help me debug please? I see that it's in the requires_dist on PyPi: https://pypi.org/pypi/matplotlib/3.8.0/json. Aren't you pushing the lib to PyPi as a wheel?
TLDR is that setuptools changed their sdist metadata generation, so while the wheels don't report that dependency the sdist (and thus pypi) report it. Will be fixed for 3.8.1
changed the title [-][MNT]: wheel of 3.5.0 apears to depend on setuptools-scm which apears to be unintentional[/-][+][MNT]: wheel of 3.5.0 appears to depend on setuptools-scm which appears to be unintentional[/+]on Jun 23, 2025
Activity
epeisach commented on Nov 29, 2021
I second this. setuptools-scm being installed on your system will affect other packages being built. The check that .git directory exists to decide on the pull in as an install requirement is wrong.
Either setup.py needs to be changed - our when building packages in your CI - you must remove the .git directory.
tacaswell commented on Nov 30, 2021
I am sold on the wheels not depending on setuptools-scm as a matter of principle, but if it being installed or not is breaking other packages for you @epeisach my knee-jerk reaction is that there are bugs in the other packages!
dopplershift commented on Nov 30, 2021
setuptools_scm should only ever be a dependency of building the wheels, not runtime. @tacaswell I think this is a little suspect:
matplotlib/setup.py
Lines 315 to 328 in d536acf
Do you remember why that install_requires portion was added?
tacaswell commented on Nov 30, 2021
Because we have
matplotlib/lib/matplotlib/__init__.py
Lines 167 to 174 in d536acf
dopplershift commented on Nov 30, 2021
In MetPy I chose to go with:
and avoid polluting install_requires. I've also moved as much as possible to put metadata in setup.cfg, so I don't even have the option for this IMO anti-pattern of running code to determine install_requires.
Drop setuptools-scm requirement in wheels
Drop setuptools-scm requirement in wheels
QuLogic commented on Nov 30, 2021
I suggest we do that for 3.6.0, and do the minimal patching in the above PR for 3.5.1.
pcorpet commented on Oct 9, 2023
I still have setuptools-scm as a dep of matplotlib 3.8.0 in my lock file. Can you help me debug please? I see that it's in the requires_dist on PyPi: https://pypi.org/pypi/matplotlib/3.8.0/json. Aren't you pushing the lib to PyPi as a wheel?
ksunden commented on Oct 9, 2023
@pcorpet see #26932
TLDR is that setuptools changed their sdist metadata generation, so while the wheels don't report that dependency the sdist (and thus pypi) report it. Will be fixed for 3.8.1