Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.debian.maint.python > #14745 > unrolled thread

How do you create entry-points for Python applications?

Started byc.buhtz@posteo.jp
First post2022-12-18 20:20 +0100
Last post2022-12-19 14:40 +0100
Articles 9 — 5 participants

Back to article view | Back to linux.debian.maint.python


Contents

  How do you create entry-points for Python applications? c.buhtz@posteo.jp - 2022-12-18 20:20 +0100
    Re: How do you create entry-points for Python applications? Danial Behzadi دانیال بهزادی <dani.behzi@ubuntu.com> - 2022-12-18 23:10 +0100
      Re: How do you create entry-points for Python  applications? c.buhtz@posteo.jp - 2022-12-19 06:20 +0100
        Re: How do you create entry-points for Python applications? Scott Kitterman <debian@kitterman.com> - 2022-12-19 06:30 +0100
          Re: How do you create entry-points for Python  applications? c.buhtz@posteo.jp - 2022-12-19 07:30 +0100
            Re: How do you create entry-points for Python applications? Scott Kitterman <debian@kitterman.com> - 2022-12-19 08:00 +0100
              Re: How do you create entry-points for Python applications? Danial Behzadi دانیال بهزادی <dani.behzi@ubuntu.com> - 2022-12-19 14:10 +0100
                Re: How do you create entry-points for Python applications? Stuart Prescott <stuart@debian.org> - 2022-12-20 01:10 +0100
    Re: How do you create entry-points for Python applications? Andrey Rahmatullin <wrar@debian.org> - 2022-12-19 14:40 +0100

#14745 — How do you create entry-points for Python applications?

Fromc.buhtz@posteo.jp
Date2022-12-18 20:20 +0100
SubjectHow do you create entry-points for Python applications?
Message-ID<FE7mx-byMF-7@gated-at.bofh.it>
Hello,
a python application isn't a binary but a script. So to invoke such an 
application there need to be a shell script somewhere in PATH that 
invoke that script via python3 interpreter. Imagine an application with 
a GUI (qt, tikinter, gtk, ...).

On the upstream site modern python projects using pyproject.toml (only), 
some use setup.cfg.
There you can define "entry points" and the "pip" installer does 
generate a shell script based on that information and place it in PATH.
That is a nice mechanism when installing via pip.

On your site as distro maintainers. How do you take care of then when 
creating deb files?
When a project do follow modern python packaging standards using 
pyproject.toml/setup.cfg and doesn't offer any other explict start shell 
script. Do you use that pip mechanic for the deb package?
Or how do you create your shell scripts?

I don't have an real world example of a python application for that.

I only have an example of a project (backintime) that don't use 
pyproject.toml/setup.cfg and offer its own shell script. I'm part of the 
new maintainer team and we will evolve the project to current python 
packaging standards; which means using pyproject.toml.

[toc] | [next] | [standalone]


#14746

FromDanial Behzadi دانیال بهزادی <dani.behzi@ubuntu.com>
Date2022-12-18 23:10 +0100
Message-ID<FEa14-bAw0-9@gated-at.bofh.it>
In reply to#14745

[Multipart message — attachments visible in raw view] — view raw

AFAIK Debian helper for Python handles this

در 18 دسامبر 2022 19:18:44 (UTC)، c.buhtz@posteo.jp نوشت:
>Hello,
>a python application isn't a binary but a script. So to invoke such an application there need to be a shell script somewhere in PATH that invoke that script via python3 interpreter. Imagine an application with a GUI (qt, tikinter, gtk, ...).
>
>On the upstream site modern python projects using pyproject.toml (only), some use setup.cfg.
>There you can define "entry points" and the "pip" installer does generate a shell script based on that information and place it in PATH.
>That is a nice mechanism when installing via pip.
>
>On your site as distro maintainers. How do you take care of then when creating deb files?
>When a project do follow modern python packaging standards using pyproject.toml/setup.cfg and doesn't offer any other explict start shell script. Do you use that pip mechanic for the deb package?
>Or how do you create your shell scripts?
>
>I don't have an real world example of a python application for that.
>
>I only have an example of a project (backintime) that don't use pyproject.toml/setup.cfg and offer its own shell script. I'm part of the new maintainer team and we will evolve the project to current python packaging standards; which means using pyproject.toml.
>

[toc] | [prev] | [next] | [standalone]


#14747 — Re: How do you create entry-points for Python applications?

Fromc.buhtz@posteo.jp
Date2022-12-19 06:20 +0100
SubjectRe: How do you create entry-points for Python applications?
Message-ID<FEgJb-bEro-1@gated-at.bofh.it>
In reply to#14746
Am 18.12.2022 23:03 schrieb Danial Behzadi دانیال بهزادی:
> AFAIK Debian helper for Python handles this

;) Yes, but how?

Does it ignore the pip-default-entry-point-scripts? Does it create its 
own script?
Do you have to explicit write a script?

[toc] | [prev] | [next] | [standalone]


#14748

FromScott Kitterman <debian@kitterman.com>
Date2022-12-19 06:30 +0100
Message-ID<FEgSR-bEzJ-5@gated-at.bofh.it>
In reply to#14747

On December 19, 2022 5:13:27 AM UTC, c.buhtz@posteo.jp wrote:
>Am 18.12.2022 23:03 schrieb Danial Behzadi دانیال بهزادی:
>> AFAIK Debian helper for Python handles this
>
>;) Yes, but how?
>
>Does it ignore the pip-default-entry-point-scripts? Does it create its own script?
>Do you have to explicit write a script?

You don't.  Pybuild using the pyproject plugin will build a wheel and then install the necessary files in the package using the installer module.  The entry point scripts are in the wheel, just like an upstream built wheel.

Your best bet is to find a package in the archive that's similar and see how it was done.

Scott K

[toc] | [prev] | [next] | [standalone]


#14749 — Re: How do you create entry-points for Python applications?

Fromc.buhtz@posteo.jp
Date2022-12-19 07:30 +0100
SubjectRe: How do you create entry-points for Python applications?
Message-ID<FEhOV-bF8f-1@gated-at.bofh.it>
In reply to#14748
Dear Scott,

thanks for the reply.

Am 19.12.2022 06:25 schrieb Scott Kitterman:
> Pybuild using the pyproject plugin will build a wheel and
> then install the necessary files in the package using the installer
> module.  The entry point scripts are in the wheel, just like an
> upstream built wheel.

Do I get that correct?
The entry scripts (their content and their location) is the same 
installing a package via pip and apt?

In that case I'm right trying to make the "pip install" process as 
correct as possible to save resources for the distro maintainers.

> Your best bet is to find a package in the archive that's similar and
> see how it was done.

That is why I'm asking here. ;)

[toc] | [prev] | [next] | [standalone]


#14750

FromScott Kitterman <debian@kitterman.com>
Date2022-12-19 08:00 +0100
Message-ID<FEihX-bFhP-1@gated-at.bofh.it>
In reply to#14749

On December 19, 2022 6:27:55 AM UTC, c.buhtz@posteo.jp wrote:
>Dear Scott,
>
>thanks for the reply.
>
>Am 19.12.2022 06:25 schrieb Scott Kitterman:
>> Pybuild using the pyproject plugin will build a wheel and
>> then install the necessary files in the package using the installer
>> module.  The entry point scripts are in the wheel, just like an
>> upstream built wheel.
>
>Do I get that correct?
>The entry scripts (their content and their location) is the same installing a package via pip and apt?
>
>In that case I'm right trying to make the "pip install" process as correct as possible to save resources for the distro maintainers.

There are exceptions, but generally that is correct.

>> Your best bet is to find a package in the archive that's similar and
>> see how it was done.
>
>That is why I'm asking here. ;)

Hopefully someone will chime in with a good example.  The only package I maintain that I can think of at the moment with entrypoints and project.toml is too complicated to be a good example.

Scott K

[toc] | [prev] | [next] | [standalone]


#14752

