Path: csiph.com!goblin3!goblin1!goblin.stu.neva.ru!newsfeed.CARNet.hr!news.spin.it!bofh.it!news.nic.it!robomod From: Robert Collins Newsgroups: linux.debian.maint.python Subject: Re: Application libraries private, Distutils metadata available for console scripts and introspection Date: Tue, 01 Sep 2015 06:50:02 +0200 Message-ID: References: X-Original-To: Ben Finney X-Mailbox-Line: From debian-python-request@lists.debian.org Tue Sep 1 04:42:50 2015 Old-Return-Path: X-Amavis-Spam-Status: No, score=-4.85 tagged_above=-10000 required=5.3 tests=[BAYES_00=-2, FOURLA=0.1, HTML_MESSAGE=2, LDO_WHITELIST=-5, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, RCVD_IN_SORBS_WEB=0.77] autolearn=no autolearn_force=no X-Policyd-Weight: DYN_NJABL=SKIP(0) NOT_IN_SBL_XBL_SPAMHAUS=-1.5 NOT_IN_BL_NJABL=-1.5 CL_IP_EQ_HELO_IP=-2 (check from: .robertcollins. - helo: .mail-ob0-f181.google. - helo-domain: .google.) FROM/MX_MATCHES_HELO(DOMAIN)=-2; rate: -7 X-Google-Dkim-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:date :message-id:subject:from:to:cc:content-type; bh=JmrpgEM/tcUvRetdJNAXpaSbEFEiJub+TY6yZKIKHcM=; b=fuMrJyqNdsfIpU6TyigM/sjyOyIodapzIkbh3eZ1SGn2e99bcrhwBECQfwZz7dRDqR /+4LElR9T6pTIGeYOK1uXfhYAgbsYhVtsGKxxfvazKfC1d2r8RV9s3JTp9HzfrbGBk9A dSaOhUqpjJdxsOwTvhKbduCVoWxAvlNJQ4Ec9E/p5W5ptWyLaxEVe8JIRtG64Z5HU1bN RKKHKXNS/rFUhqhJkZXvjkJnWkoWkRBsa6BTen2h9mWWY6yEtnWd7sDnfy4xdqq5aSW9 xYNh+p+Ak/pAlD0dImJVCTkP1VkuEMyP9AYX34tkJIDVQRMZZPfxJ35E4qPNpcaHFVAz wfwQ== X-Gm-Message-State: ALoCoQksoNxSahvtkBCEjT6xQjmtK5qC7uJn7pLVs0BaboJOJskx09URPucpgzko7Tduyt1Peyh7 MIME-Version: 1.0 X-Received: by 10.60.130.136 with SMTP id oe8mr15501385oeb.10.1441082550270; Mon, 31 Aug 2015 21:42:30 -0700 (PDT) X-Originating-IP: [122.56.205.73] Content-Type: multipart/alternative; boundary=089e0122a75c8058b4051ea82dcd X-Mailing-List: archive/latest/12528 List-ID: List-URL: List-Archive: https://lists.debian.org/msgid-search/CAJ3HoZ3tj7BHNEkdUGd9g1CstmXVDKt2USi99Vn_JisqyMQ7_A@mail.gmail.com Approved: robomod@news.nic.it Lines: 233 Organization: linux.* mail to news gateway Sender: robomod@news.nic.it X-Original-Cc: Debian Python X-Original-Date: Tue, 1 Sep 2015 16:42:30 +1200 X-Original-Message-ID: X-Original-References: <85bndmc0ln.fsf@benfinney.id.au> Xref: csiph.com linux.debian.maint.python:7221 --089e0122a75c8058b4051ea82dcd Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable PKG resources should find it anywhere in the python path. I'd the path correct within the all processes? On 1 Sep 2015 2:53 pm, "Ben Finney" wrote: > Howdy all, > > How can I specify to Pybuild that an application should have its modules > all in a private namespace, but have the Distutils metadata also > available to `pkg_resources` queries? > > I install its libraries to an application-specific space with > `PYBUILD_INSTALL_ARGS =3D --install-lib=3D/usr/share/foo/`:: > > $ find /usr/share/FooApp/ > /usr/share/FooApp/ > /usr/share/FooApp/lorem > /usr/share/FooApp/lorem/__init__.py > /usr/share/FooApp/lorem/dolor.py > /usr/share/FooApp/lorem/sit.py > /usr/share/FooApp/lorem/amet.py > /usr/share/FooApp/FooApp-1.2.3.egg-info > /usr/share/FooApp/FooApp-1.2.3.egg-info/PKG-INFO > /usr/share/FooApp/FooApp-1.2.3.egg-info/requires.txt > /usr/share/FooApp/FooApp-1.2.3.egg-info/entry_points.txt > /usr/share/FooApp/FooApp-1.2.3.egg-info/not-zip-safe > /usr/share/FooApp/FooApp-1.2.3.egg-info/dependency_links.txt > /usr/share/FooApp/FooApp-1.2.3.egg-info/top_level.txt > /usr/share/FooApp/ipsum > /usr/share/FooApp/ipsum/__init__.py > /usr/share/FooApp/ipsum/consecteur.py > /usr/share/FooApp/ipsum/adipiscing.py > /usr/share/FooApp/ipsum/elit.py > > (The actual code base is a fork of =E2=80=98dput=E2=80=99 to modernise it= s packaging > and Python idioms.) > > The application's Python package is managed like other operating system > files, but is not in the general Python namespace for other programs to > import. Good. > > The application has =E2=80=9Cconsole scripts=E2=80=9D defined in the Dist= utils > `entry_points` mapping: > > $ cat ./setup.py > [=E2=80=A6] > entry_points=3D{ > 'console_scripts': [ > "foo=3DFooApp.foo:main", > ], > }, > [=E2=80=A6] > > which installs command-line programs at `/usr/bin/foo`, for example. > Good. > > The distribution metadata (the `FooApp-1.2.3.egg-info` directory) is > also installed to the private directory though, which makes it invisible > to `pkg_resources`: > > $ /usr/bin/foo > Traceback (most recent call last): > File "/usr/bin/foo", line 5, in > from pkg_resources import load_entry_point > File "/usr/lib/python2.7/dist-packages/pkg_resources/__init__.py", > line 3084, in > @_call_aside > File "/usr/lib/python2.7/dist-packages/pkg_resources/__init__.py", > line 3070, in _call_aside > f(*args, **kwargs) > File "/usr/lib/python2.7/dist-packages/pkg_resources/__init__.py", > line 3097, in _initialize_master_working_set > working_set =3D WorkingSet._build_master() > File "/usr/lib/python2.7/dist-packages/pkg_resources/__init__.py", > line 651, in _build_master > ws.require(__requires__) > File "/usr/lib/python2.7/dist-packages/pkg_resources/__init__.py", > line 952, in require > needed =3D self.resolve(parse_requirements(requirements)) > File "/usr/lib/python2.7/dist-packages/pkg_resources/__init__.py", > line 839, in resolve > raise DistributionNotFound(req, requirers) > pkg_resources.DistributionNotFound: The FooApp=3D=3D1.2.3' distributi= on > was not found and is required by the application > > Other queries to `pkg_resources` for this application's distribution, > for example to get the distribution version or homepage URL, will also > fail. > > How can I have Pybuild specify to Distutils that the application's > library modules should be installed away from the public namespace and > not available for general import, but also that the `pkg_resources` > functionality should find the distribution metadata where expected? > > -- > \ =E2=80=9CWhen I was a kid I used to pray every night for a new bic= ycle. | > `\ Then I realised that the Lord doesn't work that way so I stole | > _o__) one and asked Him to forgive me.=E2=80=9D =E2=80= =94Emo Philips | > Ben Finney > > --089e0122a75c8058b4051ea82dcd Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable

PKG resources should find it anywhere in the python path. I&= #39;d the path correct within the all processes?

On 1 Sep 2015 2:53 pm, "Ben Finney" &l= t;ben+debian@benfinney.id.a= u> wrote:
How= dy all,

How can I specify to Pybuild that an application should have its modules all in a private namespace, but have the Distutils metadata also
available to `pkg_resources` queries?

I install its libraries to an application-specific space with
`PYBUILD_INSTALL_ARGS =3D --install-lib=3D/usr/share/foo/`::

=C2=A0 =C2=A0 $ find /usr/share/FooApp/
=C2=A0 =C2=A0 /usr/share/FooApp/
=C2=A0 =C2=A0 /usr/share/FooApp/lorem
=C2=A0 =C2=A0 /usr/share/FooApp/lorem/__init__.py
=C2=A0 =C2=A0 /usr/share/FooApp/lorem/dolor.py
=C2=A0 =C2=A0 /usr/share/FooApp/lorem/sit.py
=C2=A0 =C2=A0 /usr/share/FooApp/lorem/amet.py
=C2=A0 =C2=A0 /usr/share/FooApp/FooApp-1.2.3.egg-info
=C2=A0 =C2=A0 /usr/share/FooApp/FooApp-1.2.3.egg-info/PKG-INFO
=C2=A0 =C2=A0 /usr/share/FooApp/FooApp-1.2.3.egg-info/requires.txt
=C2=A0 =C2=A0 /usr/share/FooApp/FooApp-1.2.3.egg-info/entry_points.txt
=C2=A0 =C2=A0 /usr/share/FooApp/FooApp-1.2.3.egg-info/not-zip-safe
=C2=A0 =C2=A0 /usr/share/FooApp/FooApp-1.2.3.egg-info/dependency_links.txt<= br> =C2=A0 =C2=A0 /usr/share/FooApp/FooApp-1.2.3.egg-info/top_level.txt
=C2=A0 =C2=A0 /usr/share/FooApp/ipsum
=C2=A0 =C2=A0 /usr/share/FooApp/ipsum/__init__.py
=C2=A0 =C2=A0 /usr/share/FooApp/ipsum/consecteur.py
=C2=A0 =C2=A0 /usr/share/FooApp/ipsum/adipiscing.py
=C2=A0 =C2=A0 /usr/share/FooApp/ipsum/elit.py

