@@ -8,13 +8,14 @@ let
88 { self
99 , drv
1010 , attr
11+ , extraAttrs ? [ ]
1112 }:
1213 let
1314 buildSystem = if attr == "cython" then self.python.pythonForBuild.pkgs.cython else self.${attr};
1415 in
1516 (
1617 # Flit only works on Python3
17− if (attr == "flit-core" || attr == "flit") && !self.isPy3k then drv
18+ if (attr == "flit-core" || attr == "flit" || attr == "hatchling") && !self.isPy3k then drv
1819 else
1920 drv.overridePythonAttrs (
2021 old:
@@ -23,7 +24,7 @@ let
2324 { }
2425 else
2526 {
26− nativeBuildInputs = (old.nativeBuildInputs or [ ]) ++ [ self.${attr} ];
27+ nativeBuildInputs = (old.nativeBuildInputs or [ ]) ++ [ self.${attr} ] ++ map (a: self.${a}) extraAttrs;
2728 }
2829 )
2930 );
@@ -55,6 +56,16 @@ lib.composeManyExtensions [
5556 systems)
5657 buildSystems)
5758
59+ # Build systems with conditionals
60+ (self: super: {
61+
62+ platformdirs =
63+ if lib.versionAtLeast super.platformdirs.version "2.5.2"
64+ then addBuildSystem { inherit self; drv = super.platformdirs; attr = "hatchling"; extraAttrs = [ "hatch-vcs" ]; }
65+ else super.platformdirs;
66+
67+ })
68+
5869 # Build fixes
5970 (self: super:
6071 let
@@ -437,6 +448,17 @@ lib.composeManyExtensions [
437448 }
438449 );
439450
451+ # Setuptools >= 60 broke build_py_2to3
452+ docutils =
453+ if lib.versionOlder super.docutils.version "0.16" && lib.versionAtLeast super.setuptools.version "60" then
454+ (
455+ super.docutils.overridePythonAttrs (
456+ old: {
457+ SETUPTOOLS_USE_DISTUTILS = "stdlib";
458+ }
459+ )
460+ ) else super.docutils;
461+
440462 # Environment markers are not always included (depending on how a dep was defined)
441463 enum34 = if self.pythonAtLeast "3.4" then null else super.enum34;
442464
@@ -844,6 +866,17 @@ lib.composeManyExtensions [
844866 }
845867 );
846868
869+ lsassy =
870+ if super.lsassy.version == "3.1.1" then
871+ super.lsassy.overridePythonAttrs
872+ (old: {
873+ # pyproject.toml contains a constraint `rich = "^10.6.0"` which is not replicated in setup.py
874+ # hence pypi misses it and poetry pins rich to 11.0.0
875+ preConfigure = (old.preConfigure or "") + ''
876+ rm pyproject.toml
877+ '';
878+ }) else super.lsassy;
879+
847880 lxml = super.lxml.overridePythonAttrs (
848881 old: {
849882 nativeBuildInputs = with pkgs.buildPackages; (old.nativeBuildInputs or [ ]) ++ [ pkg-config libxml2.dev libxslt.dev ] ++ lib.optionals stdenv.isDarwin [ xcodebuild ];
@@ -1143,6 +1176,26 @@ lib.composeManyExtensions [
11431176 }
11441177 );
11451178
1179+ orjson =
1180+ let
1181+ getCargoHash = version: {
1182+ "3.6.7" = "sha256-sz2k9podPB6QSptkyOu7+BoVTrKhefizRtYU+MICPt4=";
1183+ "3.6.8" = "sha256-vpfceVtYkU09xszNIihY1xbqGWieqDquxwsAmDH8jd4=";
1184+ }.${version} or null;
1185+ in
1186+ super.orjson.overridePythonAttrs (old: {
1187+ cargoDeps = pkgs.rustPlatform.fetchCargoTarball {
1188+ inherit (old) src;
1189+ name = "${old.pname}-${old.version}";
1190+ hash = getCargoHash old.version;
1191+ };
1192+ nativeBuildInputs = (old.nativeBuildInputs or [ ]) ++ [
1193+ pkgs.rustPlatform.cargoSetupHook
1194+ pkgs.rustPlatform.maturinBuildHook
1195+ ];
1196+ buildInputs = (old.buildInputs or [ ]) ++ lib.optional pkgs.stdenv.isDarwin pkgs.libiconv;
1197+ });
1198+
11461199 osqp = super.osqp.overridePythonAttrs (
11471200 old: {
11481201 nativeBuildInputs = (old.nativeBuildInputs or [ ]) ++ [ pkgs.cmake ];
@@ -1150,6 +1203,29 @@ lib.composeManyExtensions [
11501203 }
11511204 );
11521205
1206+
1207+ pandas = super.pandas.overridePythonAttrs (old: {
1208+
1209+ buildInputs = old.buildInputs or [ ] ++ lib.optional stdenv.isDarwin pkgs.libcxx;
1210+
1211+ # Doesn't work with -Werror,-Wunused-command-line-argument
1212+ # https://github.com/NixOS/nixpkgs/issues/39687
1213+ hardeningDisable = lib.optional stdenv.cc.isClang "strictoverflow";
1214+
1215+ # For OSX, we need to add a dependency on libcxx, which provides
1216+ # `complex.h` and other libraries that pandas depends on to build.
1217+ postPatch = lib.optionalString stdenv.isDarwin ''
1218+ cpp_sdk="${lib.getDev pkgs.libcxx}/include/c++/v1";
1219+ echo "Adding $cpp_sdk to the setup.py common_include variable"
1220+ substituteInPlace setup.py \
1221+ --replace "['pandas/src/klib', 'pandas/src']" \
1222+ "['pandas/src/klib', 'pandas/src', '$cpp_sdk']"
1223+ '';
1224+
1225+
1226+ enableParallelBuilding = true;
1227+ });
1228+
11531229 pantalaimon = super.pantalaimon.overridePythonAttrs (old: {
11541230 nativeBuildInputs = old.nativeBuildInputs or [ ] ++ [ pkgs.installShellFiles ];
11551231 postInstall = old.postInstall or "" + ''
@@ -1196,8 +1272,12 @@ lib.composeManyExtensions [
11961272
11971273 pillow = super.pillow.overridePythonAttrs (
11981274 old: {
1199− nativeBuildInputs = [ pkg-config self.pytest-runner ] ++ (old.nativeBuildInputs or [ ]);
1200− buildInputs = with pkgs; [ freetype libjpeg zlib libtiff libwebp tcl lcms2 ] ++ (old.buildInputs or [ ]);
1275+ nativeBuildInputs = (old.nativeBuildInputs or [ ])
1276+ ++ [ pkg-config self.pytest-runner ];
1277+ buildInputs = with pkgs; (old.buildInputs or [ ])
1278+ ++ [ freetype libjpeg zlib libtiff libwebp tcl lcms2 ]
1279+ ++ lib.optionals (lib.versionAtLeast old.version "7.1.0") [ xorg.libxcb ]
1280+ ++ lib.optionals (self.isPyPy) [ tk xorg.libX11 ];
12011281 }
12021282 );
12031283
@@ -1246,6 +1326,14 @@ lib.composeManyExtensions [
12461326 }
12471327 );
12481328
1329+ psycopg2cffi = super.psycopg2cffi.overridePythonAttrs (
1330+ old: {
1331+ buildInputs = (old.buildInputs or [ ])
1332+ ++ lib.optional stdenv.isDarwin pkgs.openssl;
1333+ nativeBuildInputs = (old.nativeBuildInputs or [ ]) ++ [ pkgs.postgresql ];
1334+ }
1335+ );
1336+
12491337 py-solc-x = super.py-solc-x.overridePythonAttrs (
12501338 old: {
12511339 preConfigure = ''
@@ -1860,6 +1948,12 @@ lib.composeManyExtensions [
18601948
18611949 });
18621950
1951+ soundfile = super.soundfile.overridePythonAttrs (old: {
1952+ postPatch = ''
1953+ substituteInPlace soundfile.py --replace "_find_library('sndfile')" "'${pkgs.libsndfile.out}/lib/libsndfile${stdenv.hostPlatform.extensions.sharedLibrary}'"
1954+ '';
1955+ });
1956+
18631957 systemd-python = super.systemd-python.overridePythonAttrs (old: {
18641958 buildInputs = old.buildInputs ++ [ pkgs.systemd ];
18651959 nativeBuildInputs = old.nativeBuildInputs ++ [ pkgs.pkg-config ];