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

python: colocate sitecustomize with python derivation output #377

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions pkgs/modules/python/default.nix
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{ python, pypkgs }:
{ pkgs-unstable, pkgs-23_05, lib, ... }:
{ pkgs-unstable, lib, ... }:
let
pythonVersion = lib.versions.majorMinor python.version;

Expand Down Expand Up @@ -90,7 +90,6 @@ let
};
};

python3-wrapper = pythonWrapper { bin = "${python}/bin/python3"; name = "python3"; aliases = [ "python" "python${pythonVersion}" ]; };

poetry-wrapper = pythonWrapper { bin = "${poetry}/bin/poetry"; name = "poetry"; };

Expand All @@ -100,6 +99,14 @@ let

sitecustomize = pkgs.callPackage ./sitecustomize.nix { };

sitecustomized-python = pkgs.runCommand "python-replit-sitecustomized" {} ''
ls -al ${python.outPath}
${pkgs.rsync}/bin/rsync -av --chown=$USER --chmod=+w ${python.outPath}/ $out/
Copy link
Contributor

Choose a reason for hiding this comment

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

I am baffled that this is the only way. Doesn't this double the disk required for all python packages?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ooooh i think you're right, i don't actually force this python's usage anywhere. i'll fix that in the morning

rm -f $out/${python.sitePackages}/sitecustomize.py
cp ${sitecustomize}/sitecustomize.py $out/${python.sitePackages}/sitecustomize.py
'';

python3-wrapper = pythonWrapper { bin = "${sitecustomized-python}/bin/python3"; name = "python3"; aliases = [ "python" "python${pythonVersion}" ]; };
in
{
id = "python-${pythonVersion}";
Expand Down Expand Up @@ -158,7 +165,7 @@ in
POETRY_USE_USER_SITE = "1";
PIP_CONFIG_FILE = pip.config.outPath;
PYTHONUSERBASE = userbase;
PYTHONPATH = "${sitecustomize}:${pip.pip}/${python.sitePackages}";
PYTHONPATH = "${pip.pip}/${python.sitePackages}";
REPLIT_PYTHONPATH = "${userbase}/${python.sitePackages}:${pypkgs.setuptools}/${python.sitePackages}";
# Even though it is set-default in the wrapper, add it to the
# environment too, so that when someone wants to override it,
Expand Down
Loading