rstcheck / rstcheck-core

Core library behind rstcheck.
http://rstcheck-core.rtfd.io/
MIT License
4 stars 8 forks source link

[Bug]: rstcheck-core not reporting version correctly #72

Closed kynan closed 1 year ago

kynan commented 1 year ago

To Dos

Example Code (python)

# N/A

Relevant log output

N/A

Description

After installing rstcheck 6.1.2 and rstcheck-core 1.1.1 as a dependency, running pip check reports

rstcheck 6.1.2 has requirement rstcheck-core<2.0.0,>=1.0.2, but you have rstcheck-core 0.0.0.

And indeed importlib.metadata.version cannot determine the rstcheck-core version:

$ python -c "import importlib.metadata; print(importlib.metadata.version('rstcheck-core'))"
0.0.0

Operating System

Linux

Operating System Details

No response

Python Version

3.8

rstcheck Version

0.0.0 (but should report 1.1.1)

Additional Context

No response

Cielquan commented 1 year ago

This may be a regression from last release. I will take a look.

Cielquan commented 1 year ago

Unfortunately I cannot recreate your issue.

What I did on my linux maschine:

$ virtualenv .venv_test
created virtual environment CPython3.8.10.final.0-64 in 165ms
  creator CPython3Posix(dest=/home/krys/Projects/.contributions/rstcheck-core/.venv_test, clear=False, no_vcs_ignore=False, global=False)
  seeder FromAppData(download=False, pip=bundle, setuptools=bundle, wheel=bundle, via=copy, app_data_dir=/home/krys/.local/share/virtualenv)
    added seed packages: pip==23.2.1, setuptools==68.1.2, wheel==0.41.2
  activators BashActivator,CShellActivator,FishActivator,NushellActivator,PowerShellActivator,PythonActivator

$ . .venv_test/bin/activate

$ pip install rstcheck
Collecting rstcheck
  Obtaining dependency information for rstcheck from https://files.pythonhosted.org/packages/d6/a1/45a747d7a534bac89105ed2549f8addf1235c68aa2270dde54d1379407d7/rstcheck-6.2.0-py3-none-any.whl.metadata
  Using cached rstcheck-6.2.0-py3-none-any.whl.metadata (9.5 kB)
Collecting rstcheck-core>=1.1 (from rstcheck)
  Obtaining dependency information for rstcheck-core>=1.1 from https://files.pythonhosted.org/packages/d4/b2/7e81dfbfe6b8c3168eddafc4036ff3a1749c10a6ed9e568fd1e5003280f5/rstcheck_core-1.1.1-py3-none-any.whl.metadata
  Using cached rstcheck_core-1.1.1-py3-none-any.whl.metadata (9.1 kB)
Collecting typer[all]>=0.4.1 (from rstcheck)
  Using cached typer-0.9.0-py3-none-any.whl (45 kB)
Collecting importlib-metadata>=1.6 (from rstcheck)
  Obtaining dependency information for importlib-metadata>=1.6 from https://files.pythonhosted.org/packages/cc/37/db7ba97e676af155f5fcb1a35466f446eadc9104e25b83366e8088c9c926/importlib_metadata-6.8.0-py3-none-any.whl.metadata
  Using cached importlib_metadata-6.8.0-py3-none-any.whl.metadata (5.1 kB)
Collecting typing-extensions>=3.7.4 (from rstcheck)
  Obtaining dependency information for typing-extensions>=3.7.4 from https://files.pythonhosted.org/packages/24/21/7d397a4b7934ff4028987914ac1044d3b7d52712f30e2ac7a2ae5bc86dd0/typing_extensions-4.8.0-py3-none-any.whl.metadata
  Using cached typing_extensions-4.8.0-py3-none-any.whl.metadata (3.0 kB)
Collecting zipp>=0.5 (from importlib-metadata>=1.6->rstcheck)
  Obtaining dependency information for zipp>=0.5 from https://files.pythonhosted.org/packages/d9/66/48866fc6b158c81cc2bfecc04c480f105c6040e8b077bc54c634b4a67926/zipp-3.17.0-py3-none-any.whl.metadata
  Downloading zipp-3.17.0-py3-none-any.whl.metadata (3.7 kB)
