Skip to main content

Read & write entry_points.txt files

Project description

Project Status: Active — The project has reached a stable, usable state and is being actively developed. MIT License

GitHub | PyPI | Issues

entry-points-txt provides functions for reading & writing entry_points.txt files according to the spec. That is the one thing it does, and it endeavors to do it well.


entry-points-txt requires Python 3.6 or higher. Just use pip for Python 3 (You have pip, right?) to install entry-points-txt:

python3 -m pip install entry-points-txt



class EntryPoint(NamedTuple)

A representation of an entry point as a namedtuple. Instances have the following attributes and methods:

group: str
The name of the entry point group (e.g., "console_scripts")
name: str
The name of the entry point
module: str
The module portion of the object reference (the part before the colon)
object: Optional[str]
The object/attribute portion of the object reference (the part after the colon), or None if not specified
extras: Tuple[str, ...]
Extras required for the entry point
load() -> Any
Returns the object referred to by the entry point’s object reference
to_line() -> str
Returns the representation of the entry point as a line in entry_points.txt, i.e., a line of the form name = module:object [extras]


entry_points_txt.load(fp: IO[str]) -> Dict[str, Dict[str, EntryPoint]]

Parse a file-like object as an entry_points.txt-format file and return the results. The parsed entry points are returned in a dict mapping each group name to a dict mapping each entry point name to an EntryPoint object.

For example, the following input:

foo = package.__main__:main
bar = package.cli:klass.attr

quux = package.thingy [xtr]

would be parsed as:

    "console_scripts": {
        "foo": EntryPoint(group="console_scripts", name="foo", module="package.__main__", object="main", extras=()),
        "bar": EntryPoint(group="console_scripts", name="bar", module="package.cli", object="klass.attr", extras=()),
    "thingy.extension": {
        "quux": EntryPoint(group="thingy.extension", name="quux", module="package.thingy", object=None, extras=("xtr",)),


entry_points_txt.loads(s: str) -> Dict[str, Dict[str, EntryPoint]]

Like load(), but reads from a string instead of a filehandle


entry_points_txt.dump(eps: Dict[str, Dict[str, EntryPoint]], fp: IO[str]) -> None

Write a collection of entry points (in the same structure as returned by load()) to a file-like object in entry_points.txt format. A ValueError is raised and nothing is written if the group or name key under which an EntryPoint is located does not match its group or name attribute.


entry_points_txt.dumps(eps: Dict[str, Dict[str, EntryPoint]]) -> str

Like dump(), but returns a string instead of writing to a filehandle


entry_points_txt.dump_list(eps: Iterable[EntryPoint], fp: IO[str]) -> None

Write an iterable of entry points to a file-like object in entry_points.txt format. If two or more entry points have the same group & name, only the last one will be output.


entry_points_txt.dumps_list(eps: Iterable[EntryPoint]) -> str

Like dump_list(), but returns a string instead of writing to a filehandle


class ParseError(ValueError)

Exception raised by load() or loads() when given invalid input

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for entry-points-txt, version 0.1.0
Filename, size File type Python version Upload date Hashes
Filename, size entry_points_txt-0.1.0-py3-none-any.whl (6.9 kB) File type Wheel Python version py3 Upload date Hashes View
Filename, size entry-points-txt-0.1.0.tar.gz (8.8 kB) File type Source Python version None Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring DigiCert DigiCert EV certificate Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page