NixOS:master
← pasqui23:fake-background-webcam
opened 08:38PM - 02 Jan 22 UTC
<!--
To help with the large amounts of pull requests, we would appreciate your
…
reviews of other pull requests, especially simple package updates. Just leave a
comment describing what you have tested in the relevant package/service.
Reviewing helps to reduce the average time-to-merge for everyone.
Thanks a lot if you do!
List of open PRs: https://github.com/NixOS/nixpkgs/pulls
Reviewing guidelines: https://nixos.org/manual/nixpkgs/unstable/#chap-reviewing-contributions
-->
###### Motivation for this change
I want a working implementation of fake background
###### Things done
The build fails with
```
; nix build .#python3Packages.fake-background-webcam
def-matcher: command not found
warning: Git tree '/home/me/src/nixpkgs' is dirty
error: builder for '/nix/store/a2ggdkgzyjjj5pbr8apxnpv28sf6g64z-python3.9-cmapy-0.6.6.drv' failed with exit code 1;
last 10 log lines:
> adding 'cmapy-0.6.6.dist-info/top_level.txt'
> adding 'cmapy-0.6.6.dist-info/RECORD'
> removing build/bdist.linux-x86_64/wheel
> Finished executing setuptoolsBuildPhase
> installing
> Executing pipInstallPhase
> /build/cmapy-0.6.6/dist /build/cmapy-0.6.6
> Processing ./cmapy-0.6.6-py3-none-any.whl
> ERROR: Could not find a version that satisfies the requirement opencv>=3.3 (from cmapy) (from versions: none)
> ERROR: No matching distribution found for opencv>=3.3
For full logs, run 'nix log /nix/store/a2ggdkgzyjjj5pbr8apxnpv28sf6g64z-python3.9-cmapy-0.6.6.drv'.
error: 1 dependencies of derivation '/nix/store/hny98vdm4a7ls2p41v59vn3qs6dlpcrq-fake-background-webcam-unstable-2021-11-28.drv' failed to build
```
- Built on platform(s)
- [ ] x86_64-linux
- [ ] aarch64-linux
- [ ] x86_64-darwin
- [ ] aarch64-darwin
- [ ] For non-Linux: Is `sandbox = true` set in `nix.conf`? (See [Nix manual](https://nixos.org/manual/nix/stable/command-ref/conf-file.html))
- [ ] Tested, as applicable:
- [NixOS test(s)](https://nixos.org/manual/nixos/unstable/index.html#sec-nixos-tests) (look inside [nixos/tests](https://github.com/NixOS/nixpkgs/blob/master/nixos/tests))
- and/or [package tests](https://nixos.org/manual/nixpkgs/unstable/#sec-package-tests)
- or, for functions and "core" functionality, tests in [lib/tests](https://github.com/NixOS/nixpkgs/blob/master/lib/tests) or [pkgs/test](https://github.com/NixOS/nixpkgs/blob/master/pkgs/test)
- made sure NixOS tests are [linked](https://nixos.org/manual/nixpkgs/unstable/#ssec-nixos-tests-linking) to the relevant packages
- [ ] Tested compilation of all packages that depend on this change using `nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD"`. Note: all changes have to be committed, also see [nixpkgs-review usage](https://github.com/Mic92/nixpkgs-review#usage)
- [ ] Tested basic functionality of all binary files (usually in `./result/bin/`)
- [22.05 Release Notes (or backporting 21.11 Release notes)](https://github.com/NixOS/nixpkgs/blob/master/CONTRIBUTING.md#generating-2205-release-notes)
- [ ] (Package updates) Added a release notes entry if the change is major or breaking
- [ ] (Module updates) Added a release notes entry if the change is significant
- [ ] (Module addition) Added a release notes entry if adding a new NixOS module
- [ ] (Release notes changes) Ran `nixos/doc/manual/md-to-db.sh` to update generated release notes
- [ ] Fits [CONTRIBUTING.md](https://github.com/NixOS/nixpkgs/blob/master/CONTRIBUTING.md).
I want a python package to take a opencv4
dependency, but if I put the dependency in propagatedBuildInputs like nixpkgs/default.nix at 6aec41eebecce8a296442a71dcfe8727e812914d · NixOS/nixpkgs · GitHub it still complains about missing python-opencv.
How do I say to use opencv for its python-opencv?
austin
January 3, 2022, 1:18am
2
It may be that you are using opencv
when you need the Python package instead.
Maybe try changing to:
fake-background-webcam = callPackage ../applications/video/fake-background-webcam {
opencv = python3Packages.opencv4;
};
I am already building it by nix build .#python3Packages.fake-background-webcam
so it should take the opencv from the python package set
And yet it does not seem to recognize it.
1 Like
opencv4 is incorrectly packaged:
$ tree $(nix-build '<nixpkgs>' -A python3Packages.opencv4)/lib/python3.9/
/nix/store/dfylw3ppidn6gpbxrkjhmpsazk7cdzdj-opencv-4.5.4/lib/python3.9/
└── site-packages
└── cv2.cpython-39-x86_64-linux-gnu.so
There should be some distribution information
$ tree -L 3 $(nix-build '<nixpkgs>' -A python3Packages.requests)/lib/python3.9/
/nix/store/pa8f3ajnj32hp13is72yw8nfcd94bg1w-python3.9-requests-2.26.0/lib/python3.9/
└── site-packages
├── requests
....
└── requests-2.26.0.dist-info
├── direct_url.json
├── INSTALLER
├── LICENSE
├── METADATA
├── RECORD
├── REQUESTED
├── top_level.txt
└── WHEEL
That’s my suspicion, can you help me with those files?
I’m creating a PR to fix it for nixpkgs
This was more of a pain than I thought it would be. But here’s the PR: python3Packages.opencv4: fix installation metadata by jonringer · Pull Request #153373 · NixOS/nixpkgs · GitHub
Couldn’t get it to actually “work”
$ nix-shell -E 'with import ./. { }; mkShell { name = "test"; nativeBuildInputs = [ (python3.withPackages (ps: [ps.opencv4])) ]; }'
[nix-shell:~/projects/nixpkgs]$ python
Python 3.9.9 (main, Nov 15 2021, 18:05:17)
[GCC 10.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import cv2
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/nix/store/b60icklg1rxdjddk8aysg14zyxnb6za0-python3-3.9.9-env/lib/python3.9/site-packages/cv2/__init__.py", line 180, in <module>
bootstrap()
File "/nix/store/b60icklg1rxdjddk8aysg14zyxnb6za0-python3-3.9.9-env/lib/python3.9/site-packages/cv2/__init__.py", line 110, in bootstrap
load_first_config(['config.py'], True)
File "/nix/store/b60icklg1rxdjddk8aysg14zyxnb6za0-python3-3.9.9-env/lib/python3.9/site-packages/cv2/__init__.py", line 108, in load_first_config
raise ImportError('OpenCV loader: missing configuration file: {}. Check OpenCV installation.'.format(fnames))
ImportError: OpenCV loader: missing configuration file: ['config.py']. Check OpenCV installation.
But this appears to be intended behavior, as pyinstaller is required ImportError: OpenCV loader: missing configuration file: ['config.py']. · Issue #569 · opencv/opencv-python · GitHub
Hmm, deleting all of the cv2 python files seems to make it work just fine as a module.
+ # the cv2/__init__.py just tries to check provide "nice user feedback" if the installation is bad
+ # however, this also causes infinite recursion when used by other packages
+ rm -r $out/${pythonPackages.python.sitePackages}/cv2
[11:20:57] jon@nixos ~/projects/nixpkgs (fix-opencv4)
$ nix-shell -E 'with import ./. { }; mkShell { name = "test"; nativeBuildInputs = [ (python3.withPackages (ps: [ps.opencv4])) ]; }'
[nix-shell:~/projects/nixpkgs]$ python
Python 3.9.9 (main, Nov 15 2021, 18:05:17)
[GCC 10.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import cv2
>>>
Apparently the module requires opencv-python
,although it is used in the exact same way
interesting, I think that’s what the directory is called. But that’s now how they install it.
I’ve already tried symlinking opencv-ver.dist-info toopencv-python-ver.dist-inf but failed
{ lib, runCommand, opencv4 }:
runCommand "opencv-python-${opencv4.version}" { inherit (opencv4) version meta; } ''
o="lib/python3.9/site-packages/"
mkdir -p "$out/$o"
cd "$out/$o"
ln -s ${opencv4}/$o/{cv2.*,opencv*} .
mv opencv{,-python}-${opencv4.version}.dist-info
''