Openembedded Core Discussions
 help / color / mirror / Atom feed
From: Peter Kjellerstedt <peter.kjellerstedt@axis.com>
To: Tim Orling <ticotimo@gmail.com>,
	"openembedded-core@lists.openembedded.org"
	<openembedded-core@lists.openembedded.org>
Cc: Tim Orling <tim.orling@konsulko.com>
Subject: RE: [OE-core] [PATCH 2/2] pip_install_wheel: improved wheel filename guess
Date: Thu, 24 Feb 2022 13:33:01 +0000	[thread overview]
Message-ID: <4acfd09b21f445a88a60cb574c0df3d1@axis.com> (raw)
In-Reply-To: <20220224041200.2645054-2-tim.orling@konsulko.com>

> -----Original Message-----
> From: openembedded-core@lists.openembedded.org <openembedded-core@lists.openembedded.org> On Behalf Of Tim Orling
> Sent: den 24 februari 2022 05:12
> To: openembedded-core@lists.openembedded.org
> Cc: Tim Orling <tim.orling@konsulko.com>
> Subject: [OE-core] [PATCH 2/2] pip_install_wheel: improved wheel filename guess
> 
> Rather than only use PYPI_PACKAGE as a guess, fall back on PN for cases
> where a recipe does not inherit pypi.
> 
> Wheels can only have alphanumeric characters in the 'distribution'
> name [1]. Any other characters are replaced with an underscore. Provide a
> function to replace dash with underscore.
> 
> [1] https://www.python.org/dev/peps/pep-0491/#escaping-and-unicode
> 
> Signed-off-by: Tim Orling <tim.orling@konsulko.com>
> ---
>  meta/classes/pip_install_wheel.bbclass | 11 ++++++++++-
>  1 file changed, 10 insertions(+), 1 deletion(-)
> 
> diff --git a/meta/classes/pip_install_wheel.bbclass b/meta/classes/pip_install_wheel.bbclass
> index f0312e0b1eb..e0f0b97ad13 100644
> --- a/meta/classes/pip_install_wheel.bbclass
> +++ b/meta/classes/pip_install_wheel.bbclass
> @@ -1,6 +1,15 @@
>  DEPENDS:append = " python3-pip-native"
> 
> -PIP_INSTALL_PACKAGE ?= "${PYPI_PACKAGE}"
> +def guess_pip_install_package_name(d):
> +    '''https://www.python.org/dev/peps/pep-0491/#escaping-and-unicode'''
> +    package = ""
> +    if not d.getVar('PYPI_PACKAGE'):
> +         package = (d.getVar('PN').replace('-', '_'))
> +    else:
> +         package = (d.getVar('PYPI_PACKAGE').replace('-', '_'))
> +    return package

You can simplify the above to:

+def guess_pip_install_package_name(d):
+    '''https://www.python.org/dev/peps/pep-0491/#escaping-and-unicode'''
+    return (d.getVar('PYPI_PACKAGE') or d.getVar('PN')).replace('-', '_')

> +
> +PIP_INSTALL_PACKAGE ?= "${@guess_pip_install_package_name(d)}"
>  PIP_INSTALL_DIST_PATH ?= "${B}/dist"
>  PYPA_WHEEL ??= "${PIP_INSTALL_DIST_PATH}/${PIP_INSTALL_PACKAGE}-${PV}-*.whl"
> 
> --
> 2.30.2

//Peter



      reply	other threads:[~2022-02-24 13:33 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-02-24  4:11 [PATCH 1/2] setuptools3.bbclass: add check for pyproject.toml Tim Orling
2022-02-24  4:12 ` [PATCH 2/2] pip_install_wheel: improved wheel filename guess Tim Orling
2022-02-24 13:33   ` Peter Kjellerstedt [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4acfd09b21f445a88a60cb574c0df3d1@axis.com \
    --to=peter.kjellerstedt@axis.com \
    --cc=openembedded-core@lists.openembedded.org \
    --cc=ticotimo@gmail.com \
    --cc=tim.orling@konsulko.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox