Skip to content

Provide machine-readable optional dependencies? #5793

Open

Description

@bollwyvl

Congratulations on 7.5!

Downstream on conda-forge, noted that markdown is needed for the test suite to run. Exciting!

However, it would be lovely to have a centralized place for this kind of information, and future optional dependencies changes.
This would certainly make it easier for downstreams such as conda-forge, but could also provide a actionable user messages

Design ideas:

One approach would be to leverage python's optional dependencies, which could be captured in various schemes with the robotframework[extra1,extra2] syntax.

This might look like:

setup(
    # ...
    extras_require={
      "gfm": [
          "pygments",
          "robotframework[markdown]", 
      ],
      "markdown": [
         "markdown",
      ],
      "utest": [
         "robotframework[markdown]",
         # ....
      ]
      #... and pyte, xml, yaml, and...
    },
)

pretty verbose, but, selfishly: i like seeing diffs of sorted lists 😊 )

Or, with fancy new pyproject.toml, which can separate out unexported names in dependency-groups:

[project.optional-dependencies]
gfm = [
  "robotframework[markdown]", 
  "pygments"
]
markdown = [
  "markdown",
]
# ...

[dependency-groups]
utest = [
  "robotframework[markdown]",
  # ... actual unique test deps
]

this would also work if moving all of the setup.py content over to pyproject.toml, with a tiny setup.py of __import__('setuptools').setup() which wouldn't require any docs changes... though maybe some automation

I'd be happy to work up a strawman PR for either approach, if desired.

