proycon / codemetapy

A Python package for generating and working with codemeta
https://codemeta.github.io/
GNU General Public License v3.0
24 stars 5 forks source link

Incorrect parsing of versions from dependencies if e.g. extras are stated to be installed #48

Open apirogov opened 11 months ago

apirogov commented 11 months ago

The fix in #42 apparently did not work, the problem still persists with codemetapy 2.5.1:

[tool.poetry]
name = "somesy"
version = "0.1.0"
description = "A CLI tool for synchronizing software project metadata."
authors = ["Mustafa Soylu <m.soylu@fz-juelich.de>", "Anton Pirogov <a.pirogov@fz-juelich.de>"]
maintainers = ["Mustafa Soylu <m.soylu@fz-juelich.de>"]
license = "MIT"

include = [
  "*.md", "LICENSE", "LICENSES", ".reuse/dep5", "CITATION.cff", "codemeta.json",
  { path = "mkdocs.yml", format = "sdist" },
  { path = "docs", format = "sdist" },
  { path = "tests", format = "sdist" },
]

[tool.poetry.dependencies]
python = "^3.8"
pydantic = {extras = ["email"], version = "^1.9.2"}
typer = {extras = ["all"], version = "^0.7.0"}

[tool.poetry.group.docs]
optional = true

[tool.poetry.group.docs.dependencies]
mkdocstrings = {extras = ["python"], version = "^0.21.2"}
markdown-exec = {extras = ["ansi"], version = "^1.6.0"}

Output:

Passed 1 files/sources but specified 0 input types! Automatically guessing types...
Detected input types: [('pyproject.toml', 'python')]
Note: You did not specify a --baseuri so we will not provide identifiers (IRIs) for your SoftwareSourceCode resources (and others)
Initial URI automatically generated, may be overriden later: file:///pyproject-toml
Processing source #1 of 1
Obtaining python package metadata for: pyproject.toml
Loading metadata from pyproject.toml via pyproject-parser
WARNING: No translation for distutils or pyproject.toml key include
Found dependency python ^3.8
Found dependency pydantic {'extras': ['email'
Found dependency 'version': '^1.9.2'}
Found dependency typer {'extras': ['all'
Found dependency 'version': '^0.7.0'}
WARNING: No translation for distutils or pyproject.toml key group
[CODEMETA COMPOSITION (somesy)] processed 50 new triples, total is now 51
[CODEMETA VALIDATION (somesy)] codeRepository not set
[CODEMETA VALIDATION (somesy)] done
{
    "@context": [
        "https://doi.org/10.5063/schema/codemeta-2.0",
        "https://w3id.org/software-iodata",
        "https://raw.githubusercontent.com/jantman/repostatus.org/master/badges/latest/ontology.jsonld",
        "https://schema.org",
        "https://w3id.org/software-types"
    ],
    "@type": "SoftwareSourceCode",
    "author": [
        {
            "@type": "Person",
            "email": "a.pirogov@fz-juelich.de",
            "familyName": "Pirogov",
            "givenName": "Anton"
        },
        {
            "@type": "Person",
            "email": "m.soylu@fz-juelich.de",
            "familyName": "Soylu",
            "givenName": "Mustafa"
        }
    ],
    "description": "A CLI tool for synchronizing software project metadata.",
    "identifier": "somesy",
    "license": "http://spdx.org/licenses/MIT",
    "maintainer": {
        "@type": "Person",
        "email": "m.soylu@fz-juelich.de",
        "familyName": "Soylu",
        "givenName": "Mustafa"
    },
    "name": "somesy",
    "runtimePlatform": "Python 3",
    "softwareRequirements": [
        {
            "@type": "SoftwareApplication",
            "identifier": "'version':",
            "name": "'version':",
            "runtimePlatform": "Python 3",
            "version": "'^1.9.2'}"
        },
        {
            "@type": "SoftwareApplication",
            "identifier": "'version':",
            "name": "'version':",
            "runtimePlatform": "Python 3",
            "version": "'^0.7.0'}"
        },
        {
            "@type": "SoftwareApplication",
            "identifier": "pydantic",
            "name": "pydantic",
            "runtimePlatform": "Python 3",
            "version": "{'extras': ['email'"
        },
        {
            "@type": "SoftwareApplication",
            "identifier": "python",
            "name": "python",
            "runtimePlatform": "Python 3",
            "version": "^3.8"
        },
        {
            "@type": "SoftwareApplication",
            "identifier": "typer",
            "name": "typer",
            "runtimePlatform": "Python 3",
            "version": "{'extras': ['all'"
        }
    ],
    "version": "0.1.0"
}

I had no option to re-open the existing issue, so I'm creating a new one.

apirogov commented 10 months ago

This also interacts with https://github.com/proycon/codemetapy/issues/39

For example in our project I get now alternatingly

             "identifier": "'version':",
             "name": "'version':",
             "runtimePlatform": "Python 3",
-            "version": "'^2.4.2'}"
+            "version": "'^0.7.0'}"
         },
         {
             "@type": "SoftwareApplication",
             "identifier": "'version':",
             "name": "'version':",
             "runtimePlatform": "Python 3",
-            "version": "'^0.7.0'}"
+            "version": "'^2.4.2'}"
         },
         {
             "@type": "SoftwareApplication",

and

             "identifier": "'version':",
             "name": "'version':",
             "runtimePlatform": "Python 3",
-            "version": "'^0.7.0'}"
+            "version": "'^2.4.2'}"
         },
         {
             "@type": "SoftwareApplication",
             "identifier": "'version':",
             "name": "'version':",
             "runtimePlatform": "Python 3",
-            "version": "'^2.4.2'}"
+            "version": "'^0.7.0'}"
         },
         {
             "@type": "SoftwareApplication",

Not sure if this nondeterminism is only with these "broken" incorrect dependencies, or there's still a general problem with the other non-determinism issue.