Skip to content

PackageRecord#

PackageRecord #

A single record in the Conda repodata. A single record refers to a single binary distribution of a package on a Conda channel.

arch: Optional[str] property #

Optionally the architecture the package supports.

Examples#
>>> from rattler import PrefixRecord
>>> record = PrefixRecord.from_path(
...     "../test-data/conda-meta/libsqlite-3.40.0-hcfcfb64_0.json"
... )
>>> record.arch
'x86_64'
>>>

build: str property #

The build string of the package.

Examples#
>>> from rattler import PrefixRecord
>>> record = PrefixRecord.from_path(
...     "../test-data/conda-meta/libsqlite-3.40.0-hcfcfb64_0.json"
... )
>>> record.build
'hcfcfb64_0'
>>>

build_number: int property #

The build number of the package.

Examples#
>>> from rattler import PrefixRecord
>>> record = PrefixRecord.from_path(
...     "../test-data/conda-meta/libsqlite-3.40.0-hcfcfb64_0.json"
... )
>>> record.build_number
0
>>>

constrains: List[str] property #

Additional constraints on packages. Constrains are different from depends in that packages specified in depends must be installed next to this package, whereas packages specified in constrains are not required to be installed, but if they are installed they must follow these constraints.

Examples#
>>> from rattler import PrefixRecord
>>> record = PrefixRecord.from_path(
...     "../test-data/conda-meta/libsqlite-3.40.0-hcfcfb64_0.json"
... )
>>> record.constrains
[]
>>>

depends: List[str] property #

Specification of packages this package depends on.

Examples#
>>> from rattler import PrefixRecord
>>> record = PrefixRecord.from_path(
...     "../test-data/conda-meta/libsqlite-3.40.0-hcfcfb64_0.json"
... )
>>> record.depends
['ucrt >=10.0.20348.0', 'vc >=14.2,<15', 'vs2015_runtime >=14.29.30139']
>>>

features: Optional[str] property #

Features are a deprecated way to specify different feature sets for the conda solver. This is not supported anymore and should not be used. Instead, mutex packages should be used to specify mutually exclusive features.

legacy_bz2_md5: Optional[bytes] property #

A deprecated md5 hash.

legacy_bz2_size: Optional[int] property #

A deprecated package archive size.

license: Optional[str] property #

The specific license of the package.

Examples#
>>> from rattler import PrefixRecord
>>> record = PrefixRecord.from_path(
...     "../test-data/conda-meta/libsqlite-3.40.0-hcfcfb64_0.json"
... )
>>> record.license
'Unlicense'
>>>

license_family: Optional[str] property #

The license family.

Examples#
>>> from rattler import PrefixRecord
>>> record = PrefixRecord.from_path(
...     "../test-data/conda-meta/pip-23.0-pyhd8ed1ab_0.json"
... )
>>> record.license_family
'MIT'
>>>

md5: Optional[bytes] property #

Optionally a MD5 hash of the package archive.

Examples#
>>> from rattler import PrefixRecord
>>> record = PrefixRecord.from_path(
...     "../test-data/conda-meta/libsqlite-3.40.0-hcfcfb64_0.json"
... )
>>> record.md5.hex()
'5e5a97795de72f8cc3baf3d9ea6327a2'
>>>

name: PackageName property #

The name of the package.

Examples#
>>> from rattler import PrefixRecord
>>> record = PrefixRecord.from_path(
...     "../test-data/conda-meta/libsqlite-3.40.0-hcfcfb64_0.json"
... )
>>> record.name
PackageName("libsqlite")
>>>

noarch: Optional[str] property #

The noarch type of the package.

Examples#
>>> from rattler import PrefixRecord
>>> record = PrefixRecord.from_path(
...     "../test-data/conda-meta/libsqlite-3.40.0-hcfcfb64_0.json"
... )
>>> record.noarch
>>> record = PrefixRecord.from_path(
...     "../test-data/conda-meta/pip-23.0-pyhd8ed1ab_0.json"
... )
>>> record.noarch
'python'
>>>

platform: Optional[str] property #

Optionally the platform the package supports.

Examples#
>>> from rattler import PrefixRecord
>>> record = PrefixRecord.from_path(
...     "../test-data/conda-meta/libsqlite-3.40.0-hcfcfb64_0.json"
... )
>>> record.platform
'win32'
>>>

sha256: Optional[bytes] property #

Optionally a SHA256 hash of the package archive.

Examples#

```python

from rattler import PrefixRecord record = PrefixRecord.from_path( ... "../test-data/conda-meta/libsqlite-3.40.0-hcfcfb64_0.json" ... ) record.sha256.hex() '4e50b3d90a351c9d47d239d3f90fce4870df2526e4f7fef35203ab3276a6dfc9'

size: Optional[int] property #

Optionally the size of the package archive in bytes.

Examples#
>>> from rattler import PrefixRecord
>>> record = PrefixRecord.from_path(
...     "../test-data/conda-meta/libsqlite-3.40.0-hcfcfb64_0.json"
... )
>>> record.size
669941
>>>

subdir: str property #

The subdirectory where the package can be found.

Examples#
>>> from rattler import PrefixRecord
>>> record = PrefixRecord.from_path(
...     "../test-data/conda-meta/libsqlite-3.40.0-hcfcfb64_0.json"
... )
>>> record.subdir
'win-64'
>>>

timestamp: Optional[datetime.datetime] property #

The date this entry was created.

Examples#
>>> from rattler import PrefixRecord
>>> record = PrefixRecord.from_path(
...     "../test-data/conda-meta/libsqlite-3.40.0-hcfcfb64_0.json"
... )
>>> record.timestamp
datetime.datetime(2022, 11, 17, 15, 7, 19, 781000, tzinfo=datetime.timezone.utc)
>>>

track_features: List[str] property #

Track features are nowadays only used to downweight packages (ie. give them less priority). To that effect, the number of track features is counted (number of commas) and the package is downweighted by the number of track_features.

Examples#
>>> from rattler import PrefixRecord
>>> record = PrefixRecord.from_path(
...     "../test-data/conda-meta/libsqlite-3.40.0-hcfcfb64_0.json"
... )
>>> record.track_features
[]
>>>

version: VersionWithSource property #

The version of the package.

Examples#
>>> from rattler import PrefixRecord
>>> record = PrefixRecord.from_path(
...     "../test-data/conda-meta/libsqlite-3.40.0-hcfcfb64_0.json"
... )
>>> record.version
VersionWithSource(version="3.40.0", source="3.40.0")
>>>

__repr__() #

Returns a representation of the PackageRecord.

Examples#
>>> record = PackageRecord.from_index_json(
...     "../test-data/conda-meta/pysocks-1.7.1-pyh0701188_6.json"
... )
>>> record
PackageRecord("pysocks=1.7.1=pyh0701188_6")
>>>

__str__() #

Returns the string representation of the PackageRecord.

Examples#
>>> record = PackageRecord.from_index_json(
...     "../test-data/conda-meta/pysocks-1.7.1-pyh0701188_6.json"
... )
>>> str(record)
'pysocks=1.7.1=pyh0701188_6'
>>>

from_index_json(path, size=None, sha256=None, md5=None) staticmethod #

Builds a PackageRecord from an index.json. These can be found in info directory inside an extracted package archive.

Examples#
>>> record = PackageRecord.from_index_json(
...     "../test-data/conda-meta/pysocks-1.7.1-pyh0701188_6.json"
... )
>>> assert isinstance(record, PackageRecord)
>>>

matches(spec) #

Match a [PackageRecord] against a [MatchSpec].

sort_topologically(records) staticmethod #

Sorts the records topologically. This function is deterministic, meaning that it will return the same result regardless of the order of records and of the depends vector inside the records. Note that this function only works for packages with unique names.

Examples#
>>> from os import listdir
>>> from os.path import isfile, join
>>> from rattler import PrefixRecord
>>> records = [
...     PrefixRecord.from_path(join("../test-data/conda-meta/", f))
...     for f in listdir("../test-data/conda-meta")
...     if isfile(join("../test-data/conda-meta", f))
... ]
>>> sorted = PackageRecord.sort_topologically(records)
>>> sorted[0].name
PackageName("python_abi")
>>>

to_graph(records) staticmethod #

Converts a list of PackageRecords to a DAG (networkx.DiGraph). The nodes in the graph are the PackageRecords and the edges are the dependencies.

Examples#
import rattler
import asyncio
import networkx as nx
from matplotlib import pyplot as plt

records = asyncio.run(rattler.solve(['main'], ['python'], platforms=['osx-arm64', 'noarch']))
graph = rattler.PackageRecord.to_graph(records)

nx.draw(graph, with_labels=True, font_weight='bold')
plt.show()