Merge pull request #513 from nix-community/no-dontprefersetuppy

Remove dontPreferSetupPy & don't remove pyproject.toml
This commit is contained in:
adisbladis 2022-01-18 22:26:55 +12:00 committed by GitHub
commit 1c4a1a2232
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 189 additions and 245 deletions

View file

@ -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 .

View file

@ -5,10 +5,10 @@
"homepage": "https://github.com/NixOS/nixpkgs",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "eac07edbd20ed4908b98790ba299250b5527ecdf",
"sha256": "11r1b0kpyls2w4n7s9xkj2kim715vrk6aj7ackia4f8s9imachk6",
"rev": "5aaed40d22f0d9376330b6fa413223435ad6fee5",
"sha256": "0bs8sr92lzz7mdrlv143draq3j7l42dj69w3px1x31qcr3n5pgcv",
"type": "tarball",
"url": "https://github.com/NixOS/nixpkgs/archive/eac07edbd20ed4908b98790ba299250b5527ecdf.tar.gz",
"url": "https://github.com/NixOS/nixpkgs/archive/5aaed40d22f0d9376330b6fa413223435ad6fee5.tar.gz",
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
}
}

View file

@ -5,6 +5,45 @@
self: super:
let
addFlit =
{ drv
, cond ? true
, flitDrv ? self.flit-core
}: (
# Flit isn't available on Python2
if (cond && self.isPy3k) then
drv.overridePythonAttrs
(
old: {
nativeBuildInputs = (old.nativeBuildInputs or [ ]) ++ [ flitDrv ];
}
) else drv
);
addPoetry =
{ drv
, cond ? true
, poetryDrv ? self.poetry-core
}: (
if cond then
drv.overridePythonAttrs
(
old: {
buildInputs = (old.buildInputs or [ ]) ++ [ poetryDrv ];
}
) else drv
);
addPbr = drv: drv.overridePythonAttrs (
old: {
buildInputs = (old.buildInputs or [ ]) ++ [ self.pbr ];
}
);
in
{
automat = super.automat.overridePythonAttrs (
old: rec {
@ -50,12 +89,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 ];
@ -83,28 +116,12 @@ self: super:
}
);
argon2-cffi = super.argon2-cffi.overridePythonAttrs (
old: {
buildInputs = (old.buildInputs or [ ]) ++
lib.optional (lib.versionAtLeast old.version "21.2.0") [ self.flit-core ];
}
);
argon2-cffi = addFlit {
drv = super.argon2-cffi;
cond = lib.versionAtLeast super.argon2-cffi.version "21.2.0";
};
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 = addFlit { drv = super.backcall; };
bcrypt = super.bcrypt.overridePythonAttrs (
old: {
@ -118,12 +135,6 @@ self: super:
}
);
black = super.black.overridePythonAttrs (
old: {
dontPreferSetupPy = true;
}
);
borgbackup = super.borgbackup.overridePythonAttrs (
old: {
BORG_OPENSSL_PREFIX = pkgs.openssl.dev;
@ -149,7 +160,10 @@ self: super:
propagatedBuildInputs = (old.propagatedBuildInputs or [ ]) ++ [ self.setuptools ];
});
cssselect2 = super.cssselect2.overridePythonAttrs (
cssselect2 = (addFlit {
drv = super.cssselect2;
flitDrv = self.flit;
}).overridePythonAttrs (
old: {
buildInputs = (old.buildInputs or [ ]) ++ [ self.pytest-runner ];
}
@ -174,11 +188,9 @@ self: super:
}
);
cheroot = super.cheroot.overridePythonAttrs (
old: {
dontPreferSetupPy = true;
}
);
cleo = addPoetry { drv = super.cleo; };
clikit = addPoetry { drv = super.clikit; };
cloudflare = super.cloudflare.overridePythonAttrs (
old: {
@ -199,13 +211,11 @@ self: super:
buildInputs = (old.buildInputs or [ ]) ++ [
self.toml
];
postPatch = ''
substituteInPlace setup.py --replace 'setuptools.setup()' 'setuptools.setup(version="${old.version}")'
'';
}
);
crashtest = addPoetry { drv = super.crashtest; };
cryptography = super.cryptography.overridePythonAttrs (
old: {
nativeBuildInputs = (old.nativeBuildInputs or [ ])
@ -419,18 +429,16 @@ 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=[]'
'';
}
);
fastapi = super.fastapi.overridePythonAttrs (
old: {
fastapi = addFlit {
drv = super.fastapi;
# Note: requires full flit, not just flit-core
nativeBuildInputs = (old.nativeBuildInputs or [ ]) ++ [ self.flit ];
}
);
flitDrv = self.flit;
};
fastecdsa = super.fastecdsa.overridePythonAttrs (old: {
buildInputs = old.buildInputs ++ [ pkgs.gmp.dev ];
@ -442,12 +450,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 ];
@ -477,6 +479,10 @@ self: super:
}
);
graphql-core = addPoetry { drv = super.graphql-core; };
graphql-relay = addPoetry { drv = super.graphql-relay; };
gitpython = super.gitpython.overridePythonAttrs (
old: {
buildInputs = (old.buildInputs or [ ]) ++ [ self.typing-extensions ];
@ -563,10 +569,14 @@ self: super:
}
);
html5lib = addFlit { drv = super.html5lib; };
httplib2 = super.httplib2.overridePythonAttrs (old: {
propagatedBuildInputs = (old.propagatedBuildInputs or [ ]) ++ [ self.pyparsing ];
});
hypothesis-graphql = addPoetry { drv = super.hypothesis-graphql; poetryDrv = self.poetry; };
icecream = super.icecream.overridePythonAttrs (old: {
# # ERROR: Could not find a version that satisfies the requirement executing>=0.3.1 (from icecream) (from versions: none)
postPatch = ''
@ -635,20 +645,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;
}
);
@ -670,11 +666,11 @@ self: super:
buildInputs = (old.buildInputs or [ ]) ++ [
self.toml
];
# disable the removal of pyproject.toml, required because of setuptools_scm
dontPreferSetupPy = true;
}
);
jeepney = addFlit { drv = super.jeepney; };
jira = super.jira.overridePythonAttrs (
old: {
inherit (pkgs.python3Packages.jira) patches;
@ -706,12 +702,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 ];
@ -741,9 +731,6 @@ self: super:
buildInputs = (old.buildInputs or [ ]) ++ [
self.toml
];
postPatch = ''
substituteInPlace setup.py --replace 'setuptools.setup()' 'setuptools.setup(version="${old.version}")'
'';
}
);
@ -768,10 +755,6 @@ self: super:
propagatedBuildInputs = [ pkgs.libvirt ];
});
licensecheck = super.licensecheck.overridePythonAttrs (old: {
dontPreferSetupPy = true;
});
llvmlite = super.llvmlite.overridePythonAttrs (
old:
let
@ -815,11 +798,7 @@ self: super:
}
);
lockfile = super.lockfile.overridePythonAttrs (
old: {
propagatedBuildInputs = (old.propagatedBuildInputs or [ ]) ++ [ self.pbr ];
}
);
lockfile = addPbr super.lockfile;
lxml = super.lxml.overridePythonAttrs (
old: {
@ -933,9 +912,7 @@ self: super:
buildInputs = (old.buildInputs or [ ]) ++ [ self.setuptools-scm-git-archive ];
});
mongomock = super.mongomock.overridePythonAttrs (oa: {
buildInputs = oa.buildInputs ++ [ self.pbr ];
});
mongomock = addPbr super.mongomock;
mpi4py = super.mpi4py.overridePythonAttrs (
old:
@ -968,11 +945,7 @@ self: super:
}
);
munch = super.munch.overridePythonAttrs (
old: {
buildInputs = (old.buildInputs or [ ]) ++ [ self.pbr ];
}
);
munch = addPbr super.munch;
mypy = super.mypy.overridePythonAttrs (
old: {
@ -1087,6 +1060,8 @@ self: super:
'';
});
pastel = addPoetry { drv = super.pastel; };
paramiko = super.paramiko.overridePythonAttrs (old: {
doCheck = false; # requires networking
});
@ -1124,12 +1099,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 = ''
@ -1152,8 +1121,6 @@ self: super:
buildInputs = (old.buildInputs or [ ]) ++ [
self.toml
];
# disable the removal of pyproject.toml, required because of setuptools_scm
dontPreferSetupPy = true;
}
);
@ -1362,11 +1329,7 @@ self: super:
}
);
pyproject-flake8 = super.pyproject-flake8.overridePythonAttrs (
old: {
buildInputs = (old.buildInputs or [ ]) ++ [ self.flit-core ];
}
);
pyproject-flake8 = addFlit { drv = super.pyproject-flake8; };
pyrfr = super.pyrfr.overridePythonAttrs (old: {
nativeBuildInputs = (old.nativeBuildInputs or [ ]) ++ [ pkgs.swig ];
@ -1400,6 +1363,8 @@ self: super:
}
);
pytzdata = addPoetry { drv = super.pytzdata; poetryDrv = self.poetry; };
pyqt5 =
let
drv = super.pyqt5;
@ -1531,6 +1496,8 @@ self: super:
}
);
pytest-httpserver = addPoetry { drv = super.pytest-httpserver; };
pytest-randomly = super.pytest-randomly.overrideAttrs (old: {
propagatedBuildInputs = (old.propagatedBuildInputs or [ ]) ++ [
self.importlib-metadata
@ -1672,21 +1639,11 @@ self: super:
}
);
requests-mock = super.requests-mock.overridePythonAttrs (
old: {
propagatedBuildInputs = (old.propagatedBuildInputs or [ ]) ++ [ super.pbr ];
}
);
requests-mock = addPbr super.requests-mock;
requests-unixsocket = super.requests-unixsocket.overridePythonAttrs (
old: {
nativeBuildInputs = (old.nativeBuildInputs or [ ]) ++ [ self.pbr ];
}
);
requests-unixsocket = addPbr super.requests-unixsocket;
requestsexceptions = super.requestsexceptions.overridePythonAttrs (old: {
nativeBuildInputs = old.nativeBuildInputs ++ [ self.pbr ];
});
requestsexceptions = addPbr super.requestsexceptions;
rlp = super.rlp.overridePythonAttrs {
preConfigure = ''
@ -1694,8 +1651,15 @@ self: super:
'';
};
rsa = addPoetry { drv = super.rsa; };
rmfuse = super.rmfuse.overridePythonAttrs (old: {
rich = addPoetry { drv = super.rich; };
rmcl = addPoetry { drv = super.rmcl; };
rmrl = addPoetry { drv = super.rmrl; };
rmfuse = (addPoetry { drv = super.rmfuse; }).overridePythonAttrs (old: {
propagatedBuildInputs = (old.propagatedBuildInputs or [ ]) ++ [ self.setuptools ];
});
@ -1816,8 +1780,6 @@ self: super:
buildInputs = (old.buildInputs or [ ]) ++ [
self.toml
];
# disable the removal of pyproject.toml, required because of setuptools_scm
dontPreferSetupPy = true;
}
);
@ -1859,7 +1821,11 @@ self: super:
}
);
tinycss2 = super.tinycss2.overridePythonAttrs (
tinycss2 = (addFlit {
drv = super.tinycss2;
# Note: requires full flit, not just flit-core
flitDrv = self.flit;
}).overridePythonAttrs (
old: {
buildInputs = (old.buildInputs or [ ]) ++ [ self.pytest-runner ];
}
@ -1929,26 +1895,21 @@ 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
];
});
typing-extensions =
let
# nix uses a dash, poetry uses an underscore
typing-extensions = (super.typing_extensions or super.typing-extensions).overridePythonAttrs (
old: {
buildInputs = (old.buildInputs or [ ]) ++
lib.optional (lib.versionAtLeast old.version "4.0.0") [ self.flit-core ];
}
);
old = super.typing_extensions or super.typing-extensions;
in
addFlit {
drv = old;
cond = lib.versionAtLeast old.version "4.0.0";
};
urwidtrees = super.urwidtrees.overridePythonAttrs (
old: {
@ -2038,21 +1999,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 (
old: {
propagatedBuildInputs = (old.propagatedBuildInputs or [ ]) ++ [
self.toml
@ -2066,20 +2013,18 @@ self: super:
}
);
hashids = super.hashids.overridePythonAttrs (
old: {
buildInputs = (old.buildInputs or [ ]) ++ [ self.flit-core ];
}
);
hashids = addFlit { drv = super.hashids; };
packaging = super.packaging.overridePythonAttrs (
old: {
buildInputs = (old.buildInputs or [ ]) ++
packaging =
let
old = super.packaging;
in
addFlit {
drv = old;
# From 20.5 until 20.7, packaging used flit for packaging (heh)
# See https://github.com/pypa/packaging/pull/352 and https://github.com/pypa/packaging/pull/367
lib.optional (lib.versionAtLeast old.version "20.5" && lib.versionOlder old.version "20.8") [ self.flit-core ];
}
);
cond = lib.versionAtLeast old.version "20.5" && lib.versionOlder old.version "20.8";
};
psutil = super.psutil.overridePythonAttrs (
old: {
@ -2166,6 +2111,9 @@ self: super:
}
);
# NixOps >=2 dependency
nixos-modules-contrib = addPoetry { drv = super.nixos-modules-contrib; poetryDrv = self.poetry; };
wxpython = super.wxpython.overridePythonAttrs (old:
let
localPython = self.python.withPackages (ps: with ps; [
@ -2226,13 +2174,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..
@ -2241,22 +2182,18 @@ self: super:
'';
});
ptyprocess = addFlit { drv = super.ptyprocess; };
pygraphviz = super.pygraphviz.overridePythonAttrs (old: {
nativeBuildInputs = (old.nativeBuildInputs or [ ]) ++ [ pkgs.pkg-config ];
buildInputs = (old.buildInputs or [ ]) ++ [ pkgs.graphviz ];
});
pyjsg = super.pyjsg.overridePythonAttrs (old: {
buildInputs = (old.buildInputs or [ ]) ++ [ self.pbr ];
});
pyjsg = addPbr super.pyjsg;
pyshex = super.pyshex.overridePythonAttrs (old: {
buildInputs = (old.buildInputs or [ ]) ++ [ self.pbr ];
});
pyshex = addPbr super.pyshex;
pyshexc = super.pyshexc.overridePythonAttrs (old: {
buildInputs = (old.buildInputs or [ ]) ++ [ self.pbr ];
});
pyshexc = addPbr super.pyshexc;
pysqlite = super.pysqlite.overridePythonAttrs (old: {
buildInputs = (old.buildInputs or [ ]) ++ [ pkgs.sqlite ];
@ -2266,17 +2203,13 @@ self: super:
buildInputs = (old.buildInputs or [ ]) ++ [ self.setuptools-scm-git-archive ];
});
shexjsg = super.shexjsg.overridePythonAttrs (old: {
buildInputs = (old.buildInputs or [ ]) ++ [ self.pbr ];
});
shexjsg = addPbr super.shexjsg;
sparqlslurper = super.sparqlslurper.overridePythonAttrs (old: {
buildInputs = (old.buildInputs or [ ]) ++ [ self.pbr ];
});
sparqlslurper = addPbr super.sparqlslurper;
tomli = super.tomli.overridePythonAttrs (old: {
nativeBuildInputs = (old.nativeBuildInputs or [ ]) ++ [ self.flit-core ];
});
tomlkit = addPoetry { drv = super.tomlkit; };
tomli = addFlit { drv = super.tomli; };
uwsgi = super.uwsgi.overridePythonAttrs (old: {
buildInputs = (old.buildInputs or [ ]) ++ [ pkgs.ncurses ];
@ -2292,4 +2225,10 @@ self: super:
wtforms = super.wtforms.overridePythonAttrs (old: {
buildInputs = (old.buildInputs or [ ]) ++ [ self.Babel ];
});
}
xdg = addPoetry { drv = super.xdg; };
} // (
# NixOps
(lib.mapAttrs (_: v: addPoetry { drv = v; poetryDrv = self.poetry; }) (lib.filterAttrs (n: _: lib.strings.hasPrefix "nixops" n) super))
)

View file

@ -65,6 +65,9 @@ builtins.removeAttrs
aiopath = callTest ./aiopath { };
fetched-projectdir = callTest ./fetched-projectdir { };
# Inherit test cases from nixpkgs
inherit (pkgs) nixops nixopsUnstable rmfuse;
# Test building poetry
inherit poetry;

View file

@ -6,4 +6,9 @@ poetry2nix.mkPoetryApplication {
poetrylock = ./poetry.lock;
src = lib.cleanSource ./.;
pwd = ./.;
overrides = poetry2nix.overrides.withDefaults (self: super: {
trivial = super.trivial.overridePythonAttrs (old: {
buildInputs = old.buildInputs or [ ] ++ [ self.poetry ];
});
});
}

View file

@ -6,4 +6,9 @@ poetry2nix.mkPoetryApplication {
poetrylock = ./poetry.lock;
src = lib.cleanSource ./.;
pwd = ./.;
overrides = poetry2nix.overrides.withDefaults (self: super: {
trivial = super.trivial.overridePythonAttrs (old: {
buildInputs = old.buildInputs or [ ] ++ [ self.poetry ];
});
});
}