anymail / django-anymail

Django email backends and webhooks for Amazon SES, Brevo (Sendinblue), MailerSend, Mailgun, Mailjet, Postmark, Postal, Resend, SendGrid, SparkPost, Unisender Go and more
https://anymail.dev
BSD 3-Clause "New" or "Revised" License
1.7k stars 130 forks source link

"Package would be ignored" warnings from setuptools when building package #323

Closed kitterma closed 1 year ago

kitterma commented 1 year ago

Anymail 9.2 Setuptools 67.8.0 Python3 3.11.4

There are warnings for anymail.backends and anymail.webhooks:

/usr/lib/python3/dist-packages/setuptools/command/build_py.py:201: _Warning: Package 'anymail.backends' is absent from the `packages` configuration.
!!

        ********************************************************************************
        ############################
        # Package would be ignored #
        ############################
        Python recognizes 'anymail.backends' as an importable package[^1],
        but it is absent from setuptools' `packages` configuration.

        This leads to an ambiguous overall configuration. If you want to distribute this
        package, please make sure that 'anymail.backends' is explicitly added
        to the `packages` configuration field.

        Alternatively, you can also rely on setuptools' discovery methods
        (for example by using `find_namespace_packages(...)`/`find_namespace:`
        instead of `find_packages(...)`/`find:`).

        You can read more about "package discovery" on setuptools documentation page:

        - https://setuptools.pypa.io/en/latest/userguide/package_discovery.html

        If you don't want 'anymail.backends' to be distributed and are
        already explicitly excluding 'anymail.backends' via
        `find_namespace_packages(...)/find_namespace` or `find_packages(...)/find`,
        you can try to use `exclude_package_data`, or `include-package-data=False` in
        combination with a more fine grained `package-data` configuration.

        You can read more about "package data files" on setuptools documentation page:

        - https://setuptools.pypa.io/en/latest/userguide/datafiles.html

        [^1]: For Python, any directory (with suitable naming) can be imported,
              even if it does not contain any `.py` files.
              On the other hand, currently there is no concept of package data
              directory, all directories are treated like packages.
        ********************************************************************************

!!
  check.warn(importable)
/usr/lib/python3/dist-packages/setuptools/command/build_py.py:201: _Warning: Package 'anymail.webhooks' is absent from the `packages` configuration.
!!

        ********************************************************************************
        ############################
        # Package would be ignored #
        ############################
        Python recognizes 'anymail.webhooks' as an importable package[^1],
        but it is absent from setuptools' `packages` configuration.

        This leads to an ambiguous overall configuration. If you want to distribute this
        package, please make sure that 'anymail.webhooks' is explicitly added
        to the `packages` configuration field.

        Alternatively, you can also rely on setuptools' discovery methods
        (for example by using `find_namespace_packages(...)`/`find_namespace:`
        instead of `find_packages(...)`/`find:`).

        You can read more about "package discovery" on setuptools documentation page:

        - https://setuptools.pypa.io/en/latest/userguide/package_discovery.html

        If you don't want 'anymail.webhooks' to be distributed and are
        already explicitly excluding 'anymail.webhooks' via
        `find_namespace_packages(...)/find_namespace` or `find_packages(...)/find`,
        you can try to use `exclude_package_data`, or `include-package-data=False` in
        combination with a more fine grained `package-data` configuration.

        You can read more about "package data files" on setuptools documentation page:

        - https://setuptools.pypa.io/en/latest/userguide/datafiles.html

        [^1]: For Python, any directory (with suitable naming) can be imported,
              even if it does not contain any `.py` files.
              On the other hand, currently there is no concept of package data
              directory, all directories are treated like packages.
        ********************************************************************************

!!
  check.warn(importable)
medmunds commented 1 year ago

Thanks for the report.

This setuptools warning doesn't apply to Anymail v10.0 or later (which no longer uses setuptools). It also doesn't affect installing older versions of django-anymail from PyPI distributions (which wouldn't have passed pre-publishing tests if they were missing subpackages).

If you need to repeatably build your own django-anymail distribution pinned to older Anymail source, you should probably also pin an older version of setuptools known to be compatible. Despite the warning, the current setuptools 67.8.0 works: it includes the Anymail subpackages via MANIFEST.in, and you'll see them listed in the build output. I don't know what future version of setuptools might remove this. (PyPA projects sometimes include breaking changes in minor releases, so pinning an exact setuptools version would be safest.)

Again, Anymail v10.0 switched its build backend from setuptools to hatchling (and completely updated all of the packaging), so this warning doesn't apply to current code. But if we ever need to release a patch for Anymail v9.2.x or earlier, we may need to account for this—either by using an older setuptools for the Anymail build, or by updating Anymail's setup.py packages declaration.

I'm not sure there's anything to do in Anymail unless/until we're thinking about releasing a patch for an older version.

kitterma commented 1 year ago

As long as it's fixed in the next version (by not using setuptools) I'm happy. I wanted to make sure you knew.