QEMU-Devel Archive on lore.kernel.org
 help / color / Atom feed
* [Qemu-devel] [PATCH] configure: more resilient Python version capture
@ 2019-08-23 21:54 Cleber Rosa
  2019-08-24  7:32 ` tony.nguyen
  0 siblings, 1 reply; 4+ messages in thread
From: Cleber Rosa @ 2019-08-23 21:54 UTC (permalink / raw)
  To: qemu-devel, Peter Maydell; +Cc: Julio Montes, Eduardo Habkost, Cleber Rosa

The current approach to capture the Python version is fragile, as it
was demonstrated by a very specific build of Python 3 on Fedora 29
that, under non-interactive shells would print multiline version
information.

The (badly) stripped version output would be sent to config-host.mak,
producing bad syntax and rendering the makefiles unusable.  Now, the
Python versions is printed by configure, but only a simple (and better
controlled variable) indicating whether the build system is using
Python 2 is kept on config-host.mak.

Signed-off-by: Cleber Rosa <crosa@redhat.com>
---
 configure              | 5 +++--
 tests/Makefile.include | 2 +-
 2 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/configure b/configure
index e44e454c43..90b29037ab 100755
--- a/configure
+++ b/configure
@@ -1864,7 +1864,7 @@ if ! $python -c 'import sys; sys.exit(sys.version_info < (2,7))'; then
 fi
 
 # Preserve python version since some functionality is dependent on it
-python_version=$($python -V 2>&1 | sed -e 's/Python\ //')
+python_version=$(python2 -c 'import sys; print("%d.%d.%d" % (sys.version_info[0], sys.version_info[1], sys.version_info[2]))' 2>/dev/null)
 
 # Suppress writing compiled files
 python="$python -B"
@@ -6511,6 +6511,7 @@ if ! $python -c 'import sys; sys.exit(sys.version_info < (3,0))'; then
   echo
   echo "warning: Python 2 support is deprecated" >&2
   echo "warning: Python 3 will be required for building future versions of QEMU" >&2
+  python2="y"
 fi
 
 config_host_mak="config-host.mak"
@@ -7333,7 +7334,7 @@ echo "INSTALL_DATA=$install -c -m 0644" >> $config_host_mak
 echo "INSTALL_PROG=$install -c -m 0755" >> $config_host_mak
 echo "INSTALL_LIB=$install -c -m 0644" >> $config_host_mak
 echo "PYTHON=$python" >> $config_host_mak
-echo "PYTHON_VERSION=$python_version" >> $config_host_mak
+echo "PYTHON2=$python2" >> $config_host_mak
 echo "CC=$cc" >> $config_host_mak
 if $iasl -h > /dev/null 2>&1; then
   echo "IASL=$iasl" >> $config_host_mak
diff --git a/tests/Makefile.include b/tests/Makefile.include
index 49684fd4f4..f5ac09549c 100644
--- a/tests/Makefile.include
+++ b/tests/Makefile.include
@@ -1135,7 +1135,7 @@ TESTS_RESULTS_DIR=$(BUILD_DIR)/tests/results
 AVOCADO_SHOW=app
 AVOCADO_TAGS=$(patsubst %-softmmu,-t arch:%, $(filter %-softmmu,$(TARGET_DIRS)))
 
-ifneq ($(findstring v2,"v$(PYTHON_VERSION)"),v2)
+ifneq ($(PYTHON2),y)
 $(TESTS_VENV_DIR): $(TESTS_VENV_REQ)
 	$(call quiet-command, \
             $(PYTHON) -m venv --system-site-packages $@, \
-- 
2.21.0



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [Qemu-devel] [PATCH] configure: more resilient Python version capture
  2019-08-23 21:54 [Qemu-devel] [PATCH] configure: more resilient Python version capture Cleber Rosa
@ 2019-08-24  7:32 ` tony.nguyen
  2019-08-25 15:07   ` Peter Maydell
  2019-08-26 13:09   ` Cleber Rosa
  0 siblings, 2 replies; 4+ messages in thread
From: tony.nguyen @ 2019-08-24  7:32 UTC (permalink / raw)
  To: crosa, qemu-devel, peter.maydell; +Cc: julio.montes, ehabkost

> -python_version=$($python -V 2>&1 | sed -e 's/Python\ //')
> +python_version=$(python2 -c 'import sys; print("%d.%d.%d" % (sys.version_info[0], sys.version_info[1], sys.version_info[2]))' 2>/dev/null)

On a Python 3 only system, configure will no longer print the version.

e.g.         
/* snip */
install           install
python            python3 -B ()
slirp support     git 
/* snip */

> @@ -6511,6 +6511,7 @@ if ! $python -c 'import sys; sys.exit(sys.version_info < (3,0))'; then
>    echo
>    echo "warning: Python 2 support is deprecated" >&2 
>    echo "warning: Python 3 will be required for building future versions of QEMU" >&2 
> +  python2="y"
>  fi  
...
> -echo "PYTHON_VERSION=$python_version" >> $config_host_mak
> +echo "PYTHON2=$python2" >> $config_host_mak
...
> -ifneq ($(findstring v2,"v$(PYTHON_VERSION)"),v2)
> +ifneq ($(PYTHON2),y)

Succinctly, if Python 3.

We can further ween the world off Python 2 by replacing python2="y" for 
python3="y" and PYTHON2 for PYTHON3.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [Qemu-devel] [PATCH] configure: more resilient Python version capture
  2019-08-24  7:32 ` tony.nguyen
@ 2019-08-25 15:07   ` Peter Maydell
  2019-08-26 13:09   ` Cleber Rosa
  1 sibling, 0 replies; 4+ messages in thread
From: Peter Maydell @ 2019-08-25 15:07 UTC (permalink / raw)
  To: tony.nguyen; +Cc: Julio Montes, QEMU Developers, Eduardo Habkost, Cleber Rosa

On Sat, 24 Aug 2019 at 08:32, <tony.nguyen@bt.com> wrote:
> > -echo "PYTHON_VERSION=$python_version" >> $config_host_mak
> > +echo "PYTHON2=$python2" >> $config_host_mak
> ...
> > -ifneq ($(findstring v2,"v$(PYTHON_VERSION)"),v2)
> > +ifneq ($(PYTHON2),y)
>
> Succinctly, if Python 3.
>
> We can further ween the world off Python 2 by replacing python2="y" for
> python3="y" and PYTHON2 for PYTHON3.

I don't think it's a big deal which way round we do this, because
once we drop Python 2 support the if and the variable will just
be deleted entirely.

thanks
-- PMM


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [Qemu-devel] [PATCH] configure: more resilient Python version capture
  2019-08-24  7:32 ` tony.nguyen
  2019-08-25 15:07   ` Peter Maydell
@ 2019-08-26 13:09   ` Cleber Rosa
  1 sibling, 0 replies; 4+ messages in thread
From: Cleber Rosa @ 2019-08-26 13:09 UTC (permalink / raw)
  To: tony.nguyen; +Cc: julio.montes, peter.maydell, qemu-devel, ehabkost

On Sat, Aug 24, 2019 at 07:32:24AM +0000, tony.nguyen@bt.com wrote:
> > -python_version=$($python -V 2>&1 | sed -e 's/Python\ //')
> > +python_version=$(python2 -c 'import sys; print("%d.%d.%d" % (sys.version_info[0], sys.version_info[1], sys.version_info[2]))' 2>/dev/null)
> 
> On a Python 3 only system, configure will no longer print the version.
>

Oh my, this is not what I intended... gross late Friday mistake.  I meant:

python_version=$($python -c 'import sys; print("%d.%d.%d" % (sys.version_info[0], sys.version_info[1], sys.version_info[2]))' 2>/dev/null)

- Cleber.


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, back to index

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-08-23 21:54 [Qemu-devel] [PATCH] configure: more resilient Python version capture Cleber Rosa
2019-08-24  7:32 ` tony.nguyen
2019-08-25 15:07   ` Peter Maydell
2019-08-26 13:09   ` Cleber Rosa

QEMU-Devel Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/qemu-devel/0 qemu-devel/git/0.git
	git clone --mirror https://lore.kernel.org/qemu-devel/1 qemu-devel/git/1.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 qemu-devel qemu-devel/ https://lore.kernel.org/qemu-devel \
		qemu-devel@nongnu.org qemu-devel@archiver.kernel.org
	public-inbox-index qemu-devel


Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.nongnu.qemu-devel


AGPL code for this site: git clone https://public-inbox.org/ public-inbox