pytest-dev / pluggy

A minimalist production ready plugin system
https://pluggy.readthedocs.io/en/latest/
MIT License
1.31k stars 126 forks source link

0.12 with importlib_metadata makes it impossible for me to run tests #221

Closed mguijarr closed 5 years ago

mguijarr commented 5 years ago

Hi all,

I made a StackOverflow issue for this one:

https://stackoverflow.com/questions/56491266/cannot-run-pytest-anymore-because-importlib-metadata-entry-points-fails-with-c

TL, DR: for some reason importlib_metadata cannot return entry points, aborting everything. The exact same project with pluggy==0.11 works fine.

nicoddemus commented 5 years ago

Hi @mguijarr,

Could you post step by step instructions on how to reproduce this?

mguijarr commented 5 years ago

Well, it is hard for me to understand what is going wrong.

My workflow is like this:

I didn't change anything. The problem comes from importlib_metadata, but I have no clue what I should change/what is wrong with my setup.py or whatever. Was working fine before.

I am sorry it is not really helpful, it probably comes from my project (?) but it is quite hard to debug, at least for me.

nicoddemus commented 5 years ago

I was asking for instructions along the lines:

$ git clone ...
$ cd ...
$ python3.7 -m venv .env37
$ pip install -e .
$ pytest ...

It might seem redundant to provide this, but this answers quite a few questions like which python version you are using, the project URL, which commands you execute that are causing the error, etc.

This all saves us time as we don't have to guess and ask follow up questions. 😁

cc @asottile as he is the expert regarding importlib-metadata. 👍

asottile commented 5 years ago

You have two copies of pytest or some pytest plugin installed (likely with one via easy-install). Try uninstalling each one three times (to make certain it is gone) with pip and then reinstalling

asottile commented 5 years ago

Or conda + pip, given it seems you're using that

mguijarr commented 5 years ago

I really appreciate your help guys.

@asottile hmm I have the same behaviour launching tests in a clean, empty Docker environment so I doubt there are multiple pytests. Removing pytest-cov and pytest-mock does not change anything. Uninstalling pytest then reinstalling it does not change anything neither.

Any other idea ?

asottile commented 5 years ago

can you show your reproduction of a clean docker environment?

asottile commented 5 years ago

or at least your full setup.py / setup.cfg?

mguijarr commented 5 years ago

@asottile sure... I would like to provide a stripped-down, minimal version to allow a fast and easier investigation but unfortunately it is not something I can do in 5 minutes so here is the complete thing as gitlab-ci is doing:

$ sudo docker run -it continuumio/miniconda3:latest
$ git clone https://gitlab.esrf.fr/bliss/bliss
$ cd bliss
$ conda config --env --add channels esrf-bcu; conda config --env --append channels conda-forge; conda config --env --append channels tango-controls
$ conda create --quiet --name testenv --file requirements-conda.txt --file requirements-test-conda.txt
$ source activate testenv
$ pip install .
$ pytest

Maybe you will see a lot of silly mistakes with setup.py or setup.cfg or whatever I am sorry.

asottile commented 5 years ago

awesome, let me take a look at that -- thanks for providing :)

asottile commented 5 years ago

interesting, it seems mad about these two lines, this is probably a bug with importlib-metadata:

[console_scripts]
Bliss = bliss.tango.servers.bliss_ds:main
...
bliss = bliss.shell.cli.main:main

this should be an easy fix to importlib-metadata: https://gitlab.com/python-devs/importlib_metadata/merge_requests/76

mguijarr commented 5 years ago

Thanks a lot !

asottile commented 5 years ago

closing since this is importlib-metadata territory -- thanks again for the report! glad we could get to the bottom of this and improve it for everyone :tada: