Skip to content
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

Building asteroids with bdist_apps and setuptools>=61 gives error #1394

Closed
rdb opened this issue Nov 16, 2022 · 5 comments
Closed

Building asteroids with bdist_apps and setuptools>=61 gives error #1394

rdb opened this issue Nov 16, 2022 · 5 comments
Labels
bug deployment Issues with setuptools based application deployment
Milestone

Comments

@rdb
Copy link
Member

rdb commented Nov 16, 2022

Description

Encountering this error:

error: Multiple top-level packages discovered in a flat-layout: ['models', 'textures'].

To avoid accidental inclusion of unwanted files or directories,
setuptools will not proceed with this build.

If you are trying to create a single distribution with multiple packages
on purpose, you should not rely on automatic discovery.
Instead, consider the following options:

1. set up custom discovery (`find` directive with `include` or `exclude`)
2. use a `src-layout`
3. explicitly set `py_modules` or `packages` with a list of names

To find more information, look for "package discovery" on setuptools docs.

Steps to Reproduce

Run ..\..\built_x64\python\python.exe setup.py bdist_apps with setuptools>=61.0.0

Known Workaround

Add py_modules=[] to the list of parameters in setup().

Environment

  • Operating system: Windows
  • System architecture: amd64
  • Panda3D version: 9508b04
  • Installation method: source
  • Python version (if using Python): 3.8
  • Compiler (if using C++): MSVC 2022
@rdb rdb added bug deployment Issues with setuptools based application deployment labels Nov 16, 2022
@rdb rdb added this to the 1.10.13 milestone Nov 16, 2022
@rdb
Copy link
Member Author

rdb commented Nov 19, 2022

This is due to pypa/setuptools#2887 and pypa/setuptools#2894 which introduce a mechanism to automatically populate py_modules/packages if they are absent in setup.py (which they are because we don't need them).

I have no idea why automatic discovery is taking place for custom commands, though. I think we have to set py_modules to an empty list, but the discovery is taking place before our custom command even gets to run. :-/

@rdb
Copy link
Member Author

rdb commented Nov 19, 2022

I see that py2app (which is a similar tool as ours) ran into the same issue: ronaldoussoren/py2app#414
In pypa/setuptools#3248 it was recommended to create a custom finalize_distribution_options entry point:
ronaldoussoren/py2app@55eb236
…but it feels very awkward. I am on the fence between that and just telling people to add py_modules=[] to their setup.py.

@abravalheri is there a more elegant way nowadays to disable auto-discovery in custom commands?

rdb added a commit that referenced this issue Nov 19, 2022
See #1394 - creates a new finalize_distribution_options entry point that makes sure that either `py_modules` or `packages` is present, otherwise setuptools  will activate its new auto-discovery system, even for custom commands that don't need setuptools' discovery system.

However, this is not a great solution, because it applies when running all setuptools commands, not just build_apps.
@abravalheri
Copy link

For a general package, if you are using setuptools but you don't want to setuptools to process any importable package or importable module, then you need to setup either packages or py_modules to prevent setuptools from running autodiscovery1.
This can also be done in setup.cfg or pyproject.toml (it does not have to be done in setup.py).

If you are working on a plugin that the most common use case is to have "package/module"-less builds and to ditch completely regular setuptools-builds... then the procedure followed by py2app may make sense (there is no right or wrong really, it depends on how the tool influences the end-user workflow).

Footnotes

  1. See PyPA glossary for exact definitions.

@rdb
Copy link
Member Author

rdb commented Nov 26, 2022

@abravalheri We have a plug-in that adds a custom command (build_apps) to setuptools. This custom command does not need the package discovery mechanism. So, having to tell our users that they need to update their setup.py to add a dummy py_modules in order to be able to use our plug-in is a nuisance.

The py2app approach works, but is imperfect: it is not limited in scope to the use of our custom command. So, it hinders users who do want to use package discovery when not using our custom command.

If there is really no other way, we will just stick with the py2app approach, and tell users that they can't use package discovery and our plug-in at the same time in their project.

But really, why is automatic package discovery not limited in effect to the standard build and related commands?

@rdb
Copy link
Member Author

rdb commented Dec 7, 2022

Closing for now since we have a workaround. If upstream has a better solution for us then we can integrate it, until then we'll just have to put a note in the manual.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug deployment Issues with setuptools based application deployment
Projects
None yet
Development

No branches or pull requests

2 participants