clean(fetchPipMetadata): remove binary selection

...to simplify for now, we'll re-introduce it later
This commit is contained in:
phaer 2023-03-31 15:01:52 +02:00
parent 83b0d20809
commit 58b4ec80e5
2 changed files with 1 additions and 63 deletions

View File

@ -28,13 +28,6 @@
requirementsList ? [], requirementsList ? [],
# list of requirements.txt files # list of requirements.txt files
requirementsFiles ? [], requirementsFiles ? [],
# enforce source downloads for these package names
noBinary ? [],
# restrict to binary releases (.whl)
# this allows buildPlatform independent fetching
onlyBinary ? false,
# additional flags for `pip download`.
# for reference see: https://pip.pypa.io/en/stable/cli/pip_download/
pipFlags ? [], pipFlags ? [],
name ? null, name ? null,
nameSuffix ? "python-requirements", nameSuffix ? "python-requirements",
@ -50,47 +43,6 @@
# the times we have to update the output hash # the times we have to update the output hash
pipVersion ? "23.0.1", pipVersion ? "23.0.1",
}: let }: let
# throws an error if pipDownload is executed with unsafe arguments
validateArgs = result:
# specifying `--platform` for pip download is only allowed in combination with `--only-binary :all:`
# therefore, if onlyBinary is disabled, we must enforce targetPlatform == buildPlatform to ensure reproducibility
if ! onlyBinary && stdenv.system != stdenv.buildPlatform.system
then
throw ''
fetchPip cannot fetch sdist packages for ${stdenv.system} on a ${stdenv.buildPlatform.system}.
Either build on a ${stdenv.system} or set `onlyBinary = true`.
''
else result;
# map nixos system strings to python platforms
sysToPlatforms = {
"x86_64-linux" = [
"manylinux1_x86_64"
"manylinux2010_x86_64"
"manylinux2014_x86_64"
"linux_x86_64"
];
"x86_64-darwin" =
lib.forEach (lib.range 0 15)
(minor: "macosx_10_${builtins.toString minor}_x86_64");
"aarch64-linux" = [
"manylinux1_aarch64"
"manylinux2010_aarch64"
"manylinux2014_aarch64"
"linux_aarch64"
];
};
platforms =
if sysToPlatforms ? "${stdenv.system}"
then sysToPlatforms."${stdenv.system}"
else throw errorNoBinaryFetchingForTarget;
errorNoBinaryFetchingForTarget = ''
'onlyBinary' fetching is currently not supported for target ${stdenv.system}.
You could set 'onlyBinary = false' and execute the build on a ${stdenv.system}.
'';
# We use nixpkgs python3 to run mitmproxy, see function parameters # We use nixpkgs python3 to run mitmproxy, see function parameters
pythonWithMitmproxy = pythonWithMitmproxy =
python3.withPackages python3.withPackages
@ -116,8 +68,6 @@
# All variables that might influence the output # All variables that might influence the output
${finalAttrs.pypiSnapshotDate} ${finalAttrs.pypiSnapshotDate}
${toString finalAttrs.noBinary}
${finalAttrs.onlyBinaryFlags}
${finalAttrs.pipVersion} ${finalAttrs.pipVersion}
${finalAttrs.pipFlags} ${finalAttrs.pipFlags}
@ -180,7 +130,6 @@
# add some variables to the derivation to integrate them into finalAttrs # add some variables to the derivation to integrate them into finalAttrs
inherit inherit
noBinary
pipVersion pipVersion
requirementsFiles requirementsFiles
requirementsList requirementsList
@ -188,10 +137,6 @@
# prepare flags for `pip download` # prepare flags for `pip download`
pipFlags = lib.concatStringsSep " " pipFlags; pipFlags = lib.concatStringsSep " " pipFlags;
onlyBinaryFlags = lib.optionalString onlyBinary "--only-binary :all: ${
lib.concatStringsSep " " (lib.forEach platforms (pf: "--platform ${pf}"))
}";
# - Execute `pip download` through the filtering proxy. # - Execute `pip download` through the filtering proxy.
# - optionally add a file to the FOD containing metadata of the packages involved # - optionally add a file to the FOD containing metadata of the packages involved
buildPhase = '' buildPhase = ''
@ -199,4 +144,4 @@
''; '';
}); });
in in
validateArgs pipDownload pipDownload

View File

@ -24,11 +24,8 @@ PYTHON_WITH_MITM_PROXY = os.getenv("pythonWithMitmproxy")
FILTER_PYPI_RESPONSE_SCRIPTS = os.getenv("filterPypiResponsesScript") FILTER_PYPI_RESPONSE_SCRIPTS = os.getenv("filterPypiResponsesScript")
PIP_VERSION = os.getenv("pipVersion") PIP_VERSION = os.getenv("pipVersion")
PIP_FLAGS = os.getenv("pipFlags") PIP_FLAGS = os.getenv("pipFlags")
NO_BINARY = os.getenv("noBinary")
ONLY_BINARY_FLAGS = os.getenv("onlyBinaryFlags")
REQUIREMENTS_LIST = os.getenv("requirementsList") REQUIREMENTS_LIST = os.getenv("requirementsList")
REQUIREMENTS_FILES = os.getenv("requirementsFiles") REQUIREMENTS_FILES = os.getenv("requirementsFiles")
WRITE_METADATA = os.getenv("writeMetaData")
def get_max_date(): def get_max_date():
@ -127,7 +124,6 @@ if __name__ == "__main__":
flags = [ flags = [
PIP_FLAGS, PIP_FLAGS,
ONLY_BINARY_FLAGS,
"--proxy", "--proxy",
f"https://localhost:{proxy_port}", f"https://localhost:{proxy_port}",
"--progress-bar", "--progress-bar",
@ -137,9 +133,6 @@ if __name__ == "__main__":
"--report", "--report",
str(OUT / "report.json"), str(OUT / "report.json"),
] ]
if NO_BINARY:
flags += ["--no-binary " + " --no-binary ".join(NO_BINARY.split())]
for req in REQUIREMENTS_LIST.split(" "): for req in REQUIREMENTS_LIST.split(" "):
if req: if req:
flags.append(req) flags.append(req)