pytest-dev/pytest-localserver

Add `version` to `setup.py`

mroeschke opened this issue · 9 comments

Thanks for the awesome plugin. Happy users over at pandas.

Currently when running pytest with pytest-localserver, the version information is not correct

plugins: hypothesis-6.88.4, cov-4.1.0, xdist-3.4.0, localserver-0.0.0

I think this is because the setup in setup.py doesn't contain version: https://pluggy.readthedocs.io/en/stable/_modules/pluggy/_manager.html#PluginManager.list_plugin_distinfo

Thanks for the report!

It's actually intentional that setup.py does not explicitly pass a version argument; the version is dynamically determined using setuptools_scm. That being said, the fact that the version info is not correctly reported by pytest is indeed a bug. I'll take a closer look at it soon (or you someone else can, if desired). I may need to ask you for more detailed reproduction instructions, so please keep an eye on this issue, but I'll give it a try first and see if I can reproduce this myself.

Information on the install method are needed

@diazona I would recommend to migrate to use pypropject.toml only

That way broken setup invocations tur unnecessary

At the same time numerous minimal versions in the project need upgrades

Yeah I've been meaning to do that for a while, just haven't had time yet. I figured it's low priority until we actually make the release.

We install pytest-localserver and pytest via conda-forge on Ubuntu:

https://github.com/pandas-dev/pandas/blob/main/ci/deps/actions-39.yaml#L14-L17
https://github.com/pandas-dev/pandas/actions/runs/6866131540/job/18671690428#step:6:340

Example pytest run from the log above

NPY_PROMOTION_STATE=legacy MESONPY_EDITABLE_VERBOSE=1 PYTHONDEVMODE=1 PYTHONWARNDEFAULTENCODING=1 pytest -r fEs -n 0 --dist=loadfile -s --cov=pandas --cov-report=xml --cov-append --cov-config=pyproject.toml pandas -m "single_cpu"
[1/1] Generating write_version_file with a custom command
+ /home/runner/micromamba/envs/test/bin/ninja
============================= test session starts ==============================
platform linux -- Python 3.10.13, pytest-7.4.3, pluggy-1.3.0
rootdir: /home/runner/work/pandas/pandas
configfile: pyproject.toml
plugins: hypothesis-6.88.4, cov-4.1.0, xdist-3.4.0, localserver-0.0.0
collected 228736 items / 225412 deselected / 3324 selected

Here's a fresh example from a Linux OS:

(base) ...$ mamba create -n pytest-repro python=3.10 pytest pytest-localserver

Looking for: ['python=3.10', 'pytest', 'pytest-localserver']
...
(base) ...$ conda activate pytest-repro
(pytest-repro) ...$ conda env list
# packages in environment at .../mambaforge/envs/pytest-repro:
#
# Name                    Version                   Build  Channel
_libgcc_mutex             0.1                 conda_forge    conda-forge
_openmp_mutex             4.5                       2_gnu    conda-forge
aiosmtpd                  1.4.4.post2     py310hff52083_1    conda-forge
atpublic                  3.0.1              pyhd8ed1ab_0    conda-forge
attrs                     23.1.0             pyh71513ae_1    conda-forge
bzip2                     1.0.8                hd590300_5    conda-forge
ca-certificates           2023.7.22            hbcca054_0    conda-forge
colorama                  0.4.6              pyhd8ed1ab_0    conda-forge
exceptiongroup            1.1.3              pyhd8ed1ab_0    conda-forge
iniconfig                 2.0.0              pyhd8ed1ab_0    conda-forge
ld_impl_linux-64          2.40                 h41732ed_0    conda-forge
libffi                    3.4.2                h7f98852_5    conda-forge
libgcc-ng                 13.2.0               h807b86a_3    conda-forge
libgomp                   13.2.0               h807b86a_3    conda-forge
libnsl                    2.0.1                hd590300_0    conda-forge
libsqlite                 3.44.0               h2797004_0    conda-forge
libuuid                   2.38.1               h0b41bf4_0    conda-forge
libzlib                   1.2.13               hd590300_5    conda-forge
markupsafe                2.1.3           py310h2372a71_1    conda-forge
ncurses                   6.4                  h59595ed_2    conda-forge
openssl                   3.1.4                hd590300_0    conda-forge
packaging                 23.2               pyhd8ed1ab_0    conda-forge
pip                       23.3.1             pyhd8ed1ab_0    conda-forge
pluggy                    1.3.0              pyhd8ed1ab_0    conda-forge
pytest                    7.4.3              pyhd8ed1ab_0    conda-forge
pytest-localserver        0.8.1              pyhd8ed1ab_0    conda-forge
python                    3.10.13         hd12c33a_0_cpython    conda-forge
python_abi                3.10                    4_cp310    conda-forge
readline                  8.2                  h8228510_1    conda-forge
setuptools                68.2.2             pyhd8ed1ab_0    conda-forge
tk                        8.6.13          noxft_h4845f30_101    conda-forge
tomli                     2.0.1              pyhd8ed1ab_0    conda-forge
tzdata                    2023c                h71feb2d_0    conda-forge
werkzeug                  3.0.1              pyhd8ed1ab_0    conda-forge
wheel                     0.41.3             pyhd8ed1ab_0    conda-forge
xz                        5.2.6                h166bdaf_0    conda-forge
(pytest-repro) ...$ echo "def test_example():" > test_file.py
(pytest-repro) ...$ echo "    pass" >> test_file.py
(pytest-repro) ...$ pytest test_file.py
============================================================================== test session starts ===============================================================================
platform linux -- Python 3.10.13, pytest-7.4.3, pluggy-1.3.0
rootdir: ...
plugins: localserver-0.0.0
collected 1 item                                                                                                                                                                 

test_file.py .                                                                                                                                                             [100%]

=============================================================================== 1 passed in 0.01s ================================================================================

I suppose the conda package is broken then

Seems likely, yeah... to check, I tried to reproduce this in a virtualenv, but it worked as expected:

$ python3.10 -m venv pytest-env-test
$ cd pytest-env-test && source bin/activate
$ python --version
Python 3.10.13
$ pip install pytest pytest-localserver
[...]
Successfully installed MarkupSafe-2.1.3 exceptiongroup-1.1.3 iniconfig-2.0.0 packaging-23.2 pluggy-1.3.0 pytest-7.4.3 pytest-localserver-0.8.1 tomli-2.0.1 werkzeug-3.0.1
$ pip freeze
exceptiongroup==1.1.3
iniconfig==2.0.0
MarkupSafe==2.1.3
packaging==23.2
pluggy==1.3.0
pytest==7.4.3
pytest-localserver==0.8.1
tomli==2.0.1
Werkzeug==3.0.1
$ cat test_file.py 
def test_example():
    pass
$ pytest test_file.py
=============================== test session starts ===============================
platform linux -- Python 3.10.13, pytest-7.4.3, pluggy-1.3.0
rootdir: /home/diazona/tmp/pytest-env-test
plugins: localserver-0.8.1
collected 1 item

test_file.py .                                                               [100%]

================================ 1 passed in 0.01s ================================

I also downloaded the conda package and noticed that it refers to 0.0.0 as the version number in several places. I don't actually know much (anything, really) about how Anaconda works, so I couldn't trace exactly where that version 0.0.0 comes from, but regardless it seems likely that it originates with the build process for the conda package. @nicoddemus may be able to offer further insight on that.

I'm going to close this for now since it's looking like a conda error and not something we can fix here. But feel free to reopen it if you (@mroeschke, or anyone) can reproduce the problem with pure Python-ecosystem tools (i.e. pip and virtualenvs), or if further investigation shows that we're doing something wrong in this package's source code that causes conda-build not to pick up the version number correctly.

ahh darn you Github close button 😠 😛