Skip to content

Commit

Permalink
Remove dontPreferSetupPy & don't remove pyproject.toml ever
Browse files Browse the repository at this point in the history
It seems like this bandaid to avoid some build-system related overrides causes more problems than it fixes.
Let's just deal with reality up-front and hope that python-poetry/poetry#2789 will be fixed at some point.
  • Loading branch information
adisbladis committed Jan 18, 2022
1 parent 23be9b3 commit 8be11cb
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 118 deletions.
8 changes: 0 additions & 8 deletions hooks/pip-build-hook.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,6 @@ pipBuildPhase() {
echo "Executing pipBuildPhase"
runHook preBuild

# Prefer using setup.py to avoid build-system dependencies if we have a setup.py
if [ -z "${dontPreferSetupPy-}" ]; then
if test -e setup.py && test -e pyproject.toml; then
echo "Removing pyproject.toml..."
rm -f pyproject.toml
fi
fi

mkdir -p dist
echo "Creating a wheel..."
@pythonInterpreter@ -m pip wheel --verbose --no-index --no-deps --no-clean --no-build-isolation --wheel-dir dist .
Expand Down
148 changes: 38 additions & 110 deletions overrides.nix
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,6 @@ self: super:
}
);

anyio = super.anyio.overridePythonAttrs (old: {
postPatch = ''
substituteInPlace setup.py --replace 'setup()' 'setup(version="${old.version}")'
'';
});

argcomplete = super.argcomplete.overridePythonAttrs (
old: rec {
buildInputs = (old.buildInputs or [ ]) ++ [ self.importlib-metadata ];
Expand Down Expand Up @@ -90,20 +84,8 @@ self: super:
}
);

backports-entry-points-selectable = super.backports-entry-points-selectable.overridePythonAttrs (old: {
postPatch = ''
substituteInPlace setup.py --replace \
'setuptools.setup()' \
'setuptools.setup(version="${old.version}")'
'';
});

backports-functools-lru-cache = super.backports-functools-lru-cache.overridePythonAttrs (old: {
postPatch = ''
substituteInPlace setup.py --replace \
'setuptools.setup()' \
'setuptools.setup(version="${old.version}")'
'';
backcall = super.backcall.overridePythonAttrs (old: {
buildInputs = old.buildInputs or [ ] ++ [ self.flit-core ];
});

bcrypt = super.bcrypt.overridePythonAttrs (
Expand All @@ -118,12 +100,6 @@ self: super:
}
);

black = super.black.overridePythonAttrs (
old: {
dontPreferSetupPy = true;
}
);

borgbackup = super.borgbackup.overridePythonAttrs (
old: {
BORG_OPENSSL_PREFIX = pkgs.openssl.dev;
Expand Down Expand Up @@ -174,11 +150,13 @@ self: super:
}
);

cheroot = super.cheroot.overridePythonAttrs (
old: {
dontPreferSetupPy = true;
}
);
cleo = super.cleo.overridePythonAttrs (old: {
buildInputs = old.buildInputs or [ ] ++ [ self.poetry-core ];
});

clikit = super.clikit.overridePythonAttrs (old: {
buildInputs = old.buildInputs or [ ] ++ [ self.poetry-core ];
});

cloudflare = super.cloudflare.overridePythonAttrs (
old: {
Expand All @@ -199,10 +177,14 @@ self: super:
buildInputs = (old.buildInputs or [ ]) ++ [
self.toml
];
}
);

postPatch = ''
substituteInPlace setup.py --replace 'setuptools.setup()' 'setuptools.setup(version="${old.version}")'
'';
crashtest = super.crashtest.overridePythonAttrs (
old: {
buildInputs = (old.buildInputs or [ ]) ++ [
self.poetry-core
];
}
);

Expand Down Expand Up @@ -419,8 +401,7 @@ self: super:
old: {
postPatch = ''
substituteInPlace setup.py \
--replace 'setup_requires="setupmeta"' 'setup_requires=[]' \
--replace 'versioning="devcommit"' 'version="${old.version}"'
--replace 'setup_requires="setupmeta"' 'setup_requires=[]'
'';
}
);
Expand All @@ -442,12 +423,6 @@ self: super:
}
);

filelock = super.filelock.overridePythonAttrs (old: {
postPatch = ''
substituteInPlace setup.py --replace 'setup()' 'setup(version="${old.version}")'
'';
});

fiona = super.fiona.overridePythonAttrs (
old: {
buildInputs = (old.buildInputs or [ ]) ++ [ pkgs.gdal_2 ];
Expand Down Expand Up @@ -563,6 +538,10 @@ self: super:
}
);

html5lib = super.html5lib.overridePythonAttrs (old: {
buildInputs = old.buildInputs or [ ] ++ [ self.flit-core ];
});

httplib2 = super.httplib2.overridePythonAttrs (old: {
propagatedBuildInputs = (old.propagatedBuildInputs or [ ]) ++ [ self.pyparsing ];
});
Expand Down Expand Up @@ -635,20 +614,6 @@ self: super:
importlib-metadata = super.importlib-metadata.overridePythonAttrs (
old: {
propagatedBuildInputs = (old.propagatedBuildInputs or [ ]) ++ lib.optional self.python.isPy2 self.pathlib2;

# disable the removal of pyproject.toml, required because of setuptools_scm
dontPreferSetupPy = true;

postPatch = old.postPatch or "" + (lib.optionalString ((old.format or "") != "wheel") ''
substituteInPlace setup.py --replace 'setuptools.setup()' 'setuptools.setup(version="${old.version}")'
'');
}
);

importlib-resources = super.importlib-resources.overridePythonAttrs (
old: {
# disable the removal of pyproject.toml, required because of setuptools_scm
dontPreferSetupPy = true;
}
);

Expand All @@ -670,11 +635,13 @@ self: super:
buildInputs = (old.buildInputs or [ ]) ++ [
self.toml
];
# disable the removal of pyproject.toml, required because of setuptools_scm
dontPreferSetupPy = true;
}
);

jeepney = super.jeepney.overridePythonAttrs (old: {
buildInputs = old.buildInputs or [ ] ++ [ self.flit-core ];
});

jira = super.jira.overridePythonAttrs (
old: {
inherit (pkgs.python3Packages.jira) patches;
Expand Down Expand Up @@ -706,12 +673,6 @@ self: super:
}
);

jsonpickle = super.jsonpickle.overridePythonAttrs (
old: {
dontPreferSetupPy = true;
}
);

jsonslicer = super.jsonslicer.overridePythonAttrs (old: {
nativeBuildInputs = (old.nativeBuildInputs or [ ]) ++ [ pkgs.pkgconfig ];
buildInputs = (old.buildInputs or [ ]) ++ [ pkgs.yajl ];
Expand Down Expand Up @@ -741,9 +702,6 @@ self: super:
buildInputs = (old.buildInputs or [ ]) ++ [
self.toml
];
postPatch = ''
substituteInPlace setup.py --replace 'setuptools.setup()' 'setuptools.setup(version="${old.version}")'
'';
}
);

Expand All @@ -768,10 +726,6 @@ self: super:
propagatedBuildInputs = [ pkgs.libvirt ];
});

licensecheck = super.licensecheck.overridePythonAttrs (old: {
dontPreferSetupPy = true;
});

llvmlite = super.llvmlite.overridePythonAttrs (
old:
let
Expand Down Expand Up @@ -1087,6 +1041,10 @@ self: super:
'';
});

pastel = super.pastel.overridePythonAttrs (old: {
buildInputs = old.buildInputs or [ ] ++ [ self.poetry-core ];
});

paramiko = super.paramiko.overridePythonAttrs (old: {
doCheck = false; # requires networking
});
Expand Down Expand Up @@ -1124,12 +1082,6 @@ self: super:
}
);

platformdirs = super.platformdirs.overridePythonAttrs (old: {
postPatch = ''
substituteInPlace setup.py --replace 'setup()' 'setup(version="${old.version}")'
'';
});

poetry-core = super.poetry-core.overridePythonAttrs (old: {
# "Vendor" dependencies (for build-system support)
postPatch = ''
Expand All @@ -1152,8 +1104,6 @@ self: super:
buildInputs = (old.buildInputs or [ ]) ++ [
self.toml
];
# disable the removal of pyproject.toml, required because of setuptools_scm
dontPreferSetupPy = true;
}
);

Expand Down Expand Up @@ -1816,8 +1766,6 @@ self: super:
buildInputs = (old.buildInputs or [ ]) ++ [
self.toml
];
# disable the removal of pyproject.toml, required because of setuptools_scm
dontPreferSetupPy = true;
}
);

Expand Down Expand Up @@ -1929,13 +1877,6 @@ self: super:
}))
{ };

typeguard = super.typeguard.overridePythonAttrs (old: {
postPatch = ''
substituteInPlace setup.py \
--replace 'setup()' 'setup(version="${old.version}")'
'';
});

typed_ast = super.typed-ast.overridePythonAttrs (old: {
nativeBuildInputs = (old.nativeBuildInputs or [ ]) ++ [
self.pytest-runner
Expand Down Expand Up @@ -2038,21 +1979,7 @@ self: super:
if isWheel then wheelPackage else sourcePackage;

zipp = if super.zipp == null then null else
(
if lib.versionAtLeast super.zipp.version "2.0.0" then
(
super.zipp.overridePythonAttrs (
old:
if (old.format or "pyproject") != "wheel" then {
prePatch = ''
substituteInPlace setup.py --replace \
'setuptools.setup()' \
'setuptools.setup(version="${super.zipp.version}")'
'';
} else old
)
) else super.zipp
).overridePythonAttrs (
super.zipp.overridePythonAttrs (
old: {
propagatedBuildInputs = (old.propagatedBuildInputs or [ ]) ++ [
self.toml
Expand Down Expand Up @@ -2226,13 +2153,6 @@ self: super:
}
);

lazy-object-proxy = super.lazy-object-proxy.overridePythonAttrs (
old: {
# disable the removal of pyproject.toml, required because of setuptools_scm
dontPreferSetupPy = true;
}
);

pendulum = super.pendulum.overridePythonAttrs (old: {
buildInputs = (old.buildInputs or [ ]) ++ [ self.poetry ];
# Technically incorrect, but fixes the build error..
Expand All @@ -2241,6 +2161,10 @@ self: super:
'';
});

ptyprocess = super.ptyprocess.overridePythonAttrs (old: {
buildInputs = old.buildInputs or [ ] ++ [ self.flit-core ];
});

pygraphviz = super.pygraphviz.overridePythonAttrs (old: {
nativeBuildInputs = (old.nativeBuildInputs or [ ]) ++ [ pkgs.pkg-config ];
buildInputs = (old.buildInputs or [ ]) ++ [ pkgs.graphviz ];
Expand Down Expand Up @@ -2274,6 +2198,10 @@ self: super:
buildInputs = (old.buildInputs or [ ]) ++ [ self.pbr ];
});

tomlkit = super.tomlkit.overridePythonAttrs (old: {
buildInputs = old.buildInputs or [ ] ++ [ self.poetry-core ];
});

tomli = super.tomli.overridePythonAttrs (old: {
nativeBuildInputs = (old.nativeBuildInputs or [ ]) ++ [ self.flit-core ];
});
Expand Down

0 comments on commit 8be11cb

Please sign in to comment.