Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

python3Packages.bootstrapped-build: to replace pip #105714

Closed
wants to merge 3 commits into from

Conversation

FRidh
Copy link
Member

@FRidh FRidh commented Dec 2, 2020

build is a lightweight PEP 517 frontend for building wheels that could
replace pip for this purpose.

installer is a new project for installing wheels.

Why replace pip with build and installer? pip has a large
codebase doing many more things, and it vendors its dependencies.

See also https://github.com/FFY00/python-bootstrap

Might become significantly simpler if pypa/flit#511 is merged.

Things done
  • Tested using sandboxing (nix.useSandbox on NixOS, or option sandbox in nix.conf on non-NixOS linux)
  • Built on platform(s)
    • NixOS
    • macOS
    • other Linux distributions
  • Tested via one or more NixOS test(s) if existing and applicable for the change (look inside nixos/tests)
  • Tested compilation of all pkgs that depend on this change using nix-shell -p nixpkgs-review --run "nixpkgs-review wip"
  • Tested execution of all binary files (usually in ./result/bin/)
  • Determined the impact on package closure size (by running nix path-info -S before and after)
  • Ensured that relevant documentation is up to date
  • Fits CONTRIBUTING.md.

TODO

substitutions = {
inherit pythonInterpreter pythonSitePackages;
};
} ./build-build-hook.sh) {};
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

haven't implemented yet

runHook preInstall

export PYTHONPATH="$(ls | tr '\n' '\:'):''${PYTHONPATH:-}"
for pkg in $(find . -mindepth 1 -maxdepth 1 -type d -exec basename {} \;); do
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for every runtime dep of build we create a wheel and install it. This requires the build backends to be available already. We probably end up needing to add setuptools and flit here as well.

@@ -46,6 +46,15 @@ in rec {
};
} ./flit-build-hook.sh) {};

buildBuildHook = callPackage ({ build, wheel }:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That name is not that nice.

@stale
Copy link

stale bot commented Jul 19, 2021

I marked this as stale due to inactivity. → More info

@stale stale bot added the 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md label Jul 19, 2021
@stale stale bot removed the 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md label Jan 16, 2022
@FRidh
Copy link
Member Author

FRidh commented Jan 16, 2022

Managed to get bootstrapping going with build and installer!

Copy link
Member

@SuperSandro2000 SuperSandro2000 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

some random style comments mostly for when you are done with the implementation.

Comment on lines 59 to 62
export PYTHONPATH="$(pwd)/installer/src:$(pwd)/wheel/src:$(pwd)/build/src:$(pwd)/setuptools/pkg_resources:$PYTHONPATH"

'';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
export PYTHONPATH="$(pwd)/installer/src:$(pwd)/wheel/src:$(pwd)/build/src:$(pwd)/setuptools/pkg_resources:$PYTHONPATH"
'';
export PYTHONPATH="$(pwd)/installer/src:$(pwd)/wheel/src:$(pwd)/build/src:$(pwd)/setuptools/pkg_resources:$PYTHONPATH"
'';


postFixup = ''
wrapPythonPrograms
'';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
'';
'';
meta = {
description = "Package for bootstrapping the Python packages set.";
maintainers = [ lib.maintainers.fridh ];
};

# json = builtins.toFile "instructions.json" (builtins.toJSON data);
srcs = with lib; catAttrs "src" runtimeDeps;
in stdenv.mkDerivation rec {
name = "${python.libPrefix}-bootstrapped-build-installer";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it would be nice if we had some version attribute but honestly I have no idea what we should use because this is just a collection of files.

installer
];
# runtimeDeps = lib.remove python (requiredPythonModules [ build installer setuptools wheel ]);
data = map (drv: lib.getAttrs ["pname" "src" ] drv) runtimeDeps;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
data = map (drv: lib.getAttrs ["pname" "src" ] drv) runtimeDeps;
data = map (drv: lib.getAttrs [ "pname" "src" ] drv) runtimeDeps;

Comment on lines +83 to +86
if [[ -d $pkg ]]; then
echo "Building $pkg wheel"
${python.pythonForBuild.interpreter} -m build --wheel "$pkg" --no-isolation --skip-dependency-check
fi
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Normally shell inside of nix files is intended with 2 spaces.

strictDeps = true;

nativeBuildInputs = [
unzip
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not needed

@FRidh FRidh mentioned this pull request Jan 17, 2022
13 tasks
@stale stale bot added the 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md label Jul 31, 2022
@stale stale bot removed the 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md label Oct 27, 2022
@ofborg ofborg bot requested a review from veehaitch October 27, 2022 16:21
@FRidh
Copy link
Member Author

FRidh commented Aug 1, 2023

Superseded by #245509

@FRidh FRidh closed this Aug 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants