ICB-DCM / pyABC

distributed, likelihood-free inference
https://pyabc.rtfd.io
BSD 3-Clause "New" or "Revised" License
205 stars 44 forks source link

Names containing underscores in extra_options in setup.cfg are broken #618

Closed omsai closed 1 year ago

omsai commented 1 year ago

Bug description pyabc provides several optional extras, however those that contain underscores in their name cannot be installed.

The extras as of 0.12.14 are:

from importlib_metadata import metadata
from pprint import pprint

pprint(metadata('pyabc').get_all('Provides-Extra'))
['r',
 'amici',
 'autograd',
 'copasi',
 'doc',
 'examples',
 'julia',
 'migrate',
 'ot',
 'petab',
 'plotly',
 'pyarrow',
 'test',
 'test_petab',
 'webserver_dash',
 'webserver_flask',
 'yaml2sbml']

Expected behavior The name of the optional extra should be recognized and install correctly.

To reproduce

Output from trying to install each of them:

# pyproject.toml.in
[build-system]
build-backend = "hatchling.build"
requires = ["hatchling"]

[project]
name = "cal"
version = "0.1"
dependencies = ["pyabc[@EXTRA@] @git+https://github.com/ICB-DCM/pyABC#egg=v0.12.14"]

[tool.hatch.metadata]
allow-direct-references = true
$ extras="r amici autograd copasi doc examples julia migrate ot petab plotly"
$ extras+=" pyarrow test test_petab webserver_dash webserver_flask yaml2sbml"
$ for extra in $extras
>  do sed "s/@EXTRA@/$extra/" < pyproject.toml.in > pyproject.toml
> hatch project metadata
> hatch run test
> done
...
    "dependencies": [
        "pyabc[test-petab]@ git+https://github.com/ICB-DCM/pyABC#egg=v0.12.14"
    ]
}
WARNING: pyabc 0.12.14 does not provide the extra 'test-petab'
...
    "dependencies": [
        "pyabc[webserver-dash]@ git+https://github.com/ICB-DCM/pyABC#egg=v0.12.14"
    ]
}
WARNING: pyabc 0.12.14 does not provide the extra 'webserver-dash'
...
    "dependencies": [
        "pyabc[webserver-flask]@ git+https://github.com/ICB-DCM/pyABC#egg=v0.12.14"
    ]
}
WARNING: pyabc 0.12.14 does not provide the extra 'webserver-flask'
...

Environment

stephanmg commented 1 year ago

Thanks for reporting, related to setuptools issue reported here: https://github.com/pypa/setuptools/issues/2522

stephanmg commented 1 year ago

@omsai could you try fix_extra branch, it should resolve your problem.

omsai commented 1 year ago

@stephanmg It only fixes test-petab but not web server-dash or web server-flask and I see that the latter two are unchanged in the diff https://github.com/ICB-DCM/pyABC/compare/main...fix_extra

--- /tmp/abc/pyproject.toml.in.orig 2023-11-14 11:01:46
+++ /tmp/abc/pyproject.toml.in  2023-11-14 11:05:38
@@ -5,7 +5,7 @@
 [project]
 name = "cal"
 version = "0.1"
-dependencies = ["pyabc[@EXTRA@] @git+https://github.com/ICB-DCM/pyABC#egg=v0.12.14"]
+dependencies = ["pyabc[@EXTRA@] @git+https://github.com/ICB-DCM/pyABC@fix_extra"]

 [tool.hatch.metadata]
 allow-direct-references = true
$ extras="test_petab webserver_dash webserver_flask"
$ for extra in $extras
> do sed "s/@EXTRA@/$extra/" < pyproject.toml.in > pyproject.toml
> hatch project metadata
> hatch run test
{
    "name": "cal",
    "version": "0.1",
    "readme": {
        "content-type": "text/markdown",
        "text": ""
    },
    "dependencies": [
        "pyabc[test-petab]@ git+https://github.com/ICB-DCM/pyABC@fix_extra"
    ]
}
{
    "name": "cal",
    "version": "0.1",
    "readme": {
        "content-type": "text/markdown",
        "text": ""
    },
    "dependencies": [
        "pyabc[webserver-dash]@ git+https://github.com/ICB-DCM/pyABC@fix_extra"
    ]
}
WARNING: pyabc 0.12.14 does not provide the extra 'webserver-dash'
{
    "name": "cal",
    "version": "0.1",
    "readme": {
        "content-type": "text/markdown",
        "text": ""
    },
    "dependencies": [
        "pyabc[webserver-flask]@ git+https://github.com/ICB-DCM/pyABC@fix_extra"
    ]
}
WARNING: pyabc 0.12.14 does not provide the extra 'webserver-flask'
stephanmg commented 1 year ago

True @omsai I must have forgotten to change dependencies for this. Could you give the branch fix_dependencies a try?

omsai commented 1 year ago

@stephanmg Yes, it works now in that branch; thank you!

stephanmg commented 1 year ago

Alright @omsai - it will remain in develop branch until next bug fix release.