Collecting docutils>=0.7 (from rstcheck-core>=1.1->rstcheck)
  Obtaining dependency information for docutils>=0.7 from https://files.pythonhosted.org/packages/26/87/f238c0670b94533ac0353a4e2a1a771a0cc73277b88bff23d3ae35a256c1/docutils-0.20.1-py3-none-any.whl.metadata
  Using cached docutils-0.20.1-py3-none-any.whl.metadata (2.8 kB)
Collecting pydantic>=2 (from rstcheck-core>=1.1->rstcheck)
  Obtaining dependency information for pydantic>=2 from https://files.pythonhosted.org/packages/73/66/0a72c9fcde42e5650c8d8d5c5c1873b9a3893018020c77ca8eb62708b923/pydantic-2.4.2-py3-none-any.whl.metadata
  Using cached pydantic-2.4.2-py3-none-any.whl.metadata (158 kB)
Collecting click<9.0.0,>=7.1.1 (from typer[all]>=0.4.1->rstcheck)
  Obtaining dependency information for click<9.0.0,>=7.1.1 from https://files.pythonhosted.org/packages/00/2e/d53fa4befbf2cfa713304affc7ca780ce4fc1fd8710527771b58311a3229/click-8.1.7-py3-none-any.whl.metadata
  Using cached click-8.1.7-py3-none-any.whl.metadata (3.0 kB)
Collecting colorama<0.5.0,>=0.4.3 (from typer[all]>=0.4.1->rstcheck)
  Using cached colorama-0.4.6-py2.py3-none-any.whl (25 kB)
Collecting shellingham<2.0.0,>=1.3.0 (from typer[all]>=0.4.1->rstcheck)
  Obtaining dependency information for shellingham<2.0.0,>=1.3.0 from https://files.pythonhosted.org/packages/57/70/0265437683625b2e6491736706d3d679d90e2a26f6bff59f4e46e09872b9/shellingham-1.5.3-py2.py3-none-any.whl.metadata
  Using cached shellingham-1.5.3-py2.py3-none-any.whl.metadata (3.4 kB)
Collecting rich<14.0.0,>=10.11.0 (from typer[all]>=0.4.1->rstcheck)
  Obtaining dependency information for rich<14.0.0,>=10.11.0 from https://files.pythonhosted.org/packages/be/2a/4e62ff633612f746f88618852a626bbe24226eba5e7ac90e91dcfd6a414e/rich-13.6.0-py3-none-any.whl.metadata
  Using cached rich-13.6.0-py3-none-any.whl.metadata (18 kB)
Collecting annotated-types>=0.4.0 (from pydantic>=2->rstcheck-core>=1.1->rstcheck)
  Obtaining dependency information for annotated-types>=0.4.0 from https://files.pythonhosted.org/packages/d8/f0/a2ee543a96cc624c35a9086f39b1ed2aa403c6d355dfe47a11ee5c64a164/annotated_types-0.5.0-py3-none-any.whl.metadata
  Using cached annotated_types-0.5.0-py3-none-any.whl.metadata (11 kB)
Collecting pydantic-core==2.10.1 (from pydantic>=2->rstcheck-core>=1.1->rstcheck)
  Obtaining dependency information for pydantic-core==2.10.1 from https://files.pythonhosted.org/packages/da/82/4139ea7aebec9e22be42d8a5342df5022b7b6b6deb10126dc3ff80b4d6fd/pydantic_core-2.10.1-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.metadata
  Downloading pydantic_core-2.10.1-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.metadata (6.5 kB)
Collecting markdown-it-py>=2.2.0 (from rich<14.0.0,>=10.11.0->typer[all]>=0.4.1->rstcheck)
  Obtaining dependency information for markdown-it-py>=2.2.0 from https://files.pythonhosted.org/packages/42/d7/1ec15b46af6af88f19b8e5ffea08fa375d433c998b8a7639e76935c14f1f/markdown_it_py-3.0.0-py3-none-any.whl.metadata
  Using cached markdown_it_py-3.0.0-py3-none-any.whl.metadata (6.9 kB)
Collecting pygments<3.0.0,>=2.13.0 (from rich<14.0.0,>=10.11.0->typer[all]>=0.4.1->rstcheck)
  Obtaining dependency information for pygments<3.0.0,>=2.13.0 from https://files.pythonhosted.org/packages/43/88/29adf0b44ba6ac85045e63734ae0997d3c58d8b1a91c914d240828d0d73d/Pygments-2.16.1-py3-none-any.whl.metadata
  Using cached Pygments-2.16.1-py3-none-any.whl.metadata (2.5 kB)
