conda_pupa

build

Create .conda packages from wheels.

Create wheels from pypa projects.

conda_pupa.build.build_conda(whl, build_path: Path, output_path: Path, python_executable, project_path: Path | None = None, is_editable=False)
conda_pupa.build.build_pypa(path: Path, output_path, prefix: Path, distribution='editable')
Parameters:

distribution – “editable” or “wheel”

conda_pupa.build.filter(tarinfo)

Anonymize uid/gid; exclude .git directories.

conda_pupa.build.flatten(iterable)
conda_pupa.build.json_dumps(object)

Consistent json formatting.

conda_pupa.build.paths_json(base: Path | str)

Build simple paths.json with only ‘hardlink’ or ‘symlink’ types.

conda_pupa.build.pypa_to_conda(project, prefix: Path, distribution='editable', output_path: Path | None = None)
conda_pupa.build.update_RECORD(record_path: Path, base_path: Path, changed_path: Path)

Rewrite RECORD with new size, checksum for updated_file.

conda_build_utils

class conda_pupa.conda_build_utils.PathType(*values)

Bases: Enum

Refers to if the file in question is hard linked or soft linked. Originally designed to be used in paths.json

directory = 'directory'
linked_package_record = 'linked_package_record'
pyc_file = 'pyc_file'
unix_python_entry_point = 'unix_python_entry_point'
windows_python_entry_point_exe = 'windows_python_entry_point_exe'
windows_python_entry_point_script = 'windows_python_entry_point_script'
conda_pupa.conda_build_utils.sha256_checksum(filename, entry: DirEntry | None = None, buffersize=262144)

translate

Convert Python *.dist-info/METADATA to conda info/index.json

class conda_pupa.translate.CondaMetadata(metadata: importlib.metadata._meta.PackageMetadata, console_scripts: list[str], package_record: conda_pupa.translate.PackageRecord, about: dict[str, Any])

Bases: object

about: dict[str, Any]
console_scripts: list[str]
classmethod from_distribution(distribution: Distribution)

info/link.json used for console scripts; None if empty.

Note the METADATA file aka PackageRecord does not list console scripts.

metadata: PackageMetadata
package_record: PackageRecord
class conda_pupa.translate.FileDistribution(*args, **kwargs)

Bases: Distribution

From a file e.g. a single .metadata fetched from pypi instead of a *.dist-info folder.

locate_file(path)

Given a path to a file in this distribution, return a path to it.

read_text(filename: str) str | None

Attempt to load metadata file given by the name.

Parameters:

filename – The name of the file in the distribution info.

Returns:

The text if found, otherwise None.

class conda_pupa.translate.PackageRecord(name: str, version: str, subdir: str, depends: list[str], extras: dict[str, list[str]], build_number: int = 0, build_text: str = 'pupa', license_family: str = '', license: str = '', noarch: str = '', timestamp: int = 0)

Bases: object

property build
build_number: int = 0
build_text: str = 'pupa'
depends: list[str]
extras: dict[str, list[str]]
license: str = ''
license_family: str = ''
name: str
noarch: str = ''
property stem
subdir: str
timestamp: int = 0
to_index_json()
version: str
conda_pupa.translate.conda_to_pypi_name(name: str)
conda_pupa.translate.conda_to_requires(matchspec: MatchSpec)
conda_pupa.translate.pypi_to_conda_name(pypi_name: str)
conda_pupa.translate.requires_to_conda(requires: list[str] | None)

editable

Convert a dependency tree from pypi into .conda packages

class conda_pupa.convert_tree.ConvertTree(prefix: Path | str | None, override_channels=False, repo: Path | None = None, finder: PackageFinder | None = None)

Bases: object

convert_tree(requested: list[MatchSpec], max_attempts=20)
default_package_finder()
class conda_pupa.convert_tree.ReloadingLibMambaSolver(prefix: os.PathLike | str, channels: Iterable[Channel | str], subdirs: Iterable[str] = (), specs_to_add: Iterable[MatchSpec | str] = (), specs_to_remove: Iterable[MatchSpec | str] = (), repodata_fn: str = 'repodata.json', command: str | _Null = <conda.auxlib._Null object>)

Bases: LibMambaSolver

Reload channels as we add newly converted packages. LibMambaIndexHelper appears to be addressing C++ singletons or global state.

conda_pupa.convert_tree.parse_libmamba_error(message: str)

Parse missing packages out of LibMambaUnsatisfiableError message.

index

Interface to conda-index.

conda_pupa.index.update_index(path)

installer

Install a wheel / install a conda.

conda_pupa.installer.install_ephemeral_conda(prefix: Path, package: Path)

Install [editable] conda package without adding it to the environment’s package cache, since we don’t want to accidentally re-install “a link to a source checkout” elsewhere.

Installing packages directly from a file does not resolve dependencies. Should we automatically install the project’s dependencies also?

conda_pupa.installer.install_installer(python_executable: str, whl: Path, build_path: Path)
conda_pupa.installer.install_pip(python_executable: str, whl: Path, build_path: Path)

downloader

Fetch matching wheels from pypi.

conda_pupa.downloader.find_and_fetch(finder: PackageFinder, target: Path, package: str)

Find package on PyPI, download best link to target.

conda_pupa.downloader.find_package(finder: PackageFinder, package: str)

Convert :package: to MatchSpec; return best Link.

conda_pupa.downloader.get_package_finder(prefix: Path)

Finder with prefix’s Python, not our Python.

synth