Bug 259567 - devel/py-jsonschema: Version returns 0.0.0, breaking net-im/py-matrix-synapse which runs a version check
Summary: devel/py-jsonschema: Version returns 0.0.0, breaking net-im/py-matrix-synapse...
Status: Closed FIXED
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: --- Affects Many People
Assignee: Muhammad Moinur Rahman
URL:
Keywords: needs-patch, needs-qa
: 259659 (view as bug list)
Depends on:
Blocks:
 
Reported: 2021-10-31 08:56 UTC by tom
Modified: 2021-11-05 14:20 UTC (History)
5 users (show)

See Also:
bugzilla: maintainer-feedback? (bofh)
koobs: maintainer-feedback? (ports)
bofh: merge-quarterly-


Attachments
devel/py-jsonschema: Fix missing dependency (811 bytes, patch)
2021-11-02 17:13 UTC, Sascha Biberhofer
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description tom 2021-10-31 08:56:43 UTC
$ jsonschema --version
shows 0.0.0 instead of actual version which makes matrix-synapse impossible to start
---
$ service synapse start
Starting synapse.
ERROR:root:Needed jsonschema>=3.0.0, got jsonschema==0.0.0
Missing Requirements: "jsonschema>=3.0.0"
To install run:
    pip install --upgrade --force "jsonschema>=3.0.0"
/usr/local/etc/rc.d/synapse: WARNING: failed to start synapse
Comment 1 Kubilay Kocak freebsd_committer freebsd_triage 2021-11-02 01:24:08 UTC
Thank you for the report Tom.

Can you isolate / attach the 'version check' code.
Comment 2 tom 2021-11-02 08:10:10 UTC
File = /usr/local/lib/python3.8/site-packages/synapse/python_dependencies.py


Code Line 50 
REQUIREMENTS = [
    # we use the TYPE_CHECKER.redefine method added in jsonschema 3.0.0
    "jsonschema>=3.0.0",
    ....

I changed the Code to "jsonschema>=0.0.0" and matrix-synapse starts now, so it seems to be the only check.

Regards
Tom
Comment 3 Sascha Biberhofer 2021-11-02 11:51:20 UTC
I can confirm this on my system. Seems like something is weirdly wrong with the version of the FreeBSD package and *only* the distributed package:

* It appears as jsonschema==0.0.0 in pip freeze too, suggesting that something is wrong with the package metadata per se.
* I quickly built and installed the package directly from ports, which does *not* result in such a broken package for me (i.e. both pip freeze and jsonschema --version report the correct version number). Similarly, installing the package directly via pip works fine too.
* Building the package in poudriere however yields a package with version 0.0.0 in pip which is consequently also reported back by the package

It would appear that something goes wrong when building the package with poudriere, but I'm currently not sure what exactly goes wrong here and I'm a bit uncertain how to proceed. The way the package obtains the version appears to have changed and relies on importlib's metadata.version() function, which *should* work, I suppose, but I'm not sure how that version is formed before the package is installed and would need to dig deeper into this to properly find the cause.


In the meantime, should we patch synapse to remove the version check? It would be a hack and I'd prefer to resolve this issue right here, but it *should* be fine for the time being to ensure things keep running moderately smoothly.
Comment 4 Sascha Biberhofer 2021-11-02 17:13:10 UTC
Created attachment 229227 [details]
devel/py-jsonschema: Fix missing dependency

Apparently py-jsonschema uses py-setuptools_scm to filter the version from scm directly. This is reflected in the project's pyproject.toml, see [1].

Our port is missing this dependency, which causes the version to be set to 0.0.0.

I've attached a patch that bumps the port's revision and adds the missing dependency. Tested building this in poudriere and it works fine. :-)

Credits for this go to David Tucker in the #python room on matrix.org for pointing pointing me in the right direction. :D

Cheers,
Sascha

[1] https://github.com/Julian/jsonschema/blob/272b4f24437d9cba1127058dc3479f9bc6d8c4b9/pyproject.toml#L6
Comment 5 commit-hook freebsd_committer freebsd_triage 2021-11-04 02:12:38 UTC
A commit in branch main references this bug:

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

commit 9913762ef61e311938e87a588aa427bbee65a74d
Author:     Sascha Biberhofer <ports@skyforge.at>
AuthorDate: 2021-11-04 02:02:56 +0000
Commit:     Muhammad Moinur Rahman <bofh@FreeBSD.org>
CommitDate: 2021-11-04 02:11:16 +0000

    devel/py-jsonschema: Fix missing dependency

    PR: 259567
    Reported by: tom@leben-auf-see.de
    MFH:    2021Q4 (fix build)

 devel/py-jsonschema/Makefile | 2 ++
 1 file changed, 2 insertions(+)
Comment 6 Muhammad Moinur Rahman freebsd_committer freebsd_triage 2021-11-04 02:19:30 UTC
Unfortunately MFH is not required as 4.X is not on 2021Q4.
Comment 7 Muhammad Moinur Rahman freebsd_committer freebsd_triage 2021-11-05 14:20:28 UTC
*** Bug 259659 has been marked as a duplicate of this bug. ***