pytest-dev / pytest-runner

MIT License
56 stars 21 forks source link

Using setup_requires(['pytest-runner']) gives pkg_resources.DistributionNotFound: The 'pytest-runner' distribution was not found and is required by the application #48

Closed Alphadelta14 closed 5 years ago

Alphadelta14 commented 5 years ago

We have a simple local package that uses setup_requires(['pytest-runner']) and it has started to fail installation as of the 4.5 release of this package.

Collecting {internal tool}
  Downloading {internal repo}
    Complete output from command python setup.py egg_info:
    {virtualenv}/lib/python2.7/distutils/dist.py:267: UserWarning: Unknown distribution option: 'use_scm_version'
      warnings.warn(msg)
    warning: install_lib: 'build/lib' does not exist -- no Python modules to install

    zip_safe flag not set; analyzing archive contents...

    Installed /tmp/pip-install-mWRuOe/{internal tool}/.eggs/UNKNOWN-0.0.0-py2.7.egg
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/tmp/pip-install-mWRuOe/{internal tool}/setup.py", line 65, in <module>
        '''
      File "{virtualenv}/lib/python2.7/distutils/core.py", line 111, in setup
        _setup_distribution = dist = klass(attrs)
      File "{virtualenv}/lib/python2.7/site-packages/setuptools/dist.py", line 315, in __init__
        self.fetch_build_eggs(attrs['setup_requires'])
      File "{virtualenv}/lib/python2.7/site-packages/setuptools/dist.py", line 361, in fetch_build_eggs
        replace_conflicting=True,
      File "{virtualenv}/lib/python2.7/site-packages/pkg_resources/__init__.py", line 853, in resolve
        raise DistributionNotFound(req, requirers)
    pkg_resources.DistributionNotFound: The 'pytest-runner' distribution was not found and is required by the application
jaraco commented 5 years ago

gah. This is another manifestation of #43. I had forgotten that master was intended for the 5.0 release... and there's a branch for the 4.x releases.

jaraco commented 5 years ago

pytest-runner 4.5.1 is releasing momentarily, essentially reverting the changes.

But have you noticed the warnings from pytest-runner 4.4? They should be emitting warnings that you need to pin to pytest-runner<5 or ensure you have a later setuptools installed. pytest-runner 5.0 will be released soon and it will have the same failure you encountered with 4.5.

jaraco commented 5 years ago

I've also deleted 4.5 from PyPI.

jaraco commented 5 years ago

Pytest-runner 5.0 is releasing today also - please update your projects.

Alphadelta14 commented 5 years ago

The issue seems to be with the fact that setuptools_scm is required to even load the declarative setuptools definition which defines to install setuptools_scm.

jaraco commented 5 years ago

The setuptools_scm is actually a red herring. The issue would happen with or without setuptools_scm. The issue is the package is defined using declarative config, a feature added in setuptools 30.4, in which the name of the package is defined not in setup.py but in setup.cfg. Without declarative config support, the package has no name and so after easy_install builds the egg from the sdist, it goes to check what version of pytest-runner was installed but finds that no version of it was installed (because UNKNOWN was installed instead).