pypi

package
v0.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 4, 2026 License: MIT Imports: 45 Imported by: 0

Documentation

Overview

Package pypi serves PyPI repositories at /artifactory/api/pypi/{repoKey}/ through the router kit (decisions 0032 and 0037): the simple repository API that pip, uv and Poetry install from, in HTML (PEP 503) and, when pypi.simple_json is on, JSON (PEP 691), with the wheels' core metadata files (PEP 658) when pypi.core_metadata is on, and the files themselves through the item routes' download, so redirects, Range and download counts apply to them as to any file. The pages are built on each request from what the PyPI format keeps in the package index; nothing is stored for them.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func JSONMetadata

func JSONMetadata(
	ctx context.Context,
	st store.Store,
	key, name, version, base string,
	reads Reads,
) (map[string]any, error)

JSONMetadata builds the Warehouse-shaped document from the caller's visible index. Filtering precedes version and metadata selection, so neither a hidden newer release nor the metadata of a hidden earlier file can leak.

func Protocol

func Protocol(o Options) pkgroute.Protocol

Protocol is the PyPI protocol. Its errors are in Artifactory's envelope, as every 7.x answer under /api/pypi/ is (decision 0037); pip, uv and twine read only the status. The reindex is not reserved: a GET of "reindex" names a file at the repository's root, while the operation's own POST reaches the generated server ahead of the kit.

func RepoURL

func RepoURL(base, key string) string

RepoURL is the URL of the repository key under /api/pypi/ at base, the server's base URL.

func WriteMetadata

func WriteMetadata(w http.ResponseWriter, doc map[string]any, head bool) error

WriteMetadata gives generated GET and kit HEAD the same representation headers, including its byte length even when no body is sent.

Types

type Options

type Options struct {
	// Format are the PyPI format's settings, whose SimpleJSON and
	// CoreMetadata decide what the simple index answers.
	Format pypifmt.Settings
	// RemoteSources opts the native protocol into remote metadata and artifact reads.
	RemoteSources *source.Service
}

Options are the PyPI protocol's settings.

type Reads

type Reads func(path string) bool

Reads tells whether the caller may read the file at a path of the repository a request names.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL