Path: csiph.com!eternal-september.org!feeder.eternal-september.org!weretis.net!feeder1.news.weretis.net!newsfeed.CARNet.hr!news.spin.it!bofh.it!news.nic.it!robomod From: Ben Finney Newsgroups: linux.debian.maint.python Subject: Application libraries private, Distutils metadata available for console scripts and introspection Date: Tue, 01 Sep 2015 05:00:02 +0200 Message-ID: X-Original-To: debian-python@lists.debian.org X-Mailbox-Line: From debian-python-request@lists.debian.org Tue Sep 1 02:53:10 2015 Old-Return-Path: X-Amavis-Spam-Status: No, score=-9.012 tagged_above=-10000 required=5.3 tests=[BAYES_00=-2, FOURLA=0.1, HEADER_FROM_DIFFERENT_DOMAINS=0.015, LDO_WHITELIST=-5, RCVD_IN_DNSWL_LOW=-0.7, RP_MATCHES_RCVD=-1.427] autolearn=ham autolearn_force=no X-Policyd-Weight: using cached result; rate:hard: -6.1 X-Injected-Via-Gmane: http://gmane.org/ Lines: 87 MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Gmane-NNTP-Posting-Host: jigong.madmonks.org X-Public-Key-ID: 0xAC128405 X-Public-Key-Fingerprint: 517C F14B B2F3 98B0 CB35 4855 B8B2 4C06 AC12 8405 X-Public-Key-URL: http://www.benfinney.id.au/contact/bfinney-pubkey.asc X-Post-From: Ben Finney User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.4 (gnu/linux) Cancel-Lock: sha1:3t22ZmCwJ7BIHkyhC5XAVtc3Tbc= X-Mailing-List: archive/latest/12527 List-ID: List-URL: List-Archive: https://lists.debian.org/msgid-search/85bndmc0ln.fsf@benfinney.id.au Approved: robomod@news.nic.it Organization: linux.* mail to news gateway Sender: robomod@news.nic.it X-Original-Date: Tue, 01 Sep 2015 12:52:36 +1000 X-Original-Message-ID: <85bndmc0ln.fsf@benfinney.id.au> X-Original-X-Complaints-To: usenet@ger.gmane.org Xref: csiph.com linux.debian.maint.python:7220 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 = --install-lib=/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 ‘dput’ to modernise its 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 “console scripts” defined in the Distutils `entry_points` mapping: $ cat ./setup.py […] entry_points={ 'console_scripts': [ "foo=FooApp.foo:main", ], }, […] 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 = 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 = 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==1.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? -- \ “When I was a kid I used to pray every night for a new bicycle. | `\ Then I realised that the Lord doesn't work that way so I stole | _o__) one and asked Him to forgive me.” —Emo Philips | Ben Finney