scippneutron.metadata.Software#

class scippneutron.metadata.Software(**data)[source]#

A piece of software.

The piece of software should be specified as precisely as possible. For example, a release version of ScippNeutron could be specified as follows:

>>> from scippneutron.metadata import Software
>>> software = Software(
...     name='ScippNeutron',
...     version='24.11.0',
...     url='https://github.com/scipp/scippneutron/releases/tag/24.11.0',
...     doi='https://doi.org/10.5281/zenodo.14139599',
... )

A development version might include a Git hash in the version. Alternative methods can be used for projects that do not use Git. But the software should be specified as precisely as possible. For example:

>>> software = Software(
...     name='ScippNeutron',
...     version='24.11.1.dev8+g10d09ab0',
...     url='https://github.com/scipp/scippneutron',
... )

The URL can either point to the source code, a release artifact, or a package index, such as pypi.org or anaconda.org.

Attributes

compact_repr

A representation of this software as a single short string.

model_computed_fields

model_config

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

model_extra

Get extra fields set during validation.

model_fields

model_fields_set

Returns the set of fields that have been explicitly set on this model instance.

name_version

The name and version of the software, separated by a space.

name

Name of the piece of software.

version

Complete version of the piece of software.

url

URL to the concrete version of the software.

doi

DOI of the concrete version of the software.

property compact_repr: str#

A representation of this software as a single short string.

doi: str | None#

DOI of the concrete version of the software.

If there is no DOI for the concrete version, a general DOI for the software may be used.

classmethod from_package_metadata(package_name)[source]#

Construct a Software instance from the metadata of an installed package.

This function attempts to deduce all information it can from package metadata. But it only has access to the information that is encoded in the package. It therefore returns the base project URL instead of a concrete release URL, and it does not return a DOI.

Parameters:

package_name (str) – The name of the Python package.

Returns:

Software – A Software instance.

model_config: ClassVar[ConfigDict] = {}#

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

name: str#

Name of the piece of software.

property name_version: str#

The name and version of the software, separated by a space.

url: str | None#

URL to the concrete version of the software.

If no URL for a concrete version is available, a URL of the project or source code may be used.

version: str#

Complete version of the piece of software.