Skip to main content

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

GitHub | PyPI | Issues | Changelog

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.

Installation

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

python3 -m pip install entry-points-txt

API

EntryPoint

class EntryPoint

A representation of an entry point as a dataclass. 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 attribute reference (the part before the colon)

attr: str | None

The attribute/object portion of the attribute 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

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:attr [extras]

EntryPointSet

EntryPointSet = dict[str, dict[str, EntryPoint]]

An alias for the return type of load() & loads() and the argument type of dump() & dumps(). Entry points are organized into a dict that maps group names to sub-dicts that map entry point names to EntryPoint instances.

load()

entry_points_txt.load(fp: IO[str]) -> EntryPointSet

Parse a file-like object as an entry_points.txt-format file and return the results.

For example, the following input:

[console_scripts]
foo = package.__main__:main
bar = package.cli:klass.attr

[thingy.extension]
quux = package.thingy [xtr]

would be parsed as:

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

loads()

entry_points_txt.loads(s: str) -> EntryPointSet

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

dump()

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

Write a collection of entry points 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.

dumps()

entry_points_txt.dumps(eps: EntryPointSet) -> str

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

dump_list()

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.

dumps_list()

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

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

ParseError

class ParseError(ValueError)

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

Release files for entry-points-txt 0.3.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for entry-points-txt 0.3.0
File Size Uploaded
entry_points_txt-0.3.0.tar.gz 8.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for entry-points-txt 0.3.0
File Interpreter ABI Platform
entry_points_txt-0.3.0-py3-none-any.whl Python 3 none any Details

Total release size: 15.5 kB

Release files / entry_points_txt-0.3.0.tar.gz

Download URL entry_points_txt-0.3.0.tar.gz
Size 8.7 kB
Tags Source
SHA-256 checksum
How to use checksums
957f508508a761671f18870edd9deb83b36844c66251e9c8a0df55ee8ae0bf52
BLAKE2b-256 checksum
How to use checksums
fdbb17cd6dfa33fc2c247981b28e5edc0794c7d9f312767ce46caf56609eec07
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.0

Release files / entry_points_txt-0.3.0-py3-none-any.whl

Download URL entry_points_txt-0.3.0-py3-none-any.whl
Size 6.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
690a9335a17ded03ed221c2019c28094e74a9ea734931bd6ee6d853e58caa90a
BLAKE2b-256 checksum
How to use checksums
2a39a48a490970eb45e592b29c2732bcadc889d87ff0d8a15737230c60c516de
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.0

Release history Release notifications | RSS feed

This release

0.3.0 This release

2 release files

0.2.1

2 release files

0.2.0

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page