* [gentoo-python] [PATCH] Introduce python_newscript().
@ 2013-02-02 1:46 Michał Górny
2013-02-02 1:56 ` [gentoo-python] " Mike Gilbert
0 siblings, 1 reply; 4+ messages in thread
From: Michał Górny @ 2013-02-02 1:46 UTC (permalink / raw
To: gentoo-python; +Cc: python, jlec, Michał Górny
Requested by jlec, I think.
---
gx86/eclass/python-utils-r1.eclass | 47 ++++++++++++++++++++++++++++++--------
1 file changed, 37 insertions(+), 10 deletions(-)
diff --git a/gx86/eclass/python-utils-r1.eclass b/gx86/eclass/python-utils-r1.eclass
index b425302..c5a1f6e 100644
--- a/gx86/eclass/python-utils-r1.eclass
+++ b/gx86/eclass/python-utils-r1.eclass
@@ -521,7 +521,34 @@ python_scriptinto() {
python_doscript() {
debug-print-function ${FUNCNAME} "${@}"
+ local f
+ for f; do
+ python_newscript "${f}" "${f}"
+ done
+}
+
+# @FUNCTION: python_newscript
+# @USAGE: <path> <new-name>
+# @DESCRIPTION:
+# Install the given script into current python_scriptroot
+# for the current Python implementation (${EPYTHON}), and name it
+# <new-name>.
+#
+# The file must start with a 'python' shebang. The shebang will be
+# converted, the file will be renamed to be EPYTHON-suffixed
+# and a wrapper will be installed in place of the <new-name>.
+#
+# Example:
+# @CODE
+# src_install() {
+# python_foreach_impl python_newscript foo.py foo
+# }
+# @CODE
+python_newscript() {
+ debug-print-function ${FUNCNAME} "${@}"
+
[[ ${EPYTHON} ]] || die 'No Python implementation set (EPYTHON is null).'
+ [[ ${#} -eq 2 ]] || die "Usage: ${FUNCNAME} <path> <new-name>"
local d=${python_scriptroot:-${DESTTREE}/bin}
local INSDESTTREE INSOPTIONS
@@ -529,18 +556,18 @@ python_doscript() {
insinto "${d}"
insopts -m755
- local f
- for f; do
- local oldfn=${f##*/}
- local newfn=${oldfn}-${EPYTHON}
+ local f=${1}
+ local barefn=${2}
- debug-print "${FUNCNAME}: ${oldfn} -> ${newfn}"
- newins "${f}" "${newfn}" || die
- _python_rewrite_shebang "${ED}/${d}/${newfn}"
+ local oldfn=${f##*/}
+ local newfn=${barefn}-${EPYTHON}
- # install the wrapper
- _python_ln_rel "${ED}"/usr/bin/python-exec "${ED}/${d}/${oldfn}" || die
- done
+ debug-print "${FUNCNAME}: ${oldfn} -> ${newfn}"
+ newins "${f}" "${newfn}" || die
+ _python_rewrite_shebang "${ED}/${d}/${newfn}"
+
+ # install the wrapper
+ _python_ln_rel "${ED}"/usr/bin/python-exec "${ED}/${d}/${barefn}" || die
}
# @ECLASS-VARIABLE: python_moduleroot
--
1.8.1.2
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [gentoo-python] Re: [PATCH] Introduce python_newscript().
2013-02-02 1:46 [gentoo-python] [PATCH] Introduce python_newscript() Michał Górny
@ 2013-02-02 1:56 ` Mike Gilbert
2013-02-02 9:58 ` Michał Górny
0 siblings, 1 reply; 4+ messages in thread
From: Mike Gilbert @ 2013-02-02 1:56 UTC (permalink / raw
To: Michał Górny; +Cc: gentoo-python, python, jlec
On Fri, Feb 1, 2013 at 8:46 PM, Michał Górny <mgorny@gentoo.org> wrote:
> Requested by jlec, I think.
> ---
> gx86/eclass/python-utils-r1.eclass | 47 ++++++++++++++++++++++++++++++--------
> 1 file changed, 37 insertions(+), 10 deletions(-)
>
> diff --git a/gx86/eclass/python-utils-r1.eclass b/gx86/eclass/python-utils-r1.eclass
> index b425302..c5a1f6e 100644
> --- a/gx86/eclass/python-utils-r1.eclass
> +++ b/gx86/eclass/python-utils-r1.eclass
> @@ -521,7 +521,34 @@ python_scriptinto() {
> python_doscript() {
> debug-print-function ${FUNCNAME} "${@}"
>
> + local f
> + for f; do
> + python_newscript "${f}" "${f}"
> + done
> +}
Won't this break on something like "python_doscript path/to/script"?
That would result in this call:
python_newscript path/to/script path/to/script
If I'm reading python_newscript correctly, $2 should not have any path
information.
> +
> +# @FUNCTION: python_newscript
> +# @USAGE: <path> <new-name>
> +# @DESCRIPTION:
> +# Install the given script into current python_scriptroot
> +# for the current Python implementation (${EPYTHON}), and name it
> +# <new-name>.
> +#
> +# The file must start with a 'python' shebang. The shebang will be
> +# converted, the file will be renamed to be EPYTHON-suffixed
> +# and a wrapper will be installed in place of the <new-name>.
> +#
> +# Example:
> +# @CODE
> +# src_install() {
> +# python_foreach_impl python_newscript foo.py foo
> +# }
> +# @CODE
> +python_newscript() {
> + debug-print-function ${FUNCNAME} "${@}"
> +
> [[ ${EPYTHON} ]] || die 'No Python implementation set (EPYTHON is null).'
> + [[ ${#} -eq 2 ]] || die "Usage: ${FUNCNAME} <path> <new-name>"
>
> local d=${python_scriptroot:-${DESTTREE}/bin}
> local INSDESTTREE INSOPTIONS
> @@ -529,18 +556,18 @@ python_doscript() {
> insinto "${d}"
> insopts -m755
>
> - local f
> - for f; do
> - local oldfn=${f##*/}
> - local newfn=${oldfn}-${EPYTHON}
> + local f=${1}
> + local barefn=${2}
>
> - debug-print "${FUNCNAME}: ${oldfn} -> ${newfn}"
> - newins "${f}" "${newfn}" || die
> - _python_rewrite_shebang "${ED}/${d}/${newfn}"
> + local oldfn=${f##*/}
> + local newfn=${barefn}-${EPYTHON}
>
> - # install the wrapper
> - _python_ln_rel "${ED}"/usr/bin/python-exec "${ED}/${d}/${oldfn}" || die
> - done
> + debug-print "${FUNCNAME}: ${oldfn} -> ${newfn}"
> + newins "${f}" "${newfn}" || die
> + _python_rewrite_shebang "${ED}/${d}/${newfn}"
> +
> + # install the wrapper
> + _python_ln_rel "${ED}"/usr/bin/python-exec "${ED}/${d}/${barefn}" || die
> }
>
> # @ECLASS-VARIABLE: python_moduleroot
> --
> 1.8.1.2
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [gentoo-python] Re: [PATCH] Introduce python_newscript().
2013-02-02 1:56 ` [gentoo-python] " Mike Gilbert
@ 2013-02-02 9:58 ` Michał Górny
2013-02-02 15:32 ` Mike Gilbert
0 siblings, 1 reply; 4+ messages in thread
From: Michał Górny @ 2013-02-02 9:58 UTC (permalink / raw
To: Mike Gilbert; +Cc: gentoo-python, python, jlec
[-- Attachment #1: Type: text/plain, Size: 1275 bytes --]
On Fri, 1 Feb 2013 20:56:36 -0500
Mike Gilbert <floppym@gentoo.org> wrote:
> On Fri, Feb 1, 2013 at 8:46 PM, Michał Górny <mgorny@gentoo.org> wrote:
> > Requested by jlec, I think.
> > ---
> > gx86/eclass/python-utils-r1.eclass | 47 ++++++++++++++++++++++++++++++--------
> > 1 file changed, 37 insertions(+), 10 deletions(-)
> >
> > diff --git a/gx86/eclass/python-utils-r1.eclass b/gx86/eclass/python-utils-r1.eclass
> > index b425302..c5a1f6e 100644
> > --- a/gx86/eclass/python-utils-r1.eclass
> > +++ b/gx86/eclass/python-utils-r1.eclass
> > @@ -521,7 +521,34 @@ python_scriptinto() {
> > python_doscript() {
> > debug-print-function ${FUNCNAME} "${@}"
> >
> > + local f
> > + for f; do
> > + python_newscript "${f}" "${f}"
> > + done
> > +}
>
>
> Won't this break on something like "python_doscript path/to/script"?
> That would result in this call:
>
> python_newscript path/to/script path/to/script
>
> If I'm reading python_newscript correctly, $2 should not have any path
> information.
Correct, thanks. It's now:
python_newscript "${f}" "${f##*/}"
I've also removed 'oldfn' from python_newscript() which is practically
unused.
--
Best regards,
Michał Górny
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 316 bytes --]
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [gentoo-python] Re: [PATCH] Introduce python_newscript().
2013-02-02 9:58 ` Michał Górny
@ 2013-02-02 15:32 ` Mike Gilbert
0 siblings, 0 replies; 4+ messages in thread
From: Mike Gilbert @ 2013-02-02 15:32 UTC (permalink / raw
To: Michał Górny; +Cc: gentoo-python, python, jlec
On Sat, Feb 2, 2013 at 4:58 AM, Michał Górny <mgorny@gentoo.org> wrote:
> On Fri, 1 Feb 2013 20:56:36 -0500
> Mike Gilbert <floppym@gentoo.org> wrote:
>
>> On Fri, Feb 1, 2013 at 8:46 PM, Michał Górny <mgorny@gentoo.org> wrote:
>> > Requested by jlec, I think.
>> > ---
>> > gx86/eclass/python-utils-r1.eclass | 47 ++++++++++++++++++++++++++++++--------
>> > 1 file changed, 37 insertions(+), 10 deletions(-)
>> >
>> > diff --git a/gx86/eclass/python-utils-r1.eclass b/gx86/eclass/python-utils-r1.eclass
>> > index b425302..c5a1f6e 100644
>> > --- a/gx86/eclass/python-utils-r1.eclass
>> > +++ b/gx86/eclass/python-utils-r1.eclass
>> > @@ -521,7 +521,34 @@ python_scriptinto() {
>> > python_doscript() {
>> > debug-print-function ${FUNCNAME} "${@}"
>> >
>> > + local f
>> > + for f; do
>> > + python_newscript "${f}" "${f}"
>> > + done
>> > +}
>>
>>
>> Won't this break on something like "python_doscript path/to/script"?
>> That would result in this call:
>>
>> python_newscript path/to/script path/to/script
>>
>> If I'm reading python_newscript correctly, $2 should not have any path
>> information.
>
> Correct, thanks. It's now:
>
> python_newscript "${f}" "${f##*/}"
>
> I've also removed 'oldfn' from python_newscript() which is practically
> unused.
>
Ok. +1 from me then.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2013-02-02 15:32 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-02-02 1:46 [gentoo-python] [PATCH] Introduce python_newscript() Michał Górny
2013-02-02 1:56 ` [gentoo-python] " Mike Gilbert
2013-02-02 9:58 ` Michał Górny
2013-02-02 15:32 ` Mike Gilbert
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox