distributions

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Jan 27, 2025 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DistExtensions = map[string]string{
	".whl":     "bdist_wheel",
	".tar.bz2": "sdist",
	".tar.gz":  "sdist",
	".zip":     "sdist",
}
View Source
var HeaderAttrs = map[string][]HeaderAttr{
	"1.0": HeaderAttrs1_0,
	"1.1": HeaderAttrs1_1,
	"1.2": HeaderAttrs1_2,
	"2.0": HeaderAttrs2_0,
	"2.1": HeaderAttrs2_1,
	"2.2": HeaderAttrs2_2,
	"2.3": HeaderAttrs2_3,
	"2.4": HeaderAttrs2_4,
}
View Source
var HeaderAttrs1_0 = []HeaderAttr{
	{"Metadata-Version", "metadata_version", false},
	{"Name", "name", false},
	{"Version", "version", false},
	{"Platform", "platform", true},
	{"Supported-Platform", "supported_platform", true},
	{"Summary", "summary", false},
	{"Description", "description", false},
	{"Keywords", "keywords", false},
	{"Home-Page", "home_page", false},
	{"Author", "author", false},
	{"Author-Email", "author_email", false},
	{"License", "license", false},
}
View Source
var HeaderAttrs1_1 = append(HeaderAttrs1_0, []HeaderAttr{
	{"Classifier", "classifiers", true},
	{"Download-Url", "download_url", false},
	{"Requires", "requires", true},
	{"Provides", "provides", true},
	{"Obsoletes", "obsoletes", true},
}...)
View Source
var HeaderAttrs1_2 = append(HeaderAttrs1_1, []HeaderAttr{
	{"Maintainer", "maintainer", false},
	{"Maintainer-Email", "maintainer_email", false},
	{"Requires-Python", "requires_python", false},
	{"Requires-External", "requires_external", true},
	{"Requires-Dist", "requires_dist", true},
	{"Provides-Dist", "provides_dist", true},
	{"Obsoletes-Dist", "obsoletes_dist", true},
	{"Project-Url", "project_urls", true},
}...)
View Source
var HeaderAttrs2_0 = HeaderAttrs1_2 //XXX PEP 426?
View Source
var HeaderAttrs2_1 = append(HeaderAttrs1_2, []HeaderAttr{
	{"Provides-Extra", "provides_extra", true},
	{"Description-Content-Type", "description_content_type", false},
}...)
View Source
var HeaderAttrs2_2 = append(HeaderAttrs2_1, HeaderAttr{"Dynamic", "dynamic", true}) // PEP 643
View Source
var HeaderAttrs2_3 = HeaderAttrs2_2 // PEP 685
View Source
var HeaderAttrs2_4 = append(HeaderAttrs2_3, []HeaderAttr{
	{"License-Expression", "license_expression", false},
	{"License-File", "license_file", false},
}...)

Functions

func SafeName

func SafeName(name string) string

Convert an arbitrary string to a standard distribution name. Any runs of non-alphanumeric/. characters are replaced with a single '-'. Copied from pkg_resources.safe_name for compatibility with warehouse. See https://github.com/pypa/twine/issues/743.

func StructToMap

func StructToMap(input interface{}) map[string][]string

Types

type BaseDistribution

type BaseDistribution struct {
	MetadataVersion string `json:"metadata_version"`
	// version 1.0
	Name               string   `json:"name"`
	Version            string   `json:"version"`
	Platforms          []string `json:"platform"`
	SupportedPlatforms []string `json:"supported_platform"`
	Summary            string   `json:"summary"`
	Description        string   `json:"description"`
	Keywords           string   `json:"keywords"`
	HomePage           string   `json:"home_page"`
	DownloadURL        string   `json:"download_url"`
	Author             string   `json:"author"`
	AuthorEmail        string   `json:"author_email"`
	License            string   `json:"license"`
	// version 1.1
	Classifiers []string `json:"classifiers"`
	Requires    []string `json:"requires"`
	Provides    []string `json:"provides"`
	Obsoletes   []string `json:"obsoletes"`
	// version 1.2
	Maintainer       string   `json:"maintainer"`
	MaintainerEmail  string   `json:"maintainer_email"`
	RequiresPython   string   `json:"requires_python"`
	RequiresExternal []string `json:"requires_external"`
	RequiresDist     []string `json:"requires_dist"`
	ProvidesDist     []string `json:"provides_dist"`
	ObsoletesDist    []string `json:"obsoletes_dist"`
	ProjectURLs      []string `json:"project_urls"`
	// version 2.1
	ProvidesExtras         []string `json:"provides_extra"`
	DescriptionContentType string   `json:"description_content_type"`
	// version 2.2
	Dynamic []string `json:"dynamic"`
	// version 2.4
	LicenseExpression string `json:"license_expression"`
	LicenseFile       string `json:"license_file"`
}

func (*BaseDistribution) GetHeaderAttrs

func (bd *BaseDistribution) GetHeaderAttrs() ([]HeaderAttr, error)

func (*BaseDistribution) GetName

func (bd *BaseDistribution) GetName() string

func (*BaseDistribution) GetPythonVersion

func (bd *BaseDistribution) GetPythonVersion() string

TODO: remember to implement this for other distributions if they need something more specific (e.g. Wheels)

func (*BaseDistribution) GetVersion

func (bd *BaseDistribution) GetVersion() string

func (*BaseDistribution) Parse

func (bd *BaseDistribution) Parse(data []byte) error

type Distribution

type Distribution interface {
	ExtractMetadata() error
	Parse(data []byte) error

	// GetName is a helper method to get values
	GetName() string
	GetVersion() string
	GetPythonVersion() string

	// MetadataMap is used to return a map of all the metadata,
	// similar to how twine passes the metadata in a multipart
	// form request.
	MetadataMap() map[string][]string
}

func NewDistributionMetadata

func NewDistributionMetadata(filename string) (Distribution, string, string, error)

func NewSDist

func NewSDist(filename string) (Distribution, error)

func NewWheel

func NewWheel(filename string) (Distribution, error)

type HeaderAttr

type HeaderAttr struct {
	HeaderName string
	AttrName   string
	Multiple   bool
}

type SDist

type SDist struct {
	BaseDistribution
	Filename string `json:"file_name"`
}

func (*SDist) ExtractMetadata

func (sd *SDist) ExtractMetadata() error

func (*SDist) MetadataMap

func (sd *SDist) MetadataMap() map[string][]string

type Wheel

type Wheel struct {
	BaseDistribution
	Filename     string `json:"file_name"`
	BaseFilename string `json:"base_filename"`
}

func (*Wheel) ExtractMetadata

func (whl *Wheel) ExtractMetadata() error

func (*Wheel) GetPythonVersion

func (whl *Wheel) GetPythonVersion() string

func (*Wheel) MetadataMap

func (whl *Wheel) MetadataMap() map[string][]string

Jump to

Keyboard shortcuts

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