(The actual code base is a fork of =E2=80=98dput=E2=80=99 to modernise its = packaging
<URL:https://notabug.org/bignose/dput/> and Python idioms= .)

The application's Python package is managed like other operating system=
files, but is not in the general Python namespace for other programs to
import. Good.

The application has =E2=80=9Cconsole scripts=E2=80=9D defined in the Distut= ils
`entry_points` mapping:

=C2=A0 =C2=A0 $ cat ./setup.py
=C2=A0 =C2=A0 [=E2=80=A6]
=C2=A0 =C2=A0 =C2=A0 =C2=A0 entry_points=3D{
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 'console_scripts': [
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 "foo=3DFooApp.= foo:main",
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 ],
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 },
=C2=A0 =C2=A0 [=E2=80=A6]

which installs command-line programs at `/usr/bin/foo`, for example.
Good.

The distribution metadata (the `FooApp-1.2.3.egg-info` directory) is
also installed to the private directory though, which makes it invisible to `pkg_resources`:

=C2=A0 =C2=A0 $ /usr/bin/foo
=C2=A0 =C2=A0 Traceback (most recent call last):
=C2=A0 =C2=A0 =C2=A0 File "/usr/bin/foo", line 5, in <module&g= t;
=C2=A0 =C2=A0 =C2=A0 =C2=A0 from pkg_resources import load_entry_point
=C2=A0 =C2=A0 =C2=A0 File "/usr/lib/python2.7/dist-packages/pkg_resour= ces/__init__.py", line 3084, in <module>
=C2=A0 =C2=A0 =C2=A0 =C2=A0 @_call_aside
=C2=A0 =C2=A0 =C2=A0 File "/usr/lib/python2.7/dist-packages/pkg_resour= ces/__init__.py", line 3070, in _call_aside
=C2=A0 =C2=A0 =C2=A0 =C2=A0 f(*args, **kwargs)
=C2=A0 =C2=A0 =C2=A0 File "/usr/lib/python2.7/dist-packages/pkg_resour= ces/__init__.py", line 3097, in _initialize_master_working_set
=C2=A0 =C2=A0 =C2=A0 =C2=A0 working_set =3D WorkingSet._build_master()
=C2=A0 =C2=A0 =C2=A0 File "/usr/lib/python2.7/dist-packages/pkg_resour= ces/__init__.py", line 651, in _build_master
=C2=A0 =C2=A0 =C2=A0 =C2=A0 ws.require(__requires__)
=C2=A0 =C2=A0 =C2=A0 File "/usr/lib/python2.7/dist-packages/pkg_resour= ces/__init__.py", line 952, in require
=C2=A0 =C2=A0 =C2=A0 =C2=A0 needed =3D self.resolve(parse_requirements(requ= irements))
=C2=A0 =C2=A0 =C2=A0 File "/usr/lib/python2.7/dist-packages/pkg_resour= ces/__init__.py", line 839, in resolve
=C2=A0 =C2=A0 =C2=A0 =C2=A0 raise DistributionNotFound(req, requirers)
=C2=A0 =C2=A0 pkg_resources.DistributionNotFound: The FooApp=3D=3D1.2.3'= ; distribution was not found and is required by the application

Other queries to `pkg_resources` for this application's distribution, for example to get the distribution version or homepage URL, will also
fail.

How can I have Pybuild specify to Distutils that the application's
library modules should be installed away from the public namespace and
not available for general import, but also that the `pkg_resources`
functionality should find the distribution metadata where expected?

--
=C2=A0\=C2=A0 =C2=A0 =C2=A0=E2=80=9CWhen I was a kid I used to pray every n= ight for a new bicycle. |
=C2=A0 `\=C2=A0 =C2=A0 Then I realised that the Lord doesn't work that = way so I stole |
_o__)=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0o= ne and asked Him to forgive me.=E2=80=9D =E2=80=94Emo Philips |
Ben Finney

--089e0122a75c8058b4051ea82dcd--