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

With declarative config, error "Distribution contains no modules or packages for namespace package" #1494

Closed
jaraco opened this Issue Sep 17, 2018 · 9 comments

Comments

Projects
None yet
3 participants
@jaraco
Copy link
Member

jaraco commented Sep 17, 2018

Attempting to use declarative config for jaraco.itertools, I ran the tests here, and everything looks good except if you inspect the environment, a crucial file is missing, the site-packages/jaraco.itertools-nspkg.pth file.

I tried restoring the namespace package functionality in jaraco/jaraco.itertools@c436dff, but that resulted in this error during the build:

cmdargs: ['/Users/jaraco/code/main/jaraco.itertools/.tox/python/bin/python', '-m', 'pip', 'install', '-e', '/Users/jaraco/code/main/jaraco.itertools[testing]']

Obtaining file:///Users/jaraco/code/main/jaraco.itertools
  Installing build dependencies: started
  Installing build dependencies: finished with status 'done'
    Complete output from command python setup.py egg_info:
    error in setup command: Distribution contains no modules or packages for namespace package 'jaraco'

I suspect a race condition where the packages discovered by packages= find: aren't found until after namespace_packages is processed. I suspect the solution is to add support for namespace_packages in declarative config.

@jaraco jaraco changed the title With declarative config, "Distribution contains no modules or packages for namespace package With declarative config, error "Distribution contains no modules or packages for namespace package" Sep 17, 2018

@pganssle

This comment has been minimized.

Copy link
Member

pganssle commented Oct 25, 2018

A race condition? Are we doing this stuff in parallel, or do you just mean that the order is not fixed and sometimes they happen in the wrong order?

@jaraco

This comment has been minimized.

Copy link
Member Author

jaraco commented Oct 27, 2018

@pganssle This issue is the main issue I'd like to work on this weekend. In my estimation, it's a major blocker to me converting dozens of projects to declarative config. Probably I was mistaken with "race condition" and it's just an "order of operations" issue. I'll investigate.

@jaraco jaraco self-assigned this Oct 27, 2018

@jaraco

This comment has been minimized.

Copy link
Member Author

jaraco commented Oct 27, 2018

@jpurviance - this is the ticket we discussed. Love any effort on it!

@jaraco

This comment has been minimized.

Copy link
Member Author

jaraco commented Oct 27, 2018

Here's the guide.

@jpurviance

This comment has been minimized.

Copy link

jpurviance commented Oct 27, 2018

I am not able to replicate this problem.

interpreter:

(jaraco-venv) John@172-2-1-30 ~/jaraco/jaraco.itertools (master) $ python --version
Python 2.7.15

setuptools:

(jaraco-venv) John@172-2-1-30 ~ $ python -m easy_install --version
setuptools 40.5.0 from /Users/John/pypa/jaraco-venv/lib/python2.7/site-packages (Python 2.7)

I am able to install with the namespace defined in the setup.cfg and setup.py
I ran this install command for both with a clean virtualenv:

(jaraco-venv) John@172-2-1-30 ~/jaraco/jaraco.itertools (master) $ python -m pip install -e .

setup.py:

params = dict(
	name=name,
	use_scm_version=True,
	author="Jason R. Coombs",
	author_email="jaraco@jaraco.com",
	description=description or name,
	url="https://github.com/jaraco/" + name,
	packages=setuptools.find_packages(),
	include_package_data=True,
	namespace_packages=(
		name.split('.')[:-1] if nspkg_technique == 'managed'
		else []
	),
...

and

setup.cfg:

[aliases]
dists = clean --all sdist bdist_wheel

[bdist_wheel]
universal = 1

[metadata]
license_file = LICENSE
long_description = file:README.rst
namespace_packages='jaraco'

interpreter:

(jaraco-venv) John@172-2-1-30 ~/jaraco/jaraco.itertools (master) $ python
Python 2.7.15 (default, Oct  2 2018, 11:42:04)
[GCC 4.2.1 Compatible Apple LLVM 10.0.0 (clang-1000.11.45.2)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from jaraco import itertools
>>> exit()

jaraco added a commit to jaraco/jaraco.itertools that referenced this issue Oct 28, 2018

@jaraco

This comment has been minimized.

Copy link
Member Author

jaraco commented Oct 28, 2018

Okay. Thanks to your investigation @jpurviance , I've backed off much of the other changes from that branch and made two commits that now reliably replicate the issue. In addition to the change above, there's one other change that has to be made to trigger the failure.

jaraco added a commit to pypa/setuptools-issue1494 that referenced this issue Oct 28, 2018

@jaraco

This comment has been minimized.

Copy link
Member Author

jaraco commented Oct 28, 2018

@jaraco

This comment has been minimized.

Copy link
Member Author

jaraco commented Oct 28, 2018

Oh, this is interesting. I put a debug breakpoint in dist.py:496, saving the configuration, and found this result:

setuptools-issue1494 master $ python setup.py bdist_wheel
> /Users/jaraco/m/setuptools/setuptools/dist.py(498)parse_config_files()
-> self._finalize_requires()
(Pdb) res
(<setuptools.config.ConfigMetadataHandler object at 0x10f12e908>, <setuptools.config.ConfigOptionsHandler object at 0x10f12e4a8>)
(Pdb) meta, opts = res
(Pdb) opts.sections
{'': {'packages': ('setup.cfg', 'find:')}}
(Pdb) meta.sections
{'': {'namespace_packages': ('setup.cfg', 'myns')}}
@jaraco

This comment has been minimized.

Copy link
Member Author

jaraco commented Oct 28, 2018

Aha!

So that PDB result is in fact useful. It indicates that the namespace_packages is appearing in meta, but when looking at the code or the docs, it's clear that namespace_packages belongs in [options] and not [metadata].

So this issue is twofold:

  1. PEBCAK - I should have noticed the value was in the wrong section.
  2. Setuptools should maybe raise warnings if unexpected options are present in a particular section. I'll explore that in another ticket.

For this ticket, the solution is for namespace packages to use the correct option and not declare it imperatively.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.