Extracts the Python project name and derives the Python package name.
The action probes the project for metadata in the following order, selecting the first source that yields a project name. The action skips a present source that carries no usable name and continues with the next one:
pyproject.toml—[project] name(PEP 621, preferred)setup.cfg—[metadata] name(legacy pbr / setuptools projects)setup.py—name="…"literal (legacy setuptools)
This tolerates a pyproject.toml that contains a [build-system]
table (PEP 517) but no [project] name — the common pbr / setuptools
layout — by falling through to setup.cfg and then setup.py rather
than aborting. If no source yields a name, the action fails rather
than emitting an empty value.
The setup.cfg and setup.py paths exist to support legacy projects
(e.g. those still using pbr) that have not migrated to PEP 621
metadata in pyproject.toml.
An example workflow step using this action:
steps:
# Code checkout performed in earlier step
- name: Fetch Python project/package name
uses: lfreleng-actions/python-project-name-action@main| Variable Name | Required | Description |
|---|---|---|
| PATH_PREFIX | False | Path/directory to Python project code |
| Output Variable | Mandatory | Value |
|---|---|---|
python_project_file |
Yes | File used to extract metadata: pyproject.toml/setup.cfg/setup.py |
python_project_name |
Yes | Extracted from pyproject.toml, setup.cfg or setup.py |
python_package_name |
Yes | Derived from the project name (dashes become underscores) |
source |
Yes | Source file used (pyproject.toml, setup.cfg or setup.py) |
The action also exports the same values as environment variables (lowercase names) for use in later steps within the same job.