Activity

  1. pekkaklarck commented on Sep 22, 2026

    @pekkaklarck
    Member

    Handling dependencies is something we've discussed few times lately and using Python's optional dependencies sounds like a good step into right direction. The hard part is decising what names we want to use (e.g. do we want markdown and gfm separately) because changing them later is backwards incompatible. Do you want to make a proposal?

    We plan to move to pyproject.toml fully and to redo packaging in RF 8, but there's still going to be RF 7.6 before that. It's thus probably best to do this using setup.py now.

  2. bollwyvl commented on Sep 23, 2026

    @bollwyvl
    Author

    Sure, here's a stab at splitting things like pygments out as a highlight function thing, with certain "brands" named explicitly:

    ... in setup.py with all as [extras]...
    EXTRAS = {
        # user-facing, feature-based
        "highlighting": [
            "pygments"
        ],
        "markdown": [  # or "md"
            "markdown"
        ],
        "restructuredtext": [ # or "rst"
            "docutils",
        ],
        "screenshots": [ 
            "pillow; platform_system == 'Windows'",
            "pygtk; platform_system == 'Linux'",
        ],
        "telnet": [
            "pyte",
        ],
        "yaml": [
            "pyyaml",
        ],
        # user-facing, specific dependencies
        "lxml": [
            "lxml",
        ],
        "wx": [
            "wxpython",
        ],
        # internal, would be converted to [dependency-groups]`` in ``pyproject.toml``
        "atest": [
            "robotframework[highlighting]",
            "robotframework[lxml]",
            "robotframework[screenshots]",
            "robotframework[utest]",
            "robotframework[yaml]",
        ],
        "docs": [
            "sphinx",
            "sphinx-rtd-theme",
        ],
        "dev": [
            "black >=24",
            "invoke >=0.20",
            "isort",
            "pydantic <2",
            "rellu >= 0.7,<2",
            "robotframework[docs]",
            "robotframework[highlighting]",
            "robotframework[utest]",
            "ruff",
            "setuptools >75",
            "telnetlib-313-and-up; python_version >= '3.13'",
            "twine >6",
            "wheel",
        ],
        "utest": [
            "jsonschema",
            "robotframework[restructuredtext]",
            "typing-extensions >=4.13",
        ],
    }
    ... or, for comparison, pyproject.toml with some dependency-groups...
    [project.optional-dependencies]
    highlighting = ["pygments"]
    markdown = [  # or "md"
      "markdown"
    ]
    restructuredtext = [  # or "rst"
      "docutils",
    ]
    screenshots = [
      "pillow; platform_system == 'Windows'",
      "pygtk; platform_system == 'Linux'",
    ]
    telnet = [
      "pyte",
    ]
    yaml = [
      "pyyaml",
    ]
    # user-facing, specific dependencies
    lxml = [
      "lxml",
    ]
    wx = [
      "wxpython",
    ]
    
    [dependency-groups]
    atest = [
      { include-group = "utest" },
      "robotframework[highlighting]",
      "robotframework[lxml]",
      "robotframework[screenshots]",
      "robotframework[yaml]",
    ]
    docs = [
      "sphinx",
      "sphinx-rtd-theme",
    ]
    dev = [
      { include-group = "docs" },
      { include-group = "highlighting" },
      { include-group = "utest" },
      "black >=24",
      "invoke >=0.20",
      "isort",
      "pydantic <2",
      "rellu >= 0.7,<2",
      "ruff",
      "setuptools >75",
      "telnetlib-313-and-up; python_version >= '3.13'",
      "twine >6",
      "wheel",
    ]
    utest = [
      "jsonschema",
      "robotframework[restructuredtext]",
      "typing-extensions >=4.13",
    ]

    Some more thoughts:

    • having sensible (but, ideally, tested) lower bound for more of these would be ideal
      • some of the test environments have pins; if these are real, they should probably appear in the user-facing ones
      • adopting a matrix-aware tool like tox or the lockfile-enabled uv/pixi might make exercising these locally more reasonable

    As for timeline:

    • dependency-groups aren't exposed to end users, so could be adopted before moving everything to pyproject.toml
    • it's possible even the [project.optional-dependencies] could already be in pyproject.toml, would have to check building some wheels
  3. pekkaklarck commented on Sep 24, 2026

    @pekkaklarck
    Member

    Let's first agree on the extras we provide and then plan how to get this implemented. Some general thins first:

    1. I'd prefer generic names like like markdown and screenshot instead of specific module names (even through with markdown that's also the module name).
    2. Unless there are clear benefits, I'd exclude dev and test requirements from this list.

    My initial proposal for the actual extras are these:

    • yaml: pyyaml
    • markdown: python-markdown, pygments
    • restructuredtext (or rst): docutils, pygments
    • xml: lxml
    • screenshot: platform dependent (or leave out as there are so many alternatives)
    • telnet: telnetlib-313-and-up, pyte (or leave out as we've already deprecated Telnet)
  4. bollwyvl commented on Sep 24, 2026

    @bollwyvl
    Author

    It looks like the two lists mostly agree, with the following exceptions:

    • telnet: (i missed telnetlib-313-and-up); and agree on not porting a deprecated one
    • screenshots: yep, a total mess
      • pillow:a fine upstream, too bad it doesn't work everywhere
      • pygtk: only releases .exe on PyPI apparently, so not even really very useful to pip or uv
      • wx is absent, and doesn't ship linux wheels
      • there is a PEP for [external-depednencies], but it won't help end users much, yet

    I guess for file formats, perhaps the shortest-possible, yet widely-recognized extension names are best, so perhaps:

    • md
    • yaml (even though yml is technically shorter)
    • xml
    • rst

    pygments is also used in several places, so would still keep it as a separate thing, used by the others, but perhaps it could be highlight.

    I'd exclude dev and test requirements from this list.

    With setup.py [extras], there are clear downsides of having development-focused things "leaking" into userspace/downstream dependencies. The exception to this is when there is overlap where a test group refines an extra with some unknown wisdom which would be helpful to include in the user-facing ones, e.g. pillow >=7.1.0 in atest.

    clear benefits

    For pyproject.toml, kind of a lot...

    [dependency-groups] along with [build-system.requires] and requires-python, finally provides a single source of truth for all dependency information, avoiding -r .../../ kind of stuff, duplication of key constraints, circular nonsense with setup_requires, and custom path knowledge.

    • Contributors would be able to use:
      pip install -e . --group atest
    • Reviewers would be able to see changes to this important, well-known file.
    • Any lockfile-based tool would know what to do with these.
    • Selfishly, as a downstream repackager, I'd be able to look at a short command (or write a script) to keep things synced:
      git diff 0.7.0 0.7.1 -- pyproject.toml

    So taking all of the above together...

    ...here's what that would look like as a PR:
    diff --git a/pyproject.toml b/pyproject.toml
    index 0eaa75147..707cb1828 100644
    --- a/pyproject.toml
    +++ b/pyproject.toml
    @@ -1,3 +1,45 @@
    +[build-system]
    +requires = ["setuptools >75"]
    +build-backend = "setuptools.build_meta"
    +
    +[dependency-groups]
    +atest = [
    +  { include-group = "utest" },
    +  "pillow >=7.10; platform_system == 'Windows'",
    +  "robotframework[highlight]",
    +  "robotframework[telnet]",
    +  "robotframework[xml]",
    +  "robotframework[yaml]",
    +]
    +docs = [
    +  "sphinx",
    +  "sphinx-rtd-theme",
    +]
    +dev = [
    +  { include-group = "docs" },
    +  { include-group = "telnet" },
    +  { include-group = "utest" },
    +  "black >=24",
    +  "invoke >=0.20",
    +  "isort",
    +  "pydantic <2",
    +  "rellu >= 0.7,<2",
    +  "robotframework[highlight]",
    +  "ruff",
    +  "setuptools >75",
    +  "twine >6",
    +  "wheel",
    +]
    +telnet = [
    +  "pyte >=0.6",
    +  "telnetlib-313-and-up; python_version >= '3.13'",
    +]
    +utest = [
    +  "jsonschema",
    +  "robotframework[rst]",
    +  "typing-extensions >=4.13",
    +]
    +
     [tool.black]
     line_length = 88
     # When we add [project] with requires-python, remove this and Ruff's target-version
    diff --git a/setup.py b/setup.py
    index 953f05124..1bf5be726 100755
    --- a/setup.py
    +++ b/setup.py
    @@ -48,7 +48,25 @@ PACKAGE_DATA = [
         for directory in ("rebot", "libdoc", "testdoc", "lib", "common")
         for pattern in ("*.html", "*.css", "*.js")
     ] + ["api/py.typed", "logo.png"]
    -
    +EXTRAS = {
    +    "highlight": [
    +        "pygments >=2.8"
    +    ],
    +    "md": [
    +        "markdown",
    +        "robotframework[highlight]",
    +    ],
    +    "rst": [
    +        "docutils >=0.10",
    +        "robotframework[highlight]",
    +    ],
    +    "xml": [
    +        "lxml",
    +    ],
    +    "yaml": [
    +        "pyyaml",
    +    ],
    +}
     
     setup(
         name="robotframework",
    @@ -82,4 +100,5 @@ setup(
                 "libdoc = robot.libdoc:libdoc_cli",
             ]
         },
    +    extras_require=EXTRAS,
     )

    The above builds and does a dev install for python 3.9-3.14:

    • 3.8: no version of a compatible pip which supports dependency-groups
    • 3.15rc: pyyaml doesn't yet ship 3.15 wheels

    This is all based on manual inspection of the .txt, some references in docs, etc. Again, happy to start a PR where it might be easier to discuss particular lines.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions