package/rust: allow using python3 interpreter
Fedora packaging use python3 as python interpreter since rust 1.24.0 [1] by removing python2 tests from configure script [2].
Using python3 will help to remove python2 in a near future.
[1] https://src.fedoraproject.org/rpms/rust/c/216b2d27716bf1031c526dbd0e01a1fa8e6d5aa2
[2] https://src.fedoraproject.org/rpms/rust/blob/216b2d27716bf1031c526dbd0e01a1fa8e6d5aa2/f/rust.spec#_314
--- ...igure-use-default-python-interpreter.patch | 37 +++++++++++++++++++ package/rust/rust.mk | 17 ++++++--- 2 files changed, 49 insertions(+), 5 deletions(-) create mode 100644 package/rust/0002-configure-use-default-python-interpreter.patch
package/rust/0002-configure-use-default-python-interpreter.patch new file +37 -0
@@ -0,0 +1,37 @@ +From aca7abb537f5caf1c9f027cf65dd0f53fb664e73 Mon Sep 17 00:00:00 2001 +From: Romain Naour <[email protected]> +Date: Tue, 26 May 2020 18:24:25 +0200 +Subject: [PATCH] configure: use default python interpreter + +Don't try to use python2 if available, use the python interpreter available +in ouput/host/bin/python whateverer the python version is. + +Signed-off-by: Romain Naour <[email protected]> +--- + configure | 12 ------------ + 1 file changed, 12 deletions(-) + +diff --git a/configure b/configure +index eeb8d081d34..6014a982f47 100755 +--- a/configure ++++ b/configure +@@ -2,16 +2,4 @@ + + script="$(dirname $0)"/src/bootstrap/configure.py + +-try() { +- cmd=$1 +- shift +- T=$($cmd --version 2>/dev/null) +- if [ $? -eq 0 ]; then +- exec $cmd "$script" "$@" +- fi +-} +- +-try python2.7 "$@" +-try python27 "$@" +-try python2 "$@" + exec python $script "$@" +-- +2.25.4 +
package/rust/rust.mk +12 -5
@@ -17,9 +17,16 @@ HOST_RUST_DEPENDENCIES = \ host-rust-bin \ host-cargo-bin \ host-openssl \ - host-python \ $(BR2_CMAKE_HOST_DEPENDENCY) +ifeq ($(BR2_PACKAGE_PYTHON3),y) +HOST_RUST_PYTHON_VERSION = $(PYTHON3_VERSION_MAJOR) +HOST_RUST_DEPENDENCIES += host-python3 +else +HOST_RUST_PYTHON_VERSION = $(PYTHON_VERSION_MAJOR) +HOST_RUST_DEPENDENCIES += host-python +endif + HOST_RUST_VERBOSITY = $(if $(VERBOSE),2,0) # Some vendor crates contain Cargo.toml.orig files. The associated
@@ -44,7 +51,7 @@ define HOST_RUST_CONFIGURE_CMDS echo 'target = ["$(RUSTC_TARGET_NAME)"]'; \ echo 'cargo = "$(HOST_CARGO_BIN_DIR)/cargo/bin/cargo"'; \ echo 'rustc = "$(HOST_RUST_BIN_DIR)/rustc/bin/rustc"'; \ - echo 'python = "$(HOST_DIR)/bin/python2"'; \ + echo 'python = "$(HOST_DIR)/bin/python$(HOST_RUST_PYTHON_VERSION)"'; \ echo 'submodules = false'; \ echo 'vendor = true'; \ echo 'compiler-docs = false'; \
@@ -61,12 +68,12 @@ define HOST_RUST_CONFIGURE_CMDS endef define HOST_RUST_BUILD_CMDS - cd $(@D); $(HOST_MAKE_ENV) $(HOST_DIR)/bin/python2 x.py build + cd $(@D); $(HOST_MAKE_ENV) $(HOST_DIR)/bin/python$(HOST_RUST_PYTHON_VERSION) x.py build endef define HOST_RUST_INSTALL_CMDS - cd $(@D); $(HOST_MAKE_ENV) $(HOST_DIR)/bin/python2 x.py dist - cd $(@D); $(HOST_MAKE_ENV) $(HOST_DIR)/bin/python2 x.py install + cd $(@D); $(HOST_MAKE_ENV) $(HOST_DIR)/bin/python$(HOST_RUST_PYTHON_VERSION) x.py dist + cd $(@D); $(HOST_MAKE_ENV) $(HOST_DIR)/bin/python$(HOST_RUST_PYTHON_VERSION) x.py install endef $(eval $(host-generic-package))
Signature · 1 line
2.25.4
Titouan Christophe
Tested-byHello Romain and all,
Quoted 5 lines · Romain Naour
Fedora packaging use python3 as python interpreter since rust 1.24.0 [1] by removing python2 tests from configure script [2].
Using python3 will help to remove python2 in a near future.
Quoted 7 lines
[1] https://src.fedoraproject.org/rpms/rust/c/216b2d27716bf1031c526dbd0e01a1fa8e6d5aa2
[2] https://src.fedoraproject.org/rpms/rust/blob/216b2d27716bf1031c526dbd0e01a1fa8e6d5aa2/f/rust.spec#_314Signed-off-by Romain Naour <[email protected]>Cc Titouan Christophe <[email protected]>Cc Arnout Vandecappelle <[email protected]>Cc Patrick Havelange <[email protected]>
Quoted 6 lines
--- ...igure-use-default-python-interpreter.patch | 37 +++++++++++++++++++ package/rust/rust.mk | 17 ++++++--- 2 files changed, 49 insertions(+), 5 deletions(-)create mode 100644
package/rust/0002-configure-use-default-python-interpreter.patch
Hello Romain,
Quoted 5 lines · On Tue, 26 May 2020 20:20:37 +0200 Romain Naour <[email protected]> wrote:
Fedora packaging use python3 as python interpreter since rust 1.24.0 [1] by removing python2 tests from configure script [2].
Using python3 will help to remove python2 in a near future.
Quoted 7 lines
[1] https://src.fedoraproject.org/rpms/rust/c/216b2d27716bf1031c526dbd0e01a1fa8e6d5aa2
[2] https://src.fedoraproject.org/rpms/rust/blob/216b2d27716bf1031c526dbd0e01a1fa8e6d5aa2/f/rust.spec#_314Signed-off-by Romain Naour <[email protected]>Cc Titouan Christophe <[email protected]>Cc Arnout Vandecappelle <[email protected]>Cc Patrick Havelange <[email protected]>
Thanks, I have applied to next, but I have a few comments/questions, see below.
Quoted 30 lines
package/rust/0002-configure-use-default-python-interpreter.patch new file +24
-0@@ -0,0 +1,37 @@ +From aca7abb537f5caf1c9f027cf65dd0f53fb664e73 Mon Sep 17 00:00:00 2001 +From: Romain Naour <[email protected]> +Date: Tue, 26 May 2020 18:24:25 +0200 +Subject: [PATCH] configure: use default python interpreter + +Don't try to use python2 if available, use the python interpreter available +in ouput/host/bin/python whateverer the python version is. + +Signed-off-by: Romain Naour <[email protected]> +--- + configure | 12 ------------ + 1 file changed, 12 deletions(-) + +diff --git a/configure b/configure +index eeb8d081d34..6014a982f47 100755 +--- a/configure ++++ b/configure +@@ -2,16 +2,4 @@ + + script="$(dirname $0)"/src/bootstrap/configure.py + +-try() { +- cmd=$1 +- shift
package/rust/0002-configure-use-default-python-interpreter.patch line 34
Quoted 10 lines
package/rust/0002-configure-use-default-python-interpreter.patch new file +10
-0+- T=$($cmd --version 2>/dev/null) +- if [ $? -eq 0 ]; then +- exec $cmd "$script" "$@" +- fi +-} +- +-try python2.7 "$@" +-try python27 "$@" +-try python2 "$@" + exec python $script "$@"
Shouldn't we try to find an upstreamable solution here, such as perhaps a PYTHON environment variable, or an argument to configure that allows to specify the path to the Python interpreter ?
But in fact, this path to the Python interpreter is already in the config.toml file that we generate, why isn't this path used ?
Quoted 8 lines
package/rust/rust.mk +0
-0@@ -17,9 +17,16 @@ HOST_RUST_DEPENDENCIES = \ host-rust-bin \ host-cargo-bin \ host-openssl \
package/rust/rust.mk HOST_RUST_DEPENDENCIES = \ · line 28
Quoted 10 lines
package/rust/rust.mk +7
-1- host-python \ $(BR2_CMAKE_HOST_DEPENDENCY) +ifeq ($(BR2_PACKAGE_PYTHON3),y) +HOST_RUST_PYTHON_VERSION = $(PYTHON3_VERSION_MAJOR) +HOST_RUST_DEPENDENCIES += host-python3 +else +HOST_RUST_PYTHON_VERSION = $(PYTHON_VERSION_MAJOR) +HOST_RUST_DEPENDENCIES += host-python +endif
I think we should start inverting this logic, i.e use host-python3 by default if there is no python interpreter selected for the target. We should do that not only here, but in all packages that have a logic like that: python3 should become our default, and python2 should become the exception.
Thanks!
Thomas
Signature · 3 lines
Thomas Petazzoni, CTO, Bootlin Embedded Linux and Kernel engineering https://bootlin.com
Hi Thomas,
Le 29/05/2020 ? 23:14, Thomas Petazzoni a ?crit?:
Quoted 66 lines
Hello Romain,
Quoted 5 lines · On Tue, 26 May 2020 20:20:37 +0200 Romain Naour <[email protected]> wrote:
Fedora packaging use python3 as python interpreter since rust 1.24.0 [1] by removing python2 tests from configure script [2].
Using python3 will help to remove python2 in a near future.
Quoted 7 lines
[1] https://src.fedoraproject.org/rpms/rust/c/216b2d27716bf1031c526dbd0e01a1fa8e6d5aa2
[2] https://src.fedoraproject.org/rpms/rust/blob/216b2d27716bf1031c526dbd0e01a1fa8e6d5aa2/f/rust.spec#_314Signed-off-by Romain Naour <[email protected]>Cc Titouan Christophe <[email protected]>Cc Arnout Vandecappelle <[email protected]>Cc Patrick Havelange <[email protected]>Thanks, I have applied to next, but I have a few comments/questions, see below.
Quoted 30 lines
package/rust/0002-configure-use-default-python-interpreter.patch new file +24
-0@@ -0,0 +1,37 @@ +From aca7abb537f5caf1c9f027cf65dd0f53fb664e73 Mon Sep 17 00:00:00 2001 +From: Romain Naour <[email protected]> +Date: Tue, 26 May 2020 18:24:25 +0200 +Subject: [PATCH] configure: use default python interpreter + +Don't try to use python2 if available, use the python interpreter available +in ouput/host/bin/python whateverer the python version is. + +Signed-off-by: Romain Naour <[email protected]> +--- + configure | 12 ------------ + 1 file changed, 12 deletions(-) + +diff --git a/configure b/configure +index eeb8d081d34..6014a982f47 100755 +--- a/configure ++++ b/configure +@@ -2,16 +2,4 @@ + + script="$(dirname $0)"/src/bootstrap/configure.py + +-try() { +- cmd=$1 +- shiftpackage/rust/0002-configure-use-default-python-interpreter.patch line 34
Quoted 10 lines
package/rust/0002-configure-use-default-python-interpreter.patch new file +10
-0+- T=$($cmd --version 2>/dev/null) +- if [ $? -eq 0 ]; then +- exec $cmd "$script" "$@" +- fi +-} +- +-try python2.7 "$@" +-try python27 "$@" +-try python2 "$@" + exec python $script "$@"Shouldn't we try to find an upstreamable solution here, such as perhaps a PYTHON environment variable, or an argument to configure that allows to specify the path to the Python interpreter ?
Quoted 2 lines
But in fact, this path to the Python interpreter is already in the config.toml file that we generate, why isn't this path used ?
humm, It seems that this configure script is not used at all by rust package since we use directly x.py...
So we can just drop this patch.
Quoted 12 lines
Quoted 12 lines
package/rust/rust.mk +0
-1@@ -17,9 +17,16 @@ HOST_RUST_DEPENDENCIES = \ host-rust-bin \ host-cargo-bin \ host-openssl \ - host-python \ $(BR2_CMAKE_HOST_DEPENDENCY)
Quoted 13 lines
package/rust/rust.mk HOST_RUST_DEPENDENCIES = \ · line 28
Quoted 7 lines
package/rust/rust.mk +7
-0+ifeq ($(BR2_PACKAGE_PYTHON3),y) +HOST_RUST_PYTHON_VERSION = $(PYTHON3_VERSION_MAJOR) +HOST_RUST_DEPENDENCIES += host-python3 +else +HOST_RUST_PYTHON_VERSION = $(PYTHON_VERSION_MAJOR) +HOST_RUST_DEPENDENCIES += host-python +endifI think we should start inverting this logic, i.e use host-python3 by default if there is no python interpreter selected for the target. We should do that not only here, but in all packages that have a logic like that: python3 should become our default, and python2 should become the exception.
Yes, with this change we can remove python3-<module> added to provide python3 modules. I hope packages that still use python2 will only require the python2 interpreter without any additional modules.
Best regards,
Romain
Quoted 5 lines
Thanks!
Thomas
Quoted 10 lines · On Fri, 29 May 2020 23:45:23 +0200 Romain Naour <[email protected]> wrote:
Quoted 6 lines
Shouldn't we try to find an upstreamable solution here, such as perhaps a PYTHON environment variable, or an argument to configure that allows to specify the path to the Python interpreter ?
But in fact, this path to the Python interpreter is already in the config.toml file that we generate, why isn't this path used ?
humm, It seems that this configure script is not used at all by rust package since we use directly
x.py...
So we can just drop this patch.
Could you send a follow-up patch ?
Quoted 14 lines
Quoted 5 lines
Quoted 5 lines
package/rust/rust.mk +5
-0+ifeq ($(BR2_PACKAGE_PYTHON3),y) +HOST_RUST_PYTHON_VERSION = $(PYTHON3_VERSION_MAJOR) +HOST_RUST_DEPENDENCIES += host-python3 +else +HOST_RUST_PYTHON_VERSION = $(PYTHON_VERSION_MAJOR)Quoted 8 lines
package/rust/rust.mk HOST_RUST_DEPENDENCIES = \ · line 28
Quoted 2 lines
package/rust/rust.mk +2
-0+HOST_RUST_DEPENDENCIES += host-python +endifI think we should start inverting this logic, i.e use host-python3 by default if there is no python interpreter selected for the target. We should do that not only here, but in all packages that have a logic like that: python3 should become our default, and python2 should become the exception.
Quoted 3 lines
Yes, with this change we can remove python3-<module> added to provide python3 modules. I hope packages that still use python2 will only require the python2 interpreter without any additional modules.
That is not what I meant. What I meant was to change:
ifeq ($(BR2_PACKAGE_PYTHON3),y) HOST_RUST_PYTHON_VERSION = $(PYTHON3_VERSION_MAJOR) HOST_RUST_DEPENDENCIES += host-python3
elseHOST_RUST_PYTHON_VERSION = $(PYTHON_VERSION_MAJOR) HOST_RUST_DEPENDENCIES += host-python
endif
to:
ifeq ($(BR2_PACKAGE_PYTHON),y) HOST_RUST_PYTHON_VERSION = $(PYTHON_VERSION_MAJOR) HOST_RUST_DEPENDENCIES += host-python
elseHOST_RUST_PYTHON_VERSION = $(PYTHON3_VERSION_MAJOR) HOST_RUST_DEPENDENCIES += host-python3 endif
i.e: our default becomes python3.
Thomas
Signature · 3 lines
Thomas Petazzoni, CTO, Bootlin Embedded Linux and Kernel engineering https://bootlin.com
Hello Thomas,
Le 31/05/2020 ? 15:10, Thomas Petazzoni a ?crit?:
Quoted 7 lines
Quoted 4 lines · On Fri, 29 May 2020 23:45:23 +0200 Romain Naour <[email protected]> wrote:
Quoted 4 lines
Shouldn't we try to find an upstreamable solution here, such as perhaps a PYTHON environment variable, or an argument to configure that allows to specify the path to the Python interpreter ?
Quoted 8 lines
Quoted 6 lines
Quoted 2 lines
But in fact, this path to the Python interpreter is already in the config.toml file that we generate, why isn't this path used ?
humm, It seems that this configure script is not used at all by rust package since we use directly
x.py...
So we can just drop this patch.Could you send a follow-up patch ?
http://patchwork.ozlabs.org/project/buildroot/patch/20200530134344.24976-1-romain.naour at gmail.com/
Quoted 39 lines
Quoted 15 lines
Quoted 14 lines
package/rust/rust.mk HOST_RUST_DEPENDENCIES = \ · line 28
Quoted 8 lines
package/rust/rust.mk +7
-0+ifeq ($(BR2_PACKAGE_PYTHON3),y) +HOST_RUST_PYTHON_VERSION = $(PYTHON3_VERSION_MAJOR) +HOST_RUST_DEPENDENCIES += host-python3 +else +HOST_RUST_PYTHON_VERSION = $(PYTHON_VERSION_MAJOR) +HOST_RUST_DEPENDENCIES += host-python +endifI think we should start inverting this logic, i.e use host-python3 by default if there is no python interpreter selected for the target. We should do that not only here, but in all packages that have a logic like that: python3 should become our default, and python2 should become the exception.
Quoted 3 lines
Yes, with this change we can remove python3-<module> added to provide python3 modules. I hope packages that still use python2 will only require the python2 interpreter without any additional modules.
That is not what I meant. What I meant was to change:
ifeq ($(BR2_PACKAGE_PYTHON3),y)
HOST_RUST_PYTHON_VERSION= $(PYTHON3_VERSION_MAJOR)HOST_RUST_DEPENDENCIES+= host-python3
elseHOST_RUST_PYTHON_VERSION= $(PYTHON_VERSION_MAJOR)HOST_RUST_DEPENDENCIES+= host-python
endifto:
ifeq ($(BR2_PACKAGE_PYTHON),y)
HOST_RUST_PYTHON_VERSION= $(PYTHON_VERSION_MAJOR)HOST_RUST_DEPENDENCIES+= host-python
elseHOST_RUST_PYTHON_VERSION= $(PYTHON3_VERSION_MAJOR)HOST_RUST_DEPENDENCIES+= host-python3 endif
Quoted 1 line
i.e: our default becomes python3.
Ok, I guess this can be done in a patch series that also use host-python3 by default for python packages.
Best regards,
Romain
Quoted 3 lines
Thomas