Bug 269686 - textproc/py-sphinx-autodoc-typehints: Installation in unusable state
Summary: textproc/py-sphinx-autodoc-typehints: Installation in unusable state
Status: Closed FIXED
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: --- Affects Only Me
Assignee: freebsd-ports-bugs (Nobody)
URL: https://github.com/tox-dev/sphinx-aut...
Keywords:
Depends on:
Blocks: 269687
  Show dependency treegraph
 
Reported: 2023-02-19 15:52 UTC by Andreas Bilke
Modified: 2023-03-11 08:45 UTC (History)
2 users (show)

See Also:


Attachments
Fix build issue when building in not isolated mode (2.25 KB, patch)
2023-03-03 18:53 UTC, Andreas Bilke
andreas: maintainer-approval+
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Andreas Bilke 2023-02-19 15:52:39 UTC
If you use autodoc-typehints as an sphinx extension (as described in https://pypi.org/project/sphinx-autodoc-typehints/) you get an error like this (taken from py-khard)

Extension error:
Could not import extension sphinx_autodoc_typehints (exception: cannot import name '__version__' from 'sphinx_autodoc_typehints.version' (/usr/local/lib/python3.9/site-packages/sphinx_autodoc_typehints/version.py))

It boils down to the following line in (/usr/local/lib/python3.9/site-packages/sphinx_autodoc_typehints/__init__.py:26 

from .version import __version__

where __version__ is not existing in version.py

Currently it is unclear for me if it has something to do with the switch to pep 517 (see https://github.com/tox-dev/sphinx-autodoc-typehints/blame/main/src/sphinx_autodoc_typehints/__init__.py why I think that).
Comment 1 Andreas Bilke 2023-02-26 14:44:30 UTC
I further debugged the problem:

The default build command (for pep517 based builds) is

python3 -m build -n -w

which builds in *non isolation*. Doing this, I get a version.py (for this port) looking like

# coding: utf-8
# file generated by setuptools_scm
# don't change, don't track in version control
version = '1.22'
version_tuple = (1, 22)

which leads to the error above.

If I build this python project in an isolated environment (I assume that fetches all python deps explicitly in venv) with

python3 -m build -w

I get a file like

# file generated by setuptools_scm
# don't change, don't track in version control
__version__ = version = '1.22'
__version_tuple__ = version_tuple = (1, 22)

which is what sphinx-autodoc-typehints expects.

So building in isolation screws up the port system, doing it without isolation results in a broken version.py.

I don't know what are the exact differences in deps between isolation/no isolation. I assume some version differences in a dep (like setuptools_scm?).

I currently see no way of fixing that problem. I tried to post-patch the generated version.py but the pep517 build commands generates version.py and bundle it in a wheel in one step.
Comment 2 Jon Bringhurst 2023-03-01 19:14:07 UTC
Related issue:

https://github.com/tox-dev/sphinx-autodoc-typehints/issues/327
Comment 3 Andreas Bilke 2023-03-03 18:53:02 UTC
Created attachment 240566 [details]
Fix build issue when building in not isolated mode

(In reply to Jon Bringhurst from comment #2)

Since upsteam does not see any problem with the current behaviour we can only patch this issue on our side. Thank you Jon for propose a fix. I attached the patch for our port.

I also removed some redundant build dependencies.
Comment 4 commit-hook freebsd_committer freebsd_triage 2023-03-11 08:40:16 UTC
A commit in branch main references this bug:

URL: https://cgit.FreeBSD.org/ports/commit/?id=c1f83d71134e6cf4a5142c3cb917f25c265bbad3

commit c1f83d71134e6cf4a5142c3cb917f25c265bbad3
Author:     Andreas Bilke <andreas@bilke.org>
AuthorDate: 2023-03-09 00:07:21 +0000
Commit:     Robert Clausecker <fuz@FreeBSD.org>
CommitDate: 2023-03-11 08:38:57 +0000

    textproc/py-sphinx-autodoc-typehints: fix building in non isolated mode

    Since upsteam does not see any problem with the current behaviour we can
    only patch this issue on our side.

    Also remove some redundant build dependencies.

    PR:             269686

 textproc/py-sphinx-autodoc-typehints/Makefile          |  5 +----
 ...rc_sphinx__autodoc__typehints_____init____.py (new) | 18 ++++++++++++++++++
 2 files changed, 19 insertions(+), 4 deletions(-)
Comment 5 Robert Clausecker freebsd_committer freebsd_triage 2023-03-11 08:45:03 UTC
Thank you for your contribution.