or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

Files

docs

core-info.mddata-sources.mdindex.mdlinux-distribution.mdversion-components.md

core-info.mddocs/

0

# Core Distribution Information

1

2

Essential functions for identifying and describing the operating system distribution. These functions provide the primary interface for getting distribution identity, names, versions, and related information.

3

4

## Capabilities

5

6

### Distribution ID

7

8

Returns the machine-readable distribution identifier, normalized across different data sources.

9

10

```python { .api }

11

def id() -> str:

12

"""

13

Return the distribution ID in lower case.

14

15

For example: 'ubuntu', 'centos', 'debian', 'fedora', 'rhel', 'opensuse'

16

17

The ID is obtained from os-release, lsb_release, or distro release files,

18

with normalization applied via NORMALIZED_OS_ID, NORMALIZED_LSB_ID,

19

and NORMALIZED_DISTRO_ID tables.

20

21

Returns:

22

str: Machine-readable distribution ID

23

"""

24

```

25

26

Usage example:

27

```python

28

import distro

29

30

dist_id = distro.id()

31

print(f"Distribution ID: {dist_id}") # e.g., "ubuntu"

32

```

33

34

### Distribution Name

35

36

Returns the human-readable distribution name, with optional pretty formatting.

37

38

```python { .api }

39

def name(pretty: bool = False) -> str:

40

"""

41

Return the distribution name.

42

43

Args:

44

pretty: If True, include version and codename in the output

45

46

Returns:

47

str: Distribution name

48

49

Examples:

50

name() -> "Ubuntu"

51

name(pretty=True) -> "Ubuntu 20.04 LTS (Focal Fossa)"

52

"""

53

```

54

55

Usage examples:

56

```python

57

import distro

58

59

# Basic name

60

print(distro.name()) # "Ubuntu"

61

62

# Pretty formatted name with version and codename

63

print(distro.name(pretty=True)) # "Ubuntu 20.04 LTS (Focal Fossa)"

64

```

65

66

### Distribution Version

67

68

Returns the distribution version string with optional formatting and precision control.

69

70

```python { .api }

71

def version(pretty: bool = False, best: bool = False) -> str:

72

"""

73

Return the distribution version.

74

75

Args:

76

pretty: If True, include codename in parentheses

77

best: If True, return the most precise version from all sources

78

79

Returns:

80

str: Distribution version

81

82

Examples:

83

version() -> "20.04"

84

version(pretty=True) -> "20.04 (Focal Fossa)"

85

version(best=True) -> "20.04.3"

86

"""

87

```

88

89

Usage examples:

90

```python

91

import distro

92

93

# Basic version

94

print(distro.version()) # "20.04"

95

96

# Pretty version with codename

97

print(distro.version(pretty=True)) # "20.04 (Focal Fossa)"

98

99

# Most precise version available

100

print(distro.version(best=True)) # "20.04.3"

101

```

102

103

### Distribution Codename

104

105

Returns the distribution release codename.

106

107

```python { .api }

108

def codename() -> str:

109

"""

110

Return the distribution codename.

111

112

The codename is the release name given by the distribution maintainer,

113

such as "focal" for Ubuntu 20.04 or "buster" for Debian 10.

114

115

Returns:

116

str: Distribution codename, empty string if not available

117

118

Examples:

119

"focal", "buster", "tumbleweed", "rolling"

120

"""

121

```

122

123

Usage example:

124

```python

125

import distro

126

127

codename = distro.codename()

128

print(f"Codename: {codename}") # e.g., "focal"

129

```

130

131

### Like Distributions

132

133

Returns space-separated list of distributions that this distribution is based on or similar to.

134

135

```python { .api }

136

def like() -> str:

137

"""

138

Return the distribution's "like" attribute from os-release.

139

140

This indicates what other distributions this one is based on or compatible with.

141

Multiple distributions are space-separated.

142

143

Returns:

144

str: Space-separated list of like distributions

145

146

Examples:

147

"debian" (for Ubuntu)

148

"rhel centos fedora" (for Rocky Linux)

149

"" (empty for base distributions)

150

"""

151

```

152

153

Usage example:

154

```python

155

import distro

156

157

like = distro.like()

158

print(f"Based on: {like}") # e.g., "debian"

159

```

160

161

### Comprehensive Information

162

163

Returns complete distribution information as a structured dictionary.

164

165

```python { .api }

166

def info(pretty: bool = False, best: bool = False) -> InfoDict:

167

"""

168

Return comprehensive distribution information.

169

170

Args:

171

pretty: If True, use pretty formatting for name and version

172

best: If True, use most precise version available

173

174

Returns:

175

InfoDict: Dictionary containing all distribution information

176

177

Structure:

178

{

179

"id": str,

180

"version": str,

181

"version_parts": {

182

"major": str,

183

"minor": str,

184

"build_number": str

185

},

186

"like": str,

187

"codename": str

188

}

189

"""

190

```

191

192

Usage example:

193

```python

194

import distro

195

196

# Basic info

197

info = distro.info()

198

print(info)

199

# {

200

# "id": "ubuntu",

201

# "version": "20.04",

202

# "version_parts": {"major": "20", "minor": "04", "build_number": ""},

203

# "like": "debian",

204

# "codename": "focal"

205

# }

206

207

# Pretty formatted info

208

pretty_info = distro.info(pretty=True, best=True)

209

print(pretty_info["version"]) # "20.04.3 (Focal Fossa)"

210

```

211

212

## Types

213

214

```python { .api }

215

from typing import TypedDict

216

217

class VersionDict(TypedDict):

218

major: str

219

minor: str

220

build_number: str

221

222

class InfoDict(TypedDict):

223

id: str

224

version: str

225

version_parts: VersionDict

226

like: str

227

codename: str

228

```