Cadquery2 and python3.8 ? PYTHONPATH works but withPackages fails. Why?

https://mawercer.de/tmp/0001-attempt-to-add-cadquery2.patchhttps://www.topdegreesonline.org/apple-and-google/

works;
nix-shell -p python3Packages.python -p ‘python3Packages.cadquery2.pythonocc-core-cadquery’ --run ‘python -c “import OCC”’

doesn’t work:
nix-shell -p python38Packages.python -p ‘python38.withPackages (ps: with ps; [ ps.cadquery2.pythonocc-core-cadquery python six ])’ --run ‘python -c “import OCC”’

Setting PYTHONPATH=/nix/store/yx37hin6lb2hm30qlcfcn9fyrqg8j4i7-pythonocc-core-cadquery-master/lib/python3.8/site-packages
is enough to make it work

So what have i missed about withPackages ?

You are adding 2 conflicting python in PATH.

You probably want to omit the -p python38Packages.python. -p 'python38.withPackages (ps: with ps; [ ps.cadquery2.pythonocc-core-cadquery python six ])' should give you a python executable which is properly wrapped.

Before posting I tried that a well. Would have been nice if it were that simple.The question is more like should I add PYTHONPATH everywhere or try to fix it.

%nix-shell -p  'python38.withPackages (ps: with ps; [ ps.cadquery2.pythonocc-core-cadquery python  six ])' --run 'python  -c "import OCC"'                        
Traceback (most recent call last):
  File "<string>", line 1, in <module>
ModuleNotFoundError: No module named 'OCC'

For the cadquery in Nixpkgs it is fixed with pythonPackages.cadquery: wrap pythonocc-core-cadquery with toPythonMo… · NixOS/nixpkgs@e131f22 · GitHub