pytest-dev / pytest-runner

MIT License
56 stars 21 forks source link

Using test=pytest in setup.cfg gives "ModuleNotFoundError: No module named 'ptr'" #44

Closed detly closed 5 years ago

detly commented 5 years ago

As of a few hours ago, when my CI runs my unit tests with python setup.py test using pytest-runner, I get a traceback (listed below the minimal example).

Here's how to reproduce it. In an empty directory:

Create setup.py:

from setuptools import setup

setup(
    name='PytestTest',
    python_requires='>=3.6',
    setup_requires=['pytest-runner'],
    tests_require=['pytest'],
)

Create setup.cfg:

[aliases]
test=pytest

Run the following in a clean virtualenv eg. using Virtualenvwrapper:

mktmpenv -p /usr/bin/python3
cd the_dir_you_were_just_in
python setup.py test

Traceback:

$ python setup.py test
Traceback (most recent call last):
  File "setup.py", line 6, in <module>
    setup_requires=['pytest-runner'],
  File "/home/mydomain.net/username/.virtualenvs/tmp-3c301df20ea12392/lib/python3.6/site-packages/setuptools/__init__.py", line 145, in setup
    return distutils.core.setup(**attrs)
  File "/usr/lib/python3.6/distutils/core.py", line 134, in setup
    ok = dist.parse_command_line()
  File "/home/mydomain.net/username/.virtualenvs/tmp-3c301df20ea12392/lib/python3.6/site-packages/setuptools/dist.py", line 710, in parse_command_line
    result = _Distribution.parse_command_line(self)
  File "/usr/lib/python3.6/distutils/dist.py", line 472, in parse_command_line
    args = self._parse_command_opts(parser, args)
  File "/home/mydomain.net/username/.virtualenvs/tmp-3c301df20ea12392/lib/python3.6/site-packages/setuptools/dist.py", line 1025, in _parse_command_opts
    nargs = _Distribution._parse_command_opts(self, parser, args)
  File "/usr/lib/python3.6/distutils/dist.py", line 528, in _parse_command_opts
    cmd_class = self.get_command_class(command)
  File "/home/mydomain.net/username/.virtualenvs/tmp-3c301df20ea12392/lib/python3.6/site-packages/setuptools/dist.py", line 845, in get_command_class
    self.cmdclass[command] = cmdclass = ep.load()
  File "/home/mydomain.net/username/.virtualenvs/tmp-3c301df20ea12392/lib/python3.6/site-packages/pkg_resources/__init__.py", line 2324, in load
    return self.resolve()
  File "/home/mydomain.net/username/.virtualenvs/tmp-3c301df20ea12392/lib/python3.6/site-packages/pkg_resources/__init__.py", line 2330, in resolve
    module = __import__(self.module_name, fromlist=['__name__'], level=0)
ModuleNotFoundError: No module named 'ptr'

Other info: OS is Ubuntu 18.04. Pytest is... I think whatever is on PyPI right now?

$ pip list
Package       Version
------------- -------
pip           19.0.2 
pkg-resources 0.0.0  
setuptools    40.8.0 

Caveat: I'm not 100% sure this is a Pytest issue and not a Setuptools issue. Happy to re-file over on Setuptools if I'm wrong.

lpsinger commented 5 years ago

Confirmed on our project.

jaraco commented 5 years ago

The issue here was a mistake in the 4.3 release where the ptr module was omitted from the declarative config. It should have been addressed by pulling the release (which was done for other reasons) and also by the subsequent 4.3.1 release. Please report back if the issue isn't solved.