From: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
To: buildroot@busybox.net
Subject: [Buildroot] [PATCH 1/1] package/opencv3: python support needs .py modules
Date: Fri, 13 Sep 2019 22:10:07 +0200 [thread overview]
Message-ID: <20190913221007.74731262@windsurf.home> (raw)
In-Reply-To: <2ab3c932-a8d0-b682-18d1-552b5ccb81d6@mind.be>
On Sun, 8 Sep 2019 17:48:46 +0200
Arnout Vandecappelle <arnout@mind.be> wrote:
> On 05/09/2019 20:44, Fabrice Fontaine wrote:
> > Fixes:
> > - https://bugs.buildroot.org/show_bug.cgi?id=12171
>
> To make sure this thread stays readable, I'll repeat the relevant part of the
> bug report, which should have been part of the commit message:
>
> When importing cv2 in python 3.7, the program stops with:
>
> File "usr/lib/python3.7/site-packages/cv2/__init__.py", line 89, in <module>
> File "usr/lib/python3.7/site-packages/cv2/__init__.py", line 58, in bootstrap
> File "usr/lib/python3.7/site-packages/cv2/__init__.py", line 56, in
> load_first_config
> ImportError: OpenCV loader: missing configuration file: ['config.py']. Check
> OpenCV installation.
>
> Since buildroot removed all *.py, leaving the corresponding *.pyc, the above
> config.py file is not in target.
It is a bit weird/funky for OpenCV to require a .py file just for this.
It contains a single variable:
BINARIES_PATHS = [
@CMAKE_PYTHON_BINARIES_PATH@
] + BINARIES_PATHS
And then the code looks like this:
def load_first_config(fnames, required=True):
for fname in fnames:
fpath = os.path.join(LOADER_DIR, fname)
if not os.path.exists(fpath):
if DEBUG: print('OpenCV loader: config not found, skip: {}'.format(fpath))
continue
if DEBUG: print('OpenCV loader: loading config: {}'.format(fpath))
exec_file_wrapper(fpath, g_vars, l_vars)
return True
if required:
raise ImportError('OpenCV loader: missing configuration file: {}. Check OpenCV installation.'.format(fnames))
load_first_config(['config.py'], True)
load_first_config([
'config-{}.{}.py'.format(sys.version_info[0], sys.version_info[1]),
'config-{}.py'.format(sys.version_info[0])
], True)
So all it does is override the BINARIES_PATH array with some additional
value. I'm sure we can replace this with reading a simple text file
that does the exact same thing without requiring to compile/exec a .py
file.
Best regards,
Thomas
--
Thomas Petazzoni, CTO, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
next prev parent reply other threads:[~2019-09-13 20:10 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-09-05 18:44 [Buildroot] [PATCH 1/1] package/opencv3: python support needs .py modules Fabrice Fontaine
2019-09-05 18:49 ` Thomas Petazzoni
2019-09-05 18:55 ` Fabrice Fontaine
2019-09-08 15:48 ` Arnout Vandecappelle
2019-09-13 20:10 ` Thomas Petazzoni [this message]
2019-09-14 17:18 ` Arnout Vandecappelle
2019-09-15 20:52 ` Thomas Petazzoni
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190913221007.74731262@windsurf.home \
--to=thomas.petazzoni@bootlin.com \
--cc=buildroot@busybox.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.