Collecting mdurl~=0.1 (from markdown-it-py>=2.2.0->rich<14.0.0,>=10.11.0->typer[all]>=0.4.1->rstcheck)
  Using cached mdurl-0.1.2-py3-none-any.whl (10.0 kB)
Using cached rstcheck-6.2.0-py3-none-any.whl (8.3 kB)
Using cached importlib_metadata-6.8.0-py3-none-any.whl (22 kB)
Using cached rstcheck_core-1.1.1-py3-none-any.whl (27 kB)
Using cached typing_extensions-4.8.0-py3-none-any.whl (31 kB)
Using cached click-8.1.7-py3-none-any.whl (97 kB)
Using cached docutils-0.20.1-py3-none-any.whl (572 kB)
Using cached pydantic-2.4.2-py3-none-any.whl (395 kB)
Downloading pydantic_core-2.10.1-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (2.1 MB)
   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 2.1/2.1 MB 16.4 MB/s eta 0:00:00
Using cached rich-13.6.0-py3-none-any.whl (239 kB)
Using cached shellingham-1.5.3-py2.py3-none-any.whl (9.7 kB)
Downloading zipp-3.17.0-py3-none-any.whl (7.4 kB)
Using cached annotated_types-0.5.0-py3-none-any.whl (11 kB)
Using cached markdown_it_py-3.0.0-py3-none-any.whl (87 kB)
Using cached Pygments-2.16.1-py3-none-any.whl (1.2 MB)
Installing collected packages: zipp, typing-extensions, shellingham, pygments, mdurl, docutils, colorama, click, typer, pydantic-core, markdown-it-py, importlib-metadata, annotated-types, rich, pydantic, rstcheck-core, rstcheck
Successfully installed annotated-types-0.5.0 click-8.1.7 colorama-0.4.6 docutils-0.20.1 importlib-metadata-6.8.0 markdown-it-py-3.0.0 mdurl-0.1.2 pydantic-2.4.2 pydantic-core-2.10.1 pygments-2.16.1 rich-13.6.0 rstcheck-6.2.0 rstcheck-core-1.1.1 shellingham-1.5.3 typer-0.9.0 typing-extensions-4.8.0 zipp-3.17.0

$ pip check
No broken requirements found.

$ pip freeze
annotated-types==0.5.0
click==8.1.7
colorama==0.4.6
docutils==0.20.1
importlib-metadata==6.8.0
markdown-it-py==3.0.0
mdurl==0.1.2
pydantic==2.4.2
pydantic_core==2.10.1
Pygments==2.16.1
rich==13.6.0
rstcheck==6.2.0
rstcheck-core==1.1.1
shellingham==1.5.3
typer==0.9.0
typing_extensions==4.8.0
zipp==3.17.0

$ python -c "import importlib.metadata; print(importlib.metadata.version('rstcheck-core'))"
1.1.1

$ python -V
Python 3.8.10
kynan commented 1 year ago

Interesting. I can reproduce your steps.

The conditions where I encountered the issue as reported is when packaging rstcheck for conda-forge, see conda-forge/rstcheck-feedstock#11 and the build failure.

Here's a minimal example:

$ conda create -n rstcheck-test python=3.8
$ conda install -c conda-forge rstcheck-core
[...]
The following NEW packages will be INSTALLED:

  [...]
  rstcheck-core      conda-forge/noarch::rstcheck-core-1.1.1-pyhd8ed1ab_0
  [...]
[...]
$ python -c "import importlib.metadata; print(importlib.metadata.version('rstcheck-core'))"
0.0.0
$ pip freeze
[...]
rstcheck-core @ file:///home/conda/feedstock_root/build_artifacts/rstcheck-core_1695925501347/work
[...]
Cielquan commented 1 year ago

I am not familiar with conda. But according to what I could see the sdist is used instead of the wheel. My reproduction above was using the wheel by pip's default.

I tested again and forced pip to use the sdist instead of the wheel and I still could not reproduce the issue. I tested via --no-binary flag and manually passing the sdist.

In version 1.1.0 I switched from poetry to setuptools as build backend. Therefore I compared the sdist for version 1.0.3 and 1.1.1 but could not find any clue.

I took a look at the build-log and at many places rstcheck's (not rstcheck-core's) version is 0.0.0. Is this correct? If not and if rstcheck-core is installed from conda and not pypi maybe the conda build for rstcheck-core has the same issue but did not error.

