Skip to contentSkip to conversation

Fix check for Python modules for cross-compilation

PATCH New Yann E. MORIN 1 participant 4 messages Jan 14, 2014 – Jan 18, 2014 2 messages not in the archive

lore
Share & tools
lore
#0 lore raw

cover Fix check for Python modules for cross-compilation

Hello Simon and Peter!

Here are two patches to enhance (fix) the check of Python modules while cross-compiling.

There is extensive explanations in the commit log of each patch, but it basically boils down to the fact that we can't check for Python modules while doing cross-compilation:
- we can't execute the target Python (obviously)
- the host Python may not have the required module(s)

We've stumbled into this issue while building ola with Buildroot:
http://buildroot.org/

If you prefer a pull-request, I can set up a public repo for you to pull from.

I'm sending those to you two, since I could not find a contact info for where to send the patches. If I missed it, please be kind enough to point me to the correct recipient(s) or mailing list.

Regards,
Yann E. MORIN.

Signature · 6 lines
.-----------------.--------------------.------------------.--------------------.
|  Yann E. MORIN  | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: |
| +33 662 376 056 | Software  Designer | \ / CAMPAIGN     |  ___               |
| +33 223 225 172 `------------.-------:  X  AGAINST      |  \e/  There is no  |
| http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL    |   v   conspiracy.  |
'------------------------------^-------^------------------^--------------------'
#1 lore raw

PATCH 1/2 configure: move python sub-check to configure.ac

From: "Yann E. MORIN" <[email protected]>

We do not want to re-test the python name for each Python module we want to check for.

Even if we only check for one Python module right now, this is good practice overall.

---
 config/ax_python_module.m4 | 5 -----
 configure.ac               | 4 ++++
 2 files changed, 4 insertions(+), 5 deletions(-)
config/ax_python_module.m4 +0 -5
index bd70a06..96dd1ab 100644
@@ -25,11 +25,6 @@
 
 AU_ALIAS([AC_PYTHON_MODULE], [AX_PYTHON_MODULE])
 AC_DEFUN([AX_PYTHON_MODULE],[
-    if test -z $PYTHON;
-    then
-        PYTHON="python"
-    fi
-    PYTHON_NAME=`basename $PYTHON`
     AC_MSG_CHECKING($PYTHON_NAME module: $1)
 	$PYTHON -c "import $1" 2>/dev/null
 	if test $? -eq 0;
configure.ac +4 -0
index 1efedf1..5f6f604 100644
@@ -570,6 +570,10 @@ AM_CONDITIONAL(INSTALL_RDM_TESTS, test "${enable_rdm_tests}" = "yes")
 
 if test "${enable_python_libs}" = "yes"; then
  AM_PATH_PYTHON(2.6)
+ if test -z $PYTHON; then
+  PYTHON="python"
+ fi
+ PYTHON_NAME=`basename $PYTHON`
  AX_PYTHON_MODULE("google.protobuf", "fatal")
 fi
 
Signature · 1 line
1.8.1.2
#2 lore raw

PATCH 2/2 configure: add option for user to override checks for Python modules

In reply to Yann E. MORIN

From: "Yann E. MORIN" <[email protected]>

The check for google.protobuf is inherently flawed for cross-compilation, as it uses the host Python to check for target modules.

In this case, it is not possible to check for a Pyhon modules altogether, and we need to rely on the user to properly tell us whether we do or do not have google.protobuf.

This is done by adding am autoconf cache variable:
ac_cv_have_pymod_google_protobuf

which can be set to:
- yes : force the test to be true
- no : force the test to be false
- (empty) : let the test decide

This is then used in AX_PYTHON_MODULE to override the test.

Currently, only the google.protobuf Python module is checked for, but the same could be done later on of other Python modules that may be added in the future, of course.

Fixes configure-errors like:

    http://autobuild.buildroot.net/results/e63/e634d5f0cee3967caffaa6e7ada8c0968e3eff63/build-end.log

Also fixes some under-quotation in the python module check.

---
 config/ax_python_module.m4 | 11 ++++-------
 configure.ac               |  4 +++-
 2 files changed, 7 insertions(+), 8 deletions(-)
config/ax_python_module.m4 +4 -7
index 96dd1ab..2910e88 100644
@@ -25,20 +25,17 @@
 
 AU_ALIAS([AC_PYTHON_MODULE], [AX_PYTHON_MODULE])
 AC_DEFUN([AX_PYTHON_MODULE],[
-    AC_MSG_CHECKING($PYTHON_NAME module: $1)
 	$PYTHON -c "import $1" 2>/dev/null
 	if test $? -eq 0;
 	then
-		AC_MSG_RESULT(yes)
-		eval AS_TR_CPP(HAVE_PYMOD_$1)=yes
+		eval AS_TR_CPP([HAVE_PYMOD_$1])=yes
 	else
-		AC_MSG_RESULT(no)
-		eval AS_TR_CPP(HAVE_PYMOD_$1)=no
+		eval AS_TR_CPP([HAVE_PYMOD_$1])=no
 		#
 		if test -n "$2"
 		then
-			AC_MSG_ERROR(failed to find required module $1)
-			exit 1
+			AC_MSG_ERROR([failed to find required module $1])
 		fi
 	fi
+	AC_MSG_RESULT([AS_TR_CPP([HAVE_PYMOD_$1])])
 ])
configure.ac +3 -1
index 5f6f604..5994d06 100644
@@ -574,7 +574,9 @@ if test "${enable_python_libs}" = "yes"; then
   PYTHON="python"
  fi
  PYTHON_NAME=`basename $PYTHON`
- AX_PYTHON_MODULE("google.protobuf", "fatal")
+ AC_CACHE_CHECK([$PYTHON_NAME module: google.protobuf],
+    [ac_cv_have_pymod_google_protobuf],
+    [AX_PYTHON_MODULE([google.protobuf], [fatal])])
 fi
 
 # Maybe build the logic sniffer tools
Signature · 1 line
1.8.1.2

A message that is not in the archive (sent off-list or not yet received): CAPQm1=O0zZbJR4NWXjop5RH4-KMRTJWM60BiXnw6OHnv5m6T+Q@mail.gmail.com

A message that is not in the archive (sent off-list or not yet received): 02e001cf13e9$7fd5cee0$0700000a@D400

#5 lore raw

cover Fix check for Python modules for cross-compilation

Peter, Simon,

On 2014-01-18 01:06 -0000, Peter Newman spake thusly:

Quoted 7 lines

Taking on board what you said, I've put together a small page on our site about how to contribute:
http://www.openlighting.org/ola/developer-documentation/contributing/

As someone a bit external to the project, and a recent contributor, would you mind just taking a quick look at it to confirm it gives the sort of information you were looking for before?

OK, I was a bit puzzled when browsing the openlightning.org website. Navigating from the homepage down to the contributing section is not straightforward.

What is strange here is that he homepage has those shortcuts on the banner[*] : Overview - People - Supporters - History

Plus a big button to download OLA. But no info on how to contriute to OLA. I had expected to find something like "contacts" or "Developpers" right on the frontpage.

OK, so I hover over "Download OLA": it's not an archive, but point to a page labelled "getting-started". *That* sounds like a good starting point, indeed. *Click*

From there on, here's the path I followed:
-> Download & Install OLA
-> Install From Git
- section of "Install on Linux"
- no infro on how to contribute

Ok, what was this link Peter sent me, BTW? Ah, there is "developer-documentation" in the link. But I can't see a page labelled "developpers" or some such.

Hmm.. Wait! The banner does not contain the same items as the homepage does! And there *is* a "Developpers" item, now! Yes, it;s a menu! Yes it has a "Contributing" section. Aha! Good! :-)

So it all boils down to the fact that the homepage and the rest of the website does not contain the same items in the banner. I think it would be much more helpful to have the same banner acros the whoel website. After all, this banner should be a way to quickly go to interesting sections.

But, hey, the info is there and it took me only a few minutes to find it. So that's not so bad in the end.

All the required info I needed is there on that page, so that's good. Thank you for providing this; hopefully, that will make it easier for people to send their contributions. :-)

Regards,
Yann E. MORIN.

[*] Sorry, I'm French and don't know what this part is called in
english. I roughly tranlstated from the french "bandeau".

Signature · 6 lines
.-----------------.--------------------.------------------.--------------------.
|  Yann E. MORIN  | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: |
| +33 662 376 056 | Software  Designer | \ / CAMPAIGN     |  ___               |
| +33 223 225 172 `------------.-------:  X  AGAINST      |  \e/  There is no  |
| http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL    |   v   conspiracy.  |
'------------------------------^-------^------------------^--------------------'