Skip to content

[MNT]: wheel of 3.5.0 apears to depend on setuptools-scm which apears to be unintentional #21783

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
franzhaas opened this issue Nov 28, 2021 · 8 comments · Fixed by #21820
Closed
Milestone

Comments

@franzhaas
Copy link

Summary

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).

Thansk for the great work!

@epeisach
Copy link

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
Copy link
Member

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
Copy link
Contributor

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

install_requires=[
"cycler>=0.10",
"fonttools>=4.22.0",
"kiwisolver>=1.0.1",
"numpy>=1.17",
"packaging>=20.0",
"pillow>=6.2.0",
"pyparsing>=2.2.1,<3.0.0",
"python-dateutil>=2.7",
] + (
# Installing from a git checkout.
["setuptools_scm>=4"] if Path(__file__).with_name(".git").exists()
else []
),

Do you remember why that install_requires portion was added?

@tacaswell
Copy link
Member

Because we have

if (root / ".git").exists() and not (root / ".git/shallow").exists():
import setuptools_scm
return setuptools_scm.get_version(
root=root,
version_scheme="release-branch-semver",
local_scheme="node-and-date",
fallback_version=_version.version,
)
in __init__.py to make the version auto-track in source installs (like we used to have with versioneer).

@dopplershift
Copy link
Contributor

dopplershift commented Nov 30, 2021

In MetPy I chose to go with:

    try:
        from setuptools_scm import get_version
        return get_version(root='../..', relative_to=__file__,
                           version_scheme='post-release')
    except (ImportError, LookupError):
        try:
            from importlib.metadata import PackageNotFoundError, version
        except ImportError:  # Can remove when we require Python > 3.7
            from importlib_metadata import PackageNotFoundError, version

        try:
            return version(__package__)
        except PackageNotFoundError:
            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.

QuLogic added a commit to QuLogic/matplotlib that referenced this issue Nov 30, 2021
QuLogic added a commit to QuLogic/matplotlib that referenced this issue Nov 30, 2021
@QuLogic
Copy link
Member

QuLogic commented 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.

@QuLogic QuLogic added this to the v3.5.1 milestone Dec 1, 2021
@pcorpet
Copy link

pcorpet commented 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
Copy link
Member

ksunden commented 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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants