Python packages are not building "ModuleNotFoundError: No module named 'setuptools'"

these are the errors popping up on nixos-rebuild switch --upgrade --keep-going
I absolutely have no idea what package is causing this issue,
is there a tool to sanely traceback this? or any recent reported bug on unstable channel related to python packages and setuptool fails
what should be my first step to diagnose this

ModuleNotFoundError: No module named 'setuptools'

error: builder for '/nix/store/4s93ccs152sgmrwmgr4wp7py1m73iirf-python3.10-toml-0.10.2.drv' failed with exit code 2
building '/nix/store/m2rc25xnv94arhvhc4gyasdzmf522a5s-system-shutdown.drv'...
building '/nix/store/71l9ibl1shyl3qdw76qfc6ai2k6yd5v4-systemd-boot-builder.py.drv'...
building '/nix/store/d00l1smzfy0mqvzllw5w5yw9fypaiwl9-systemsettings-5.25.5_fish-completions.drv'...

error: builder for '/nix/store/f88b6qmpk9mhahl49p606qc9shg768fy-python3.10-typing-extensions-3.10.0.2.drv' failed with exit code 2
error: 2 dependencies of derivation '/nix/store/vngipha4lh31aw0d66bcgh59qx1mif11-python3.10-setuptools-scm-7.0.5.drv' failed to build
error: 1 dependencies of derivation '/nix/store/kag649a6i0fxcp78bfsdq8sj174h8l7v-python3.10-cachy-0.3.0.drv' failed to build
error: 1 dependencies of derivation '/nix/store/wigs2b91jjgqb5k4ziz6qh1mbfjcvp4b-python3.10-certifi-2021.10.8.drv' failed to build
error: 1 dependencies of derivation '/nix/store/p9717qawksq1xv6a0k8l8gq9j22azd2y-python3.10-chardet-4.0.0.drv' failed to build
error: 1 dependencies of derivation '/nix/store/11dkcjhbq2icvkzs002gjimfjgdlfb4k-python3.10-distlib-0.3.4.drv' failed to build
error: 1 dependencies of derivation '/nix/store/p90dh60zbwsmnxwaqc0vzakwa2y4b6mz-python3.10-filelock-3.2.1.drv' failed to build
error: 1 dependencies of derivation '/nix/store/wr0kvmx1r42blc5x2gb6ivfqsp8dv5f4-python3.10-idna-2.10.drv' failed to build
error: 1 dependencies of derivation '/nix/store/r2vzzsx1rpm0hkwp1nlq4m91vzrx71wf-python3.10-jeepney-0.7.1.drv' failed to build
error: 1 dependencies of derivation '/nix/store/2ca79ms2wri8zxpvgw1li3nx97c8cr6g-python3.10-lockfile-0.12.2.drv' failed to build
error: 1 dependencies of derivation '/nix/store/41976liy18c9qssz80swjgsils25gqnx-python3.10-msgpack-1.0.4.drv' failed to build
error: 1 dependencies of derivation '/nix/store/f723cjii4zkhvqp4nmxrby5js559cwx6-python3.10-pkginfo-1.8.2.drv' failed to build
error: 1 dependencies of derivation '/nix/store/f7v5m492sph1nswxyaz73hyxy9bv0ssk-python3.10-platformdirs-2.0.2.drv' failed to build
error: 1 dependencies of derivation '/nix/store/ywbn7nd8dwa8npbl29mh2wgcmxbzkj9m-python3.10-poetry-core-1.0.8.drv' failed to build
error: 1 dependencies of derivation '/nix/store/8n0c4jpylkz6xqz5y2lkq8llnyqzn7w6-python3.10-ptyprocess-0.7.0.drv' failed to build
error: 1 dependencies of derivation '/nix/store/k8pgdvyc222vc1x7dgc5s6qpl7999mmp-python3.10-pycparser-2.21.drv' failed to build
error: 1 dependencies of derivation '/nix/store/4a858crirfhcjabbymag8p0crmbrs2m7-python3.10-pylev-1.4.0.drv' failed to build
error: 2 dependencies of derivation '/nix/store/7q4m52r1vy23r32vxyl3q8fsp8k0qgxh-python3.10-setuptools-rust-1.5.1.drv' failed to build
error: 1 dependencies of derivation '/nix/store/qzx1wxi4p3vfv98v1gjjsia3prs0ssd9-python3.10-shellingham-1.4.0.drv' failed to build
error: 1 dependencies of derivation '/nix/store/zvy47jy8fzym6b54z4bvhmxg4j3h5206-python3.10-urllib3-1.26.9.drv' failed to build
error: 1 dependencies of derivation '/nix/store/j8s2w0diav58snwaqny16m23hhl11sg2-python3.10-webencodings-0.5.1.drv' failed to build
building '/nix/store/h0hhg6rc6clzhw50z01nh2lax94ag77k-udev-rules.drv'...
building '/nix/store/czilllfairqvac6p676zyiz8xyw5csf9-unit-gpg-agent.service.drv'...
building '/nix/store/fz6wljxr672mn3bnwvm1jz15k1afz54v-unit-script-anbox-container-manager-pre-start.drv'...
building '/nix/store/gwmyals15yp5p5h7ag67zvy72qjcr311-unit-systemd-udevd.service.drv'...
building '/nix/store/mgjfliwy871a3dsnzqdfzzgw6wikynnd-unit-waydroid-container.service.drv'...
error: 2 dependencies of derivation '/nix/store/gr3lli4wfn9s7wgiskqf9az2n4cdckpk-python3.10-cffi-1.15.1.drv' failed to build
error: 2 dependencies of derivation '/nix/store/j8q1w6pgayixdviv801zjb9wqnqbffa4-python3.10-crashtest-0.3.1.drv' failed to build
error: 3 dependencies of derivation '/nix/store/mfb3vwlnxpwvsmg1r96qp6i9n2ahwkzc-python3.10-html5lib-1.1.drv' failed to build
error: 2 dependencies of derivation '/nix/store/3fjm0z35xj60p64hp40vbaz5w0cnhq6f-python3.10-pastel-0.2.1.drv' failed to build
error: 2 dependencies of derivation '/nix/store/f37hpvljv1g2if9l4wfvpw14k3axnz48-python3.10-pexpect-4.8.0.drv' failed to build
error: 5 dependencies of derivation '/nix/store/wks0jhsb85xswxnp3lxxl8i2vq6g01mm-python3.10-requests-2.25.1.drv' failed to build
error: 2 dependencies of derivation '/nix/store/vvz0ap4j2dqfghca8ybsa1wvphds8wps-python3.10-tomlkit-0.7.2.drv' failed to build
error: 5 dependencies of derivation '/nix/store/5vfjqkq3m4irl2d1in8lbxgnjqlswvf8-python3.10-virtualenv-20.15.1.drv' failed to build
error: 4 dependencies of derivation '/nix/store/085x6dps3knx156fq63wi66l0nsvw4if-python3.10-cachecontrol-0.12.11.drv' failed to build
error: 5 dependencies of derivation '/nix/store/ag0s043rvcxz57rvz6h7h00dn1pl92wq-python3.10-clikit-0.6.2.drv' failed to build
error: 3 dependencies of derivation '/nix/store/ql5jsw587pdxxbksq3vsn0cxxklzfwdf-python3.10-cryptography-37.0.4.drv' failed to build
error: 2 dependencies of derivation '/nix/store/15pgjis0cp1yzlziv1csarj6sl5h11cb-python3.10-requests-toolbelt-0.9.1.drv' failed to build
error: 3 dependencies of derivation '/nix/store/9nyj7pydpkgsmxpf85fzn2mcgbi1if46-python3.10-cleo-0.8.1.drv' failed to build
error: 3 dependencies of derivation '/nix/store/54zrj2ac82rdhc58j46lhkhizq9nsahn-python3.10-secretstorage-3.3.2.drv' failed to build
error: 4 dependencies of derivation '/nix/store/cfv33w2xc7lxrv3zjbcv75nni1a6phvr-python3.10-keyring-22.3.0.drv' failed to build
error: 16 dependencies of derivation '/nix/store/bvzl52l1maa7yw70cwql3kxnhzf6id57-python3.10-poetry-1.1.14.drv' failed to build
error: 1 dependencies of derivation '/nix/store/b9m7gz29qqab4r7676r5xxc2ycs259xx-python3.10-poetry-1.1.14_fish-completions.drv' failed to build

Happens since buildPython*: wrap setuptools in hook for catching conflicts · NixOS/nixpkgs@13bb0f4 · GitHub, I bisected over the last 3 days…

Enough time to close the related issue as “fixed” without a fix, or I am fundamentally misunderstanding something… nixpkgs#poetry is broken at nixpkgs-unstable · Issue #193657 · NixOS/nixpkgs · GitHub

I have not yet seen a replacement for that issue.

so my answer is get rid of poetry from nixpkgs,
and long answer is they gotta patch poetry?

From my understanding, poetry2nix needs to get fixed to create an expression that contains setuptools.

The linked issue has been reopenend eith that information given a couple of hours ago.

So for now, use a poetry from an earlier version of nixpkgs and wait for a fix.

FWIW, I was still having this same error, even after the fix was merged in that GH issue. Instead, I found poetry2nix has an edge case section in their docs which I was able to utilize to resolve it.