FromDanial Behzadi دانیال بهزادی <dani.behzi@ubuntu.com>
Date2022-12-19 14:10 +0100
Message-ID<FEo41-bIWk-5@gated-at.bofh.it>
In reply to#14750

[Multipart message — attachments visible in raw view] — view raw

> The only package I maintain that I can think of at the moment with entrypoints and project.toml is too complicated to be a good example.

That shouldn't be so much different from setup.py projects and there are plenty of them in archive.

[toc] | [prev] | [next] | [standalone]


#14759

FromStuart Prescott <stuart@debian.org>
Date2022-12-20 01:10 +0100
Message-ID<FEymJ-bPjW-11@gated-at.bofh.it>
In reply to#14752

On 20/12/2022 00:09, Danial Behzadi دانیال بهزادی wrote:
>  > The only package I maintain that I can think of at the moment with 
> entrypoints and project.toml is too complicated to be a good example.
> 
> That shouldn't be so much different from setup.py projects and there are 
> plenty of them in archive.

In general, the Debian tooling installs the package and so the upstream 
build system should generate the entry points scripts no matter which 
approach is used.

There are some differences to be aware of:

If the pybuild 'distutils' plugin is used (i.e. with a setup.py 
project), then the entry points will be created at the "install" step 
and should land in debian/*/usr/bin; you may need to move them into the 
right binary package.

If the pybuild 'pyproject' plugin is used (i.e. with a pyproject.toml 
project), then the entry points will be created in the "build" step. 
They will land in the pybuild {home_dir}/scripts directory and be 
available to the "test" target in PATH for any cli tests that are in the 
test suite. They will get copied into debian/*/usr/bin during the 
"install" step and you may need to move them into the right binary package.

The main things that the packager needs to be aware of are:

* the packaging needs to move the entry points scripts into the correct 
binary package; that might be a debian/package.install file or it might 
be a mv in debian/rules.

* make sure there's a tight enough dependency between the package that 
contains the entry points scripts and the package that contains the 
modules; the entry points scripts include exact versioning on the 
upstream version of the module and if the binary packages don't have 
dependencies that enforce that requirement, the entry points script can 
fail at run time for the user. («python3-foo (= ${binary:Version})» 
should be ok for packages that are only arch:all).

cheers
Stuart

-- 
Stuart Prescott   http://www.nanonanonano.net/ stuart@nanonanonano.net
Debian Developer  http://www.debian.org/       stuart@debian.org
GPG fingerprint   90E2 D2C1 AD14 6A1B 7EBB 891D BBC1 7EBB 1396 F2F7

[toc] | [prev] | [next] | [standalone]


#14753

FromAndrey Rahmatullin <wrar@debian.org>
Date2022-12-19 14:40 +0100
Message-ID<FEox3-bJ67-3@gated-at.bofh.it>
In reply to#14745

[Multipart message — attachments visible in raw view] — view raw

On Sun, Dec 18, 2022 at 07:18:44PM +0000, c.buhtz@posteo.jp wrote:
> Hello,
> a python application isn't a binary but a script. So to invoke such an
> application there need to be a shell script somewhere in PATH that invoke
> that script via python3 interpreter. Imagine an application with a GUI (qt,
> tikinter, gtk, ...).
> 
> On the upstream site modern python projects using pyproject.toml (only),
> some use setup.cfg.
> There you can define "entry points" and the "pip" installer does generate a
> shell script based on that information and place it in PATH.
> That is a nice mechanism when installing via pip.
> 
> On your site as distro maintainers. How do you take care of then when
> creating deb files?
I feel like this question is not really specific to pyproject.toml etc.:
entry points are an old concept and we have a lot of packages shipping
setuptools entry points (grep your /usr/bin for "load_entry_point").
For these packages the executable is indeed created automatically by the
packaging tools, and I would expect the same to happen for any other
supported setuptools replacement.

-- 
WBR, wRAR

[toc] | [prev] | [standalone]


Back to top | Article view | linux.debian.maint.python


csiph-web