find_py_modules?
See original GitHub issueAFAICT, there is no find_py_modules()
function that could be used as value to setup(py_modules=...)
, similarly to how one can use setup(packages=find_packages())
.
Such a function would be a useful addition, providing benefits similar to find_packages()
.
Issue Analytics
- State:
- Created 5 years ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
modulefinder — Find modules used by a script ... - Python Docs
Source code: Lib/modulefinder.py This module provides a ModuleFinder class that can be used to determine the set of modules imported by a script....
Read more >11.1. Finding Modules | Chapter 11. Extending and ... - Drupal
Filter your search using the categories on the module search page. Fill in the fields as shown below. Field name, Explanation · Click...
Read more >How to locate a particular module in Python? - GeeksforGeeks
In this article, we will see how to locate a particular module in Python. Locating a module means finding the directory from which...
Read more >Find and use installed modules in a (sub)category - MetaCPAN
Module ::Find lets you find and use modules in categories. This can be very useful for auto-detecting driver or plugin modules. You can...
Read more >ansible.builtin.find module – Return a list of files based on ...
In most cases, you can use the short module name find even without specifying the collections: keyword. However, we recommend you use the...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Ah, no, I meant the opposite.
py_modules
is for when your source tree is basically a single Python file. There are no submodules, and if you’re doing things right, it’s a 1-element list. In such a simple module, you don’t need a function to find all the files that you want to package up, because the list is and always will be one item (once you get to 2 items, you need to refactor into a module with an__init__.py
, because now you have to have submodules). It’s not that it’s too hard to write (though making a perfectly general version of this that does the right thing might be hard), it’s that it’s unnecessary because this is not something that needs to be done programmatically.In my opinion, ideally you also wouldn’t need
find_packages
, since most people just want to use their folder structure as the module structure unchanged (like it is if you import from the module when your CWD is at the base of the repo and you aren’t using thesrc
layout), but that has its own problems (for example many modules put atests
submodule that isn’t shipped with the package, which is also an anti-pattern in my opinion), and in any case it would be a major backwards-incompatible change.We can leave the ticket open for a bit so other people can weigh in, but I’m definitely -1 on this idea. The only realistic use case would be an anti-pattern, and it has the potential to cause a lot of problems if used incorrectly (and most people will just guess how it’s supposed to be used based on the name, not look up the documentation on it).
I don’t think it makes sense to do that. I personally find
find_packages
very dangerous, but it’s necessary because you need to specify all modules and submodules for your package. The fact that you can have modules nested under other modules is why it’s necessary to have a function that recursively finds modules.py_modules
is for python files that are themselves modules. In general, the best practice would be to have exactly one of these, and it’s very likely that you have other.py
files in your root directory that are not intended to be used as modules, sofind_py_modules
would be even more dangerous thanfind_packages
but with none of the benefits.That said, do you have a specific use case in mind?