Reference#

build#

Create .conda packages from wheels.

Create wheels from pypa projects.

conda_pypi.build.build_conda(whl, build_path, output_path, python_executable, project_path=None, is_editable=False)[source]#
Parameters:
  • build_path (Path)

  • output_path (Path)

  • project_path (Path | None)

Return type:

Path

conda_pypi.build.build_pypa(path, output_path, prefix, distribution='editable')[source]#
Parameters:
  • distribution – “editable” or “wheel”

  • path (Path)

  • prefix (Path)

conda_pypi.build.filter(tarinfo)[source]#

Anonymize uid/gid; exclude .git directories.

conda_pypi.build.flatten(iterable)[source]#
conda_pypi.build.json_dumps(object)[source]#

Consistent json formatting.

conda_pypi.build.paths_json(base)[source]#

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

Parameters:

base (Path | str)

conda_pypi.build.pypa_to_conda(project, prefix, distribution='editable', output_path=None)[source]#
Parameters:
  • prefix (Path)

  • output_path (Path | None)

conda_pypi.build.update_RECORD(record_path, base_path, changed_path)[source]#

Rewrite RECORD with new size, checksum for updated_file.

Parameters:
  • record_path (Path)

  • base_path (Path)

  • changed_path (Path)

conda_build_utils#

class conda_pypi.conda_build_utils.PathType(value)[source]#

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_pypi.conda_build_utils.sha256_checksum(filename, entry=None, buffersize=262144)[source]#
Parameters:

entry (DirEntry | None)

translate#

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

class conda_pypi.translate.CondaMetadata(metadata: importlib.metadata._meta.PackageMetadata, console_scripts: List[str], package_record: conda_pypi.translate.PackageRecord, about: Dict[str, Any])[source]#

Bases: object

Parameters:
  • metadata (PackageMetadata)

  • console_scripts (List[str])

  • package_record (PackageRecord)

  • about (Dict[str, Any])

about: Dict[str, Any]#
console_scripts: List[str]#
classmethod from_distribution(distribution)[source]#
Parameters:

distribution (Distribution)

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

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

Return type:

dict | None

metadata: PackageMetadata#
package_record: PackageRecord#
class conda_pypi.translate.FileDistribution(raw_text)[source]#

Bases: Distribution

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

locate_file(path)[source]#

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

read_text(filename)[source]#

Attempt to load metadata file given by the name.

Parameters:

filename (str) – The name of the file in the distribution info.

Returns:

The text if found, otherwise None.

Return type:

str | None

class conda_pypi.translate.PackageRecord(name: str, version: str, subdir: str, depends: List[str], extras: Dict[str, List[str]], build_number: int = 0, build_text: str = 'pypi', license_family: str = '', license: str = '', noarch: str = '', timestamp: int = 0)[source]#

Bases: object

Parameters:
  • name (str)

  • version (str)

  • subdir (str)

  • depends (List[str])

  • extras (Dict[str, List[str]])

  • build_number (int)

  • build_text (str)

  • license_family (str)

  • license (str)

  • noarch (str)

  • timestamp (int)

property build#
build_number: int = 0#
build_text: str = 'pypi'#
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()[source]#
version: str#
conda_pypi.translate.conda_to_pypi_name(name)[source]#
Parameters:

name (str)

conda_pypi.translate.conda_to_requires(matchspec)[source]#
Parameters:

matchspec (MatchSpec)

conda_pypi.translate.pypi_to_conda_name(pypi_name)[source]#
Parameters:

pypi_name (str)

conda_pypi.translate.requires_to_conda(requires)[source]#
Parameters:

requires (List[str] | None)

editable#

Convert a dependency tree from pypi into .conda packages

class conda_pypi.convert_tree.ConvertTree(prefix, override_channels=False, repo=None, finder=None)[source]#

Bases: object

Parameters:
  • prefix (Optional[Union[pathlib.Path, str]])

  • repo (Optional[pathlib.Path])

  • finder (Optional[PackageFinder])

convert_tree(requested, max_attempts=20)[source]#

Preform a solve on the list of requested packages and converts the full dependency tree to conda packages if required. The converted packages will be stored in the local conda-pypi channel.

Parameters:
  • requested (List[MatchSpec]) – The list of requested packages.

  • max_attempts (int) – max number of times to try to execute the solve.

Returns:

A two-tuple of PackageRef sequences. The first is the group of packages to remove from the environment, in sorted dependency order from leaves to roots. The second is the group of packages to add to the environment, in sorted dependency order from roots to leaves.

Return type:

tuple[tuple[PrefixRecord, …], tuple[PrefixRecord, …]] | None

default_package_finder()[source]#
class conda_pypi.convert_tree.ReloadingLibMambaSolver(prefix, channels, subdirs=(), specs_to_add=(), specs_to_remove=(), repodata_fn='repodata.json', command=<conda.auxlib._Null object>)[source]#

Bases: LibMambaSolver

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

Parameters:
  • prefix (PathType)

  • channels (Iterable[Channel | str])

  • subdirs (Iterable[str])

  • specs_to_add (Iterable[MatchSpec | str])

  • specs_to_remove (Iterable[MatchSpec | str])

  • repodata_fn (str)

  • command (str | _Null)

conda_pypi.convert_tree.parse_libmamba_error(message)[source]#

Parse missing packages out of LibMambaUnsatisfiableError message.

Parameters:

message (str)

index#

Interface to conda-index.

conda_pypi.index.update_index(path)[source]#

installer#

Install a wheel / install a conda.

conda_pypi.installer.install_ephemeral_conda(prefix, package)[source]#

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?

Parameters:
  • prefix (Path)

  • package (Path)

conda_pypi.installer.install_installer(python_executable, whl, build_path)[source]#
Parameters:
  • python_executable (str)

  • whl (Path)

  • build_path (Path)

conda_pypi.installer.install_pip(python_executable, whl, build_path)[source]#
Parameters:
  • python_executable (str)

  • whl (Path)

  • build_path (Path)

downloader#

Fetch matching wheels from pypi.

conda_pypi.downloader.find_and_fetch(finder, target, package)[source]#

Find package on PyPI, download best link to target.

Parameters:
  • finder (PackageFinder)

  • target (Path)

  • package (str)

conda_pypi.downloader.find_package(finder, package)[source]#

Convert :package: to MatchSpec; return best Link.

Parameters:
  • finder (PackageFinder)

  • package (str)

conda_pypi.downloader.get_package_finder(prefix, index_urls=('https://pypi.org/simple/',))[source]#

Finder with prefix’s Python, not our Python.

Parameters:
  • prefix (Path)

  • index_urls (Iterable[str])

Return type:

PackageFinder

synth#

Generate repodata.json converted from wheel metadata.

class conda_pypi.synth.Package(*, build='', build_number=0, depends=[], extras={}, md5=None, name='', sha256=None, size=0, subdir='', timestamp=0, version='')[source]#

Bases: BaseModel

Parameters:
  • build (str)

  • build_number (int)

  • depends (List[str])

  • extras (Dict[str, List[str]])

  • md5 (str | None)

  • name (str)

  • sha256 (str | None)

  • size (int)

  • subdir (str)

  • timestamp (int)

  • version (str)

build: str#
build_number: int#
depends: List[str]#
extras: Dict[str, List[str]]#
md5: str | None#
model_config: ClassVar[ConfigDict] = {}#

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

name: str#
sha256: str | None#
size: int#
subdir: str#
timestamp: int#
version: str#
class conda_pypi.synth.RepoData(*, info, packages, repodata_version)[source]#

Bases: BaseModel

Parameters:
  • info (dict)

  • packages (Dict[str, Package])

  • repodata_version (int)

info: dict#
model_config: ClassVar[ConfigDict] = {}#

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

packages: Dict[str, Package]#
repodata_version: int#
conda_pypi.synth.compatible_wheel(filename)[source]#

Compare filename with supported tags, determine if wheel is compatible.

An installer would rank the wheels based on the order of sys_tags().

conda_pypi.synth.create_api(config_file=<typer.models.OptionInfo object>, repo_dir=<typer.models.OptionInfo object>, populate=<typer.models.OptionInfo object>)[source]#

Create a repodata.json file based on the list of projects provided.

Parameters:
  • config_file (str)

  • repo_dir (str)

  • populate (bool)

conda_pypi.synth.extract_version_of_project(project_page, version, download, download_dir)[source]#

Extract the version and details of the project from the project page.

Parameters:
  • project_page (ProjectPage)

  • version (str)

  • download (bool)

  • download_dir (str)

conda_pypi.synth.pypi_simple()[source]#