diff mbox

python-ranger: new package

Message ID 1445367699-13964-1-git-send-email-thijsvermeir@gmail.com
State Changes Requested
Headers show

Commit Message

Thijs Vermeir Oct. 20, 2015, 7:01 p.m. UTC
ranger is a console file manager with VI key bindings. It provides a
minimalistic and nice curses interface with a view on the directory hierarchy.
It ships with "rifle", a file launcher that is good at automatically finding
out which program to use for what file type.

http://ranger.nongnu.org
---
 package/Config.in                                 |  1 +
 package/python-ranger/0001-colorschemes-pyc.patch | 13 +++++++++++++
 package/python-ranger/Config.in                   | 13 +++++++++++++
 package/python-ranger/python-ranger.mk            | 21 +++++++++++++++++++++
 4 files changed, 48 insertions(+)
 create mode 100644 package/python-ranger/0001-colorschemes-pyc.patch
 create mode 100644 package/python-ranger/Config.in
 create mode 100644 package/python-ranger/python-ranger.mk

Comments

Peter Korsgaard Oct. 20, 2015, 7:40 p.m. UTC | #1
>>>>> "Thijs" == Thijs Vermeir <thijsvermeir@gmail.com> writes:

Hi,

 > ranger is a console file manager with VI key bindings. It provides a
 > minimalistic and nice curses interface with a view on the directory hierarchy.
 > It ships with "rifle", a file launcher that is good at automatically finding
 > out which program to use for what file type.

 > http://ranger.nongnu.org

Please add your signed-off-by tag to the patch (git commit -s), thanks.

> diff --git a/package/python-ranger/0001-colorschemes-pyc.patch b/package/python-ranger/0001-colorschemes-pyc.patch
 > new file mode 100644
 > index 0000000..6752cb4
 > --- /dev/null
 > +++ b/package/python-ranger/0001-colorschemes-pyc.patch

And a description + signed-off-by for the patch. Have you tried
submitting it upstream? If so, was it accepted?

> @@ -0,0 +1,13 @@
 > +Index: python-ranger-1.7.2/ranger/gui/colorscheme.py
 > +===================================================================
 > +--- python-ranger-1.7.2.orig/ranger/gui/colorscheme.py
 > ++++ python-ranger-1.7.2/ranger/gui/colorscheme.py
 > +@@ -86,7 +86,7 @@ def _colorscheme_name_to_class(signal):
 > +     usecustom = not ranger.arg.clean
 > + 
 > +     def exists(colorscheme):
 > +-        return os.path.exists(colorscheme + '.py')
 > ++        return os.path.exists(colorscheme + '.py') or os.path.exists(colorscheme + '.pyc')
 > + 
 > +     def is_scheme(x):
 > +         try:
 > diff --git a/package/python-ranger/Config.in b/package/python-ranger/Config.in
 > new file mode 100644
 > index 0000000..4ded82e
 > --- /dev/null
 > +++ b/package/python-ranger/Config.in
 > @@ -0,0 +1,13 @@
 > +config BR2_PACKAGE_PYTHON_RANGER
 > +	bool "python-ranger"
 > +	depends on BR2_PACKAGE_PYTHON3_CURSES || BR2_PACKAGE_PYTHON_CURSES

We normally use select for library dependencies, so you can do
   select BR2_PACKAGE_PYTHON_CURSES if BR2_PACKAGE_PYTHON
   select BR2_PACKAGE_PYTHON3_CURSES if BR2_PACKAGE_PYTHON3

> +	help
 > +	  ranger is a console file manager with VI key bindings. It provides a
 > +	  minimalistic and nice curses interface with a view on the directory hierarchy.
 > +	  It ships with "rifle", a file launcher that is good at automatically finding
 > +	  out which program to use for what file type.
 > +
 > +	  http://ranger.nongnu.org
 > +
 > +comment "python-ranger needs the curses python or python3 library"
 > +	depends on !BR2_PACKAGE_PYTHON3_CURSES && !BR2_PACKAGE_PYTHON_CURSES

And drop this comment.

> diff --git a/package/python-ranger/python-ranger.mk b/package/python-ranger/python-ranger.mk
 > new file mode 100644
 > index 0000000..7272fbb
 > --- /dev/null
 > +++ b/package/python-ranger/python-ranger.mk
 > @@ -0,0 +1,21 @@
 > +################################################################################
 > +#
 > +# python-ranger
 > +#
 > +################################################################################
 > +
 > +PYTHON_RANGER_VERSION = 1.7.2
 > +PYTHON_RANGER_SITE = $(call github,hut,ranger,v$(PYTHON_RANGER_VERSION))
 > +PYTHON_RANGER_SETUP_TYPE = distutils
 > +PYTHON_RANGER_LICENSE = GPLv3

Is there no license file in the tarball?

We recently started adding hashes for the packages on github as
well. Please add a (locally calculated) sha256 in python-ranger.hash

> +
 > +define PYTHON_RANGER_DO_NOT_GENERATE_BYTECODE_AT_RUNTIME
 > +	$(SED) 's%/usr/bin/python -O%/usr/bin/python%g' $(@D)/scripts/ranger
 > +endef

Please add a comment explaining why this is done.

 > +
 > +ifeq ($(BR2_PACKAGE_PYTHON3_PYC_ONLY)$(BR2_PACKAGE_PYTHON_PYC_ONLY),y)
 > +PYTHON_RANGER_POST_PATCH_HOOKS += PYTHON_RANGER_DO_NOT_GENERATE_BYTECODE_AT_RUNTIME
 > +endif
 > +
 > +$(eval $(python-package))
 > +$(eval $(host-python-package))

Is there anything needing this on the host?
Thomas Petazzoni Oct. 21, 2015, 11:48 a.m. UTC | #2
Hello,

On Tue, 20 Oct 2015 21:01:39 +0200, Thijs Vermeir wrote:
> ranger is a console file manager with VI key bindings. It provides a
> minimalistic and nice curses interface with a view on the directory hierarchy.
> It ships with "rifle", a file launcher that is good at automatically finding
> out which program to use for what file type.
> 
> http://ranger.nongnu.org

Thanks for your contribution! Others have already reviewed your patch
in details, but I have one question (not really for you, but mainly for
the other core Buildroot developers).


> diff --git a/package/Config.in b/package/Config.in
> index 7392363..578ba1b 100644
> --- a/package/Config.in
> +++ b/package/Config.in
> @@ -659,6 +659,7 @@ menu "External python modules"
>  	source "package/python-pyxml/Config.in"
>  	source "package/python-pyyaml/Config.in"
>  	source "package/python-pyzmq/Config.in"
> +	source "package/python-ranger/Config.in"
>  	source "package/python-requests/Config.in"
>  	source "package/python-rtslib-fb/Config.in"
>  	source "package/python-serial/Config.in"