In line 399 rstcheck-core's version is correctly listed.

EDIT: Could you compare the conda package for 1.0.3 and 1.1.1 or add links to them so I can take a look.

kynan commented 1 year ago

In version 1.1.0 I switched from poetry to setuptools as build backend.

That shouldn't in itself be an issue: I've packaged many other Python packages for conda-forge that use setuptools.

I took a look at the build-log and at many places rstcheck's (not rstcheck-core's) version is 0.0.0. Is this correct? If not and if rstcheck-core is installed from conda and not pypi maybe the conda build for rstcheck-core has the same issue but did not error.

Yes, rstcheck and rstcheck-core both suffer from this issue when packaging with conda. I figured I'd try to resolve the issue with rstcheck-core first :)

You can get the conda packages here. Note that they're zip archives with a different extension, so a bit "unwieldy" for inspection.

kynan commented 1 year ago

Suspiciously, the files actually installed for 1.1.1 are these:

site-packages/rstcheck_core-0.0.0.dist-info/AUTHORS.rst
site-packages/rstcheck_core-0.0.0.dist-info/INSTALLER
site-packages/rstcheck_core-0.0.0.dist-info/LICENSE
site-packages/rstcheck_core-0.0.0.dist-info/METADATA
site-packages/rstcheck_core-0.0.0.dist-info/RECORD
site-packages/rstcheck_core-0.0.0.dist-info/REQUESTED
site-packages/rstcheck_core-0.0.0.dist-info/WHEEL
site-packages/rstcheck_core-0.0.0.dist-info/direct_url.json
site-packages/rstcheck_core-0.0.0.dist-info/top_level.txt
site-packages/rstcheck_core/__init__.py
site-packages/rstcheck_core/__version__.py
site-packages/rstcheck_core/_compat.py
site-packages/rstcheck_core/_docutils.py
site-packages/rstcheck_core/_extras.py
site-packages/rstcheck_core/_sphinx.py
site-packages/rstcheck_core/checker.py
site-packages/rstcheck_core/config.py
site-packages/rstcheck_core/inline_config.py
site-packages/rstcheck_core/py.typed
site-packages/rstcheck_core/runner.py
site-packages/rstcheck_core/types.py

Clearly, dist-info is incorrect, which presumably leads to the incorrectly reported version.

For 1.0.3 the file listing looks correct:

site-packages/rstcheck_core-1.0.3.dist-info/INSTALLER
site-packages/rstcheck_core-1.0.3.dist-info/LICENSE
site-packages/rstcheck_core-1.0.3.dist-info/METADATA
site-packages/rstcheck_core-1.0.3.dist-info/RECORD
site-packages/rstcheck_core-1.0.3.dist-info/REQUESTED
site-packages/rstcheck_core-1.0.3.dist-info/WHEEL
site-packages/rstcheck_core-1.0.3.dist-info/direct_url.json
site-packages/rstcheck_core/__init__.py
site-packages/rstcheck_core/_compat.py
site-packages/rstcheck_core/_docutils.py
site-packages/rstcheck_core/_extras.py
site-packages/rstcheck_core/_sphinx.py
site-packages/rstcheck_core/checker.py
site-packages/rstcheck_core/config.py
site-packages/rstcheck_core/inline_config.py
site-packages/rstcheck_core/py.typed
site-packages/rstcheck_core/runner.py
site-packages/rstcheck_core/types.py

We may need help from someone on the conda-forge team to dig into this.

If you want to investigate further, the PR for packaging 1.1.0 is conda-forge/rstcheck-core-feedstock#2, for 1.1.1 it's conda-forge/rstcheck-core-feedstock#3.

Cielquan commented 1 year ago

Yeah I guess this is an issue with the conda build process. But it may be fixable on our side in a way that helps conda.

dopplershift commented 1 year ago

I think the conda recipe needs to be updated, it lists poetry (which seems to be now unused) and not setuptools_scm. I strongly suspect the lack of the latter is why it ends up with version 0.0.0.

kynan commented 1 year ago

Thanks @dopplershift and @synapticarbors (suggesting the same on conda-forge/rstcheck-feedstock#11), that was indeed the issue - and an embarrassing oversight on my part!

Addressed in conda-forge/rstcheck-core-feedstock#4 for 1.1.0 and conda-forge/rstcheck-core-feedstock#5 for 1.1.1.

Cielquan commented 1 year ago

I am glad the issue could be resolved :)