diff --git a/komodo/build.py b/komodo/build.py index 3b2f61bc..5bf959eb 100644 --- a/komodo/build.py +++ b/komodo/build.py @@ -196,6 +196,11 @@ def make( fakeroot=".", ): pkgorder = list(pkgs.keys()) + # We only need to ensure that python is 'installed' first + pkgorder.remove("python") + pkgorder.insert(0, "python") + assert pkgorder[0] == "python" + fakeprefix = fakeroot + prefix shell(["mkdir -p", fakeprefix]) prefix = os.path.abspath(prefix) diff --git a/komodo/cli.py b/komodo/cli.py index 8a4b12bb..e5fcbfa4 100755 --- a/komodo/cli.py +++ b/komodo/cli.py @@ -132,7 +132,7 @@ def download_packages( repository_file_content: Mapping[str, Mapping[str, Union[str, Sequence[str]]]], download_destination: str, pip_executable: str = "pip", -) -> Dict[str, str]: +): """Downloads all PyPI packages to destination. Tries to download other packages to destination too. Git packages are collected, and a dict of all git hashes is returned. @@ -151,14 +151,14 @@ def download_packages( -- Dict of git hashes found """ - git_hashes = fetch( + git_hashes, pypi_packages = fetch( release_file_content, repository_file_content, outdir=download_destination, pip=pip_executable, ) - return git_hashes + return git_hashes, pypi_packages @profile_time("Building non-pip part of komodo in workspace") @@ -270,36 +270,20 @@ def apply_fallback_tmpdir_for_pip_if_set(tmp_dir: Optional[str] = None): @profile_time("pip install to final destination") def install_previously_downloaded_pip_packages( - release_file_content: Mapping[str, str], - repository_file_content: Mapping[str, Mapping[str, Union[str, Sequence[str]]]], - downloads_directory: str, - pip_executable: str, + pypi_packages: list[str], release_root: Path, ) -> None: - for pkg, ver in release_file_content.items(): - current = repository_file_content[pkg][ver] - if current["make"] != "pip": - continue - - package_name = current.get("pypi_package_name", pkg) - if ver == LATEST_PACKAGE_ALIAS: - ver = latest_pypi_version(package_name) - shell_input = [ - pip_executable, - f"install {package_name}=={strip_version(ver)}", - "--prefix", - str(release_root), - "--no-index", - "--no-deps", - "--ignore-installed", - "--no-compile", - # assuming fetch.py has done "pip download" to this directory: - f"--cache-dir {downloads_directory}", - f"--find-links {downloads_directory}", - ] - shell_input.append(current.get("makeopts")) - - print(shell(shell_input)) + shell_input = [ + "uv pip", + "install", + f"--python {str(release_root / "bin" / "python")}", + "--no-deps", + "--no-cache", + "--reinstall", + " ".join(pypi_packages), + ] + + print(shell(shell_input)) def run_post_installation_scripts_if_set( @@ -349,7 +333,7 @@ def _main(args: KomodoNamespace) -> None: data = Data(extra_data_dirs=args.extra_data_dirs) git_hashes = None if args.download or (not args.build and not args.install): - git_hashes = download_packages( + git_hashes, pypi_packages = download_packages( args.pkgs.content, args.repo.content, download_destination=args.downloads, @@ -391,10 +375,7 @@ def _main(args: KomodoNamespace) -> None: apply_fallback_tmpdir_for_pip_if_set(args.tmp) install_previously_downloaded_pip_packages( - args.pkgs.content, - args.repo.content, - downloads_directory=args.downloads, - pip_executable=args.pip, + pypi_packages, release_root=release_root, ) fixup_python_shebangs(args.prefix, args.release) diff --git a/komodo/data/setup-py.sh b/komodo/data/setup-py.sh index ae0b8c58..ffa3e757 100755 --- a/komodo/data/setup-py.sh +++ b/komodo/data/setup-py.sh @@ -52,10 +52,8 @@ while test $# -gt 0; do done unset DESTDIR -$PIP install $OPTS . \ - --ignore-installed \ - --root $FAKEROOT \ - --no-deps \ - --no-cache-dir \ - --no-compile \ - --prefix $PREFIX 1>&2 +uv pip install \ + --python $FAKEROOT/$PREFIX/bin/python \ + --no-deps \ + --no-cache \ + --reinstall . \ diff --git a/komodo/fetch.py b/komodo/fetch.py index 605bfc36..f32c4673 100644 --- a/komodo/fetch.py +++ b/komodo/fetch.py @@ -158,9 +158,9 @@ def fetch(pkgs, repo, outdir, pip="pip") -> dict: os.symlink(normalised_dir, pkgname) print(f"Downloading {len(pypi_packages)} pypi packages") - shell([pip, "download", "--no-deps", "--dest .", " ".join(pypi_packages)]) + # shell([pip, "download", "--no-deps", "--dest .", " ".join(pypi_packages)]) - return git_hashes + return git_hashes, pypi_packages if __name__ == "__main__":