Issue warnings for missing py_modules?
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 59
- Forks
- 94
- PR merge metrics
- No merged PRs in 30d
Description
Hello,
After more hours than I'd care to admit trying to figure out why setuptools was giving me a "no module found" error when using attr: in a config file, I finally tracked the issue down to a silly mistake: I'd specified py_modules instead of packages in the config file, and my code was in a package. The mistake stemmed from a copy-paste error: I'd copied an old configuration file because I didn't remember all the details of the format, and renamed things for my new project without remembering that py_modules would have to change to packages since the new project used a package (see https://github.com/pypa/setuptools/issues/3266).
The change I'd like to see it for the distutils code that checks modules to issue a warning when a listed module is not found, as opposed to silently ignoring this case, since that would have saved me a lot of time, and might also save time for others, on top of being quite reasonable behavior. The relevant code is lines 273-278 of command/build_py.py:
# XXX perhaps we should also check for just .pyc files
# (so greedy closed-source bastards can distribute Python
# modules too)
module_file = os.path.join(package_dir, module_base + ".py")
if not self.check_module(module, module_file):
continue
The equivalent code for finding packages raises an error on lines 189-195:
if not os.path.exists(package_dir):
raise DistutilsFileError(
"package directory '%s' does not exist" % package_dir)
if not os.path.isdir(package_dir):
raise DistutilsFileError(
"supposed package directory '%s' exists, "
"but is not a directory" % package_dir)
Since the comment in the modules code suggests the existence of .pyc files might be a reason for not being strict about modules existing, I think issuing a warning rather than an error is probably best to minimize what breaks. If this is something that maintainers here think is reasonable, I could put together a PR for raising a DistutilsFileWarning before continuing in the missing module case, which would include adding a DistutilsFileWarning class to errors.py.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in command/build_py.py around the module-checking code referenced in the issue, then inspect errors.py for the warning definitions. Done means a missing py_modules entry emits a DistutilsFileWarning instead of being silently ignored, while the existing continuation behavior remains intact.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- build-system
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 35/100