This menu is normally for "External python modules" (as its prompt
says). However here, python-ranger is not really a python module, it's
a regular application that ends up being implemented in Python (but
it's kind of an implementation detail).

So I would rather see it visible in "System tools" or "Shell and
utilities", and named just 'ranger' (which is the upstream name for the
project.

Peter ?

Thomas
Peter Korsgaard Oct. 21, 2015, 11:56 a.m. UTC | #3
>>>>> "Thomas" == Thomas Petazzoni <thomas.petazzoni@free-electrons.com> writes:

Hi,

>> source "package/python-serial/Config.in"

 > This menu is normally for "External python modules" (as its prompt
 > says). However here, python-ranger is not really a python module, it's
 > a regular application that ends up being implemented in Python (but
 > it's kind of an implementation detail).

 > So I would rather see it visible in "System tools" or "Shell and
 > utilities", and named just 'ranger' (which is the upstream name for the
 > project.

 > Peter ?

Indeed, I was thinking the same. Question is if we want to forcible
select python / python3 (and if so, which one?) or if it should depend
on them.

It should probably also be simply called ranger instead.

I personally think it should use select and default to python3 if python
isn't enabled - E.G. something like:

config BR2_PACKAGE_RANGER
       bool "ranger"
       depends on BR2_USE_WCHAR # python
       depends on BR2_USE_MMU # python
       depends on BR2_TOOLCHAIN_HAS_THREADS # python
       depends on !BR2_STATIC_LIBS # python
       select BR2_PACKAGE_PYTHON3 if !BR2_PACKAGE_PYTHON
       select BR2_PACKAGE_PYTHON_CURSES if BR2_PACKAGE_PYTHON
       select BR2_PACKAGE_PYTHON3_CURSES if BR2_PACKAGE_PYTHON3

(Untested, I don't know if kconfig gets confused here).
Thomas Petazzoni Oct. 21, 2015, 12:13 p.m. UTC | #4
Hello,

On Wed, 21 Oct 2015 13:56:42 +0200, Peter Korsgaard wrote:
> >>>>> "Thomas" == Thomas Petazzoni <thomas.petazzoni@free-electrons.com> writes:
> 
> Hi,
> 
> >> source "package/python-serial/Config.in"
> 
>  > This menu is normally for "External python modules" (as its prompt
>  > says). However here, python-ranger is not really a python module, it's
>  > a regular application that ends up being implemented in Python (but
>  > it's kind of an implementation detail).
> 
>  > So I would rather see it visible in "System tools" or "Shell and
>  > utilities", and named just 'ranger' (which is the upstream name for the
>  > project.
> 
>  > Peter ?
> 
> Indeed, I was thinking the same. Question is if we want to forcible
> select python / python3 (and if so, which one?) or if it should depend
> on them.

Good that we agree :)

> It should probably also be simply called ranger instead.

See what I wrote :-)

> I personally think it should use select and default to python3 if python
> isn't enabled - E.G. something like:
> 
> config BR2_PACKAGE_RANGER
>        bool "ranger"
>        depends on BR2_USE_WCHAR # python
>        depends on BR2_USE_MMU # python
>        depends on BR2_TOOLCHAIN_HAS_THREADS # python
>        depends on !BR2_STATIC_LIBS # python

Change all those comments to "# python3"

>        select BR2_PACKAGE_PYTHON3 if !BR2_PACKAGE_PYTHON
>        select BR2_PACKAGE_PYTHON_CURSES if BR2_PACKAGE_PYTHON
>        select BR2_PACKAGE_PYTHON3_CURSES if BR2_PACKAGE_PYTHON3

But other than that, looks sane to me.

Or alternatively, if we don't want to hide to the user that this tool
is going to bring Python into the build, we could:

config BR2_PACKAGE_RANGER
	bool "ranger
	depends on BR2_PACKAGE_PYTHON || BR2_PACKAGE_PYTHON3
        select BR2_PACKAGE_PYTHON_CURSES if BR2_PACKAGE_PYTHON
        select BR2_PACKAGE_PYTHON3_CURSES if BR2_PACKAGE_PYTHON3

comment "ranger needs Python"
	depends on !BR2_PACKAGE_PYTHON && !BR2_PACKAGE_PYTHON3

It also removes the need for propagating the toolchain dependencies of
Python.

Thomas
Peter Korsgaard Oct. 21, 2015, 12:22 p.m. UTC | #5
>>>>> "Thomas" == Thomas Petazzoni <thomas.petazzoni@free-electrons.com> writes:

Hi,

 >> Indeed, I was thinking the same. Question is if we want to forcible
 >> select python / python3 (and if so, which one?) or if it should depend
 >> on them.

 > Good that we agree :)

Yeah ;)

 > Or alternatively, if we don't want to hide to the user that this tool
 > is going to bring Python into the build, we could:

We already do so for E.G. dstat, so unless kconfig gets confused about
the conditional selects I think we should go for it.
diff mbox

Patch

diff --git a/package/Config.in b/package/Config.in
index 7392363..578ba1b 100644
--- a/package/Config.in
+++ b/package/Config.in
@@ -659,6 +659,7 @@  menu "External python modules"
 	source "package/python-pyxml/Config.in"
 	source "package/python-pyyaml/Config.in"
 	source "package/python-pyzmq/Config.in"
+	source "package/python-ranger/Config.in"
 	source "package/python-requests/Config.in"
 	source "package/python-rtslib-fb/Config.in"
 	source "package/python-serial/Config.in"
diff --git a/package/python-ranger/0001-colorschemes-pyc.patch b/package/python-ranger/0001-colorschemes-pyc.patch
new file mode 100644
index 0000000..6752cb4
--- /dev/null
+++ b/package/python-ranger/0001-colorschemes-pyc.patch
@@ -0,0 +1,13 @@ 
+Index: python-ranger-1.7.2/ranger/gui/colorscheme.py
+===================================================================
+--- python-ranger-1.7.2.orig/ranger/gui/colorscheme.py
++++ python-ranger-1.7.2/ranger/gui/colorscheme.py
+@@ -86,7 +86,7 @@ def _colorscheme_name_to_class(signal):
+     usecustom = not ranger.arg.clean
+ 
+     def exists(colorscheme):
+-        return os.path.exists(colorscheme + '.py')
++        return os.path.exists(colorscheme + '.py') or os.path.exists(colorscheme + '.pyc')
+ 
+     def is_scheme(x):
+         try:
diff --git a/package/python-ranger/Config.in b/package/python-ranger/Config.in
new file mode 100644
index 0000000..4ded82e
--- /dev/null
+++ b/package/python-ranger/Config.in
@@ -0,0 +1,13 @@ 
+config BR2_PACKAGE_PYTHON_RANGER
+	bool "python-ranger"
+	depends on BR2_PACKAGE_PYTHON3_CURSES || BR2_PACKAGE_PYTHON_CURSES
+	help
+	  ranger is a console file manager with VI key bindings. It provides a
+	  minimalistic and nice curses interface with a view on the directory hierarchy.
+	  It ships with "rifle", a file launcher that is good at automatically finding
+	  out which program to use for what file type.
+
+	  http://ranger.nongnu.org
+
+comment "python-ranger needs the curses python or python3 library"
+	depends on !BR2_PACKAGE_PYTHON3_CURSES && !BR2_PACKAGE_PYTHON_CURSES
diff --git a/package/python-ranger/python-ranger.mk b/package/python-ranger/python-ranger.mk
new file mode 100644
index 0000000..7272fbb
--- /dev/null
+++ b/package/python-ranger/python-ranger.mk
@@ -0,0 +1,21 @@ 
+################################################################################
+#
+# python-ranger
+#
+################################################################################
+
+PYTHON_RANGER_VERSION = 1.7.2
+PYTHON_RANGER_SITE = $(call github,hut,ranger,v$(PYTHON_RANGER_VERSION))
+PYTHON_RANGER_SETUP_TYPE = distutils
+PYTHON_RANGER_LICENSE = GPLv3
+
+define PYTHON_RANGER_DO_NOT_GENERATE_BYTECODE_AT_RUNTIME
+	$(SED) 's%/usr/bin/python -O%/usr/bin/python%g' $(@D)/scripts/ranger
+endef
+
+ifeq ($(BR2_PACKAGE_PYTHON3_PYC_ONLY)$(BR2_PACKAGE_PYTHON_PYC_ONLY),y)
+PYTHON_RANGER_POST_PATCH_HOOKS += PYTHON_RANGER_DO_NOT_GENERATE_BYTECODE_AT_RUNTIME
+endif
+
+$(eval $(python-package))
+$(eval $(host-python-package))