Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 522794 - dev-python/python-docs: Install files in a more predictable location
Summary: dev-python/python-docs: Install files in a more predictable location
Status: RESOLVED WONTFIX
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: [OLD] Development (show other bugs)
Hardware: All Linux
: Normal normal (vote)
Assignee: Python Gentoo Team
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-09-14 17:52 UTC by Mike Gilbert
Modified: 2018-04-24 16:54 UTC (History)
4 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Mike Gilbert gentoo-dev 2014-09-14 17:52:36 UTC
dev-python/python-docs currently installs files in /usr/share/doc/${PF}/html. This is undesirable for a couple of reasons:

1. It is difficult to bookmark in a browser across minor version bumps.

2. As has been pointed out by Ian in a recent mailing list post, intersphinx needs to access objects.inv when building docs for other packages. It would be helpful to have this file in a predictable location.

Here is what I propose:

A. python-docs installs its files in /usr/share/doc/${PN}-${SLOT}

B. A pkg_postinst / pkg_postrm call will maintain a symlink at /usr/share/doc/python-docs which points at the latest installed version.

Any objections or better ideas?
Comment 1 Michał Górny archtester Gentoo Infrastructure gentoo-dev Security 2014-09-14 17:58:14 UTC
I don't like the idea of reusing /usr/share/doc with another naming scheme. Does sphinx have any specific location hardcoded btw?
Comment 2 Mike Gilbert gentoo-dev 2014-09-14 18:04:02 UTC
None that I know of. Docs for reference:

http://sphinx-doc.org/ext/intersphinx.html
Comment 3 W. Trevor King 2014-09-14 18:07:48 UTC
(In reply to Michał Górny from comment #1)
> I don't like the idea of reusing /usr/share/doc with another naming scheme.

Why not?  It's a slotted dependency, so there won't be conflicts for
slot-level namespacing.

> Does sphinx have any specific location hardcoded btw?

No, it's just hardcoded in the consumer's intersphinx_mapping [1,2].

For (B), I'd propose we link to the 2.7 slot, and fall back to the
highest 3.x slot if there isn't an installed version of python-docs in
the 2.7 slot.  That matches PEP 430 [3] and
https://docs.python.org/objects.inv.

[1]: http://sphinx-doc.org/latest/ext/intersphinx.html#confval-intersphinx_mapping
[2]: https://github.com/wcdolphin/flask-cors/blob/v1.8.0/docs/conf.py#L259
[3]: http://legacy.python.org/dev/peps/pep-0430/#don-t-break-useful-resources
Comment 4 W. Trevor King 2014-09-14 18:16:12 UTC
(In reply to W. Trevor King from comment #3)
> For (B), I'd propose we link to the 2.7 slot, and fall back to the
> highest 3.x slot if there isn't an installed version of python-docs in
> the 2.7 slot.  That matches PEP 430 [3] and
> https://docs.python.org/objects.inv.

Oh, we'll probably want additional symlinks for /usr/share/doc/${PN}-2 and 3, to match http://docs.python.org/2/objects.inv and http://docs.python.org/3/objects.inv.  For easier maintenance, ${PN}-2 can just point to ${PN}.
Comment 5 Mike Gilbert gentoo-dev 2014-09-14 18:32:34 UTC
Another possible location would be /usr/share/python-docs, which would keep us from messing with the /usr/share/doc naming convention.
Comment 6 Mike Gilbert gentoo-dev 2014-09-14 19:14:05 UTC
A less intrusive solution would be to leave the files where they are, and create some symlinks /usr/share/python-docs.
Comment 7 W. Trevor King 2014-09-15 02:15:20 UTC
(In reply to Mike Gilbert from comment #0)
> 2. As has been pointed out by Ian in a recent mailing list post, intersphinx
> needs to access objects.inv when building docs for other packages. It would
> be helpful to have this file in a predictable location.

This stable-symlink approach to providing unversioned, 2.x, 3.x, and slot-level symlinks is ok for python-docs, because it matches upstream's approach with docs.python.org.  I don't think it's going to scale well for other packages with Sphinx-based docs that act as intersphins targets, though.  For example, Matplotlib's Sphinx docs will have an objects.inv, but dev-python/matplotlib-9999 currently uses distutils-r1's HTML_DOCS to install it's docs.  That's not going to intall objects.inv, but even if it did, it would be touchy to have a matplotlib client linking into /usr/share/docs/matplotlib-1.2.0-r2 and unweildy to link into /usr/share/matplotlib-docs/1.3 (etc., etc., for every other Sphinx-based package).
Comment 8 Chris Mayo 2014-09-15 18:37:42 UTC
Maybe it doesn't do what you want but no one has mentioned the existing symlink:
/usr/share/doc/html/dev-python/python-docs-${SLOT}
Comment 9 W. Trevor King 2014-09-15 18:43:35 UTC
(In reply to Chris Mayo from comment #8)
> Maybe it doesn't do what you want but no one has mentioned the existing
> symlink:
> /usr/share/doc/html/dev-python/python-docs-${SLOT}

I don't have that link locally.  Do you know where yours came from?
Comment 10 Mike Gilbert gentoo-dev 2014-09-15 19:03:15 UTC
He probably has DOC_SYMLINKS_DIR set in make.conf.

DOC_SYMLINKS_DIR
If this variable contains a directory then symlinks to html documentation will  be installed into it.
Comment 11 W. Trevor King 2014-09-15 19:13:41 UTC
(In reply to Mike Gilbert from comment #10)
> He probably has DOC_SYMLINKS_DIR set in make.conf.

That's not in the PMS, so I think it's probably off-limits in an ebuild that needs access to an objects.inv file.  Portage's 507bae0b (create symlinks to html documentation if DOC_SYMLINK_DIR is set, 2007-01-10) doesn't explain why you'd want something like this anyway ;).  Perhaps it's for the bookmark reason you mention in the original comment?  In any case, a solution that works for both users and ebuilds would be better ;).
Comment 12 Ian Delaney (RETIRED) gentoo-dev 2014-09-29 04:39:22 UTC
Do we have any consensus on a final generic from of sulution? Last entry 2 weeks.  If nothing else, the form in the now present and bumped flask-cors to me would suffice.  It's a template since the entry in conf.py may need a tweak form package to package. Already found one
Comment 13 Mike Gilbert gentoo-dev 2014-10-18 22:45:47 UTC
Given the complexity of a generic solution for the intersphinx problem, and the relative utility of having hyperlinks to external documentation for the standard library, I don't think it really makes sense to implement this.
Comment 14 W. Trevor King 2014-10-18 23:41:14 UTC
(In reply to Mike Gilbert from comment #13)
> Given the complexity of a generic solution for the intersphinx problem, …

It's not particularly complicated.  Figuring out which packages are satisfying an or-clause dependency and locating one of their installed files by name are both simple concepts.  I think the main blocker is that there's currently no way to do either of these, and the benefit may not be worth the trouble of pushing through a PMS update (i.e. “the PMS is too heavy”, not “a generic solution is complex”).

> … and the relative utility of having hyperlinks to external documentation
> for the standard library, …

Are you saying that linking out to external documentation is more useful than linking to local docs?  If you're in that camp, I don't see why you'd enable the 'doc' flag at all ;).  Anyway, we shouldn't be hitting the network to download the objects.inv files at build time [1], and I don't have a solution to versioning any objects.inv files a build depends on thats any simpler than the one proposed here.

[1]: https://bugs.gentoo.org/show_bug.cgi?id=522064
Comment 15 Mike Gilbert gentoo-dev 2014-10-18 23:59:40 UTC
(In reply to W. Trevor King from comment #14)

I'm saying that I don't think it makes sense to mess with a bunch of packages so that we can generate hyperlinks to a local copy of the python docs. It's just not worth it.

As for the "don't fetch from the network thing", that's pretty minor. If the network is unavailable, nothing breaks except for a few hyperlinks.
Comment 16 Michał Górny archtester Gentoo Infrastructure gentoo-dev Security 2014-10-19 07:13:33 UTC
As floppym said. If we were able to install the Sphinx docs in such a way that intersphinx would find them automatically, that would be a different thing. But I don't think any of us is able to work on that right now.

If you are interested, please look into patching the Sphinx code. Not sure how feasible that would be, and whether upstream will be really interested in applying it. For a start, you would have to be able to map URIs into local directories for all packages.

We could probably change the install location then, but you'd also have them to install some kind of index file... also, note that for the case of python-docs, the mapping would have to recognize different locations for different python versions.

In other words, unlikely and a lot of work.
Comment 17 Mike Gilbert gentoo-dev 2014-10-20 14:45:32 UTC
I'm reopening this because I think problem #1 is worth solving, regardless of the intersphinx issue.

If it makes the intersphinx sed-hack (which I still don't really like) simpler, we will count that as a bonus.
Comment 18 W. Trevor King 2014-10-21 00:19:47 UTC
 Earlier today on #gentoo-python I said I was fine with /usr/share/doc/${PN}/${SLOT} symlinks (or some variation on that name), but I've since come back to my earlier position:

(In reply to W. Trevor King from comment #14)
> It's not particularly complicated.  Figuring out which packages are
> satisfying an or-clause dependency and locating one of their installed files
> by name are both simple concepts.  I think the main blocker is that there's
> currently no way to do either of these, and the benefit may not be worth the
> trouble of pushing through a PMS update (i.e. “the PMS is too heavy”, not “a
> generic solution is complex”).

Letting the "locating one of their installed files" bit slip for now, the symlink approach allows us to tiptoe around figuring out which package satisfies a dependency (e.g. if you asked for python-docs:2.7, you can just use the …/2.7 symlink without figuring out that it's 2.7.8 and using …/python-docs-2.7.8/).  I'd rather have something give me atoms for “what package satifsies "${DEPENDENCY_CLAUSE}"”.  That's basically an extension of best_version (lets call it satisfied_by).  Then you could have:

  PYTHON_DOCS_DEPENDS="|| ( dev-python/python-docs:2.7 dev-python/python-docs:3.3 … )
  DEPENDS="${PYTHON_DOCS_DEPENDS} …"
  …
  python_prepare_all() {
    if use doc; then
      local PYTHON_DOC_ATOM=$(satisfied_by --host-root "${PYTHON_DOCS_DEPENDS}")
      …
    fi
  }

Of course, a naive satisfied_by is not going to be able to traverse the dependency tree (e.g. to look past virtual/* dependencies).  It's hard to write a clean API for that in Bash though.  What you'd want is access to a Portage's parsed dependency tree in Python.  So until we land a pure-Python EAPI, I think we have to either use /usr/share/doc/${PN}/${SLOT} symlinks for all installed packages, or just stick to the cases we can already handle with best_version.
Comment 19 Ian Delaney (RETIRED) gentoo-dev 2014-10-21 02:31:43 UTC
good thoughts.

"What you'd want is access to a Portage's parsed dependency tree in Python."

Careful we don't overload the requirements to get this to work.

"or just stick to the cases we can already handle with best_version"
it appears would keep this 'manageable', though once we get a working form, we' (I) can add to it at leisure.  What makes this whole exercise difficult is it starts out with "the intersphinx sed-hack". which frankly is easy not to like. However, imho, we need get past that and accept it will require a use of the lesser of the choice of evils.  In other words, compromise; something that is just part of 'real life'.
Comment 20 Mike Gilbert gentoo-dev 2014-10-21 03:09:35 UTC
(In reply to Ian Delaney from comment #19)
> However, imho, we need get past that and accept it will require a
> use of the lesser of the choice of evils.

An even "lesser evil" would be to leave it alone and not apply the sed hack. It's a half-baked solution to a very minor problem.
Comment 21 Dirkjan Ochtman (RETIRED) gentoo-dev 2014-10-21 07:27:42 UTC
I'm with Mike!
Comment 22 Michał Górny archtester Gentoo Infrastructure gentoo-dev Security 2014-10-21 07:51:22 UTC
So how about /usr/share/sphinx-docs/python-{2.7,3.3,3.4,...}? That looks quite sane and keeps the potential of installing future application docs there. Since that's not the only problem with Sphinx-generated docs, we may want to provide a more complete solution that covers bug #526186 (filtered files) as well.
Comment 23 W. Trevor King 2014-10-21 18:04:07 UTC
(In reply to Michał Górny from comment #22)
> So how about /usr/share/sphinx-docs/python-{2.7,3.3,3.4,...}? That looks
> quite sane and keeps the potential of installing future application docs
> there. Since that's not the only problem with Sphinx-generated docs, we may
> want to provide a more complete solution that covers bug #526186 (filtered
> files) as well.

I still think that we should have generic solutions to the genric problems [1].  In this case, I'm fine just using best_version.  We currently use best_version to get the full version number (in flask-cors[doc] and similar), are folks really that unhappy about that approach?  In the next week or so, I hope to have an initial sphinx.eclass that abstracts away the current best_version through intersphinx sed stuff into an:

  sphinx_local_objects LINKED_PACKAGE_DEPENDENCY SED_REGEX_MATCHINGsphinx_local_objects_THE_UPSTREAM_INTERSPHINX_ENTRY PATH_TO_CONF_PY

so, for example, the flask-cors doc patch would look like:

  sphinx_local_objects dev-python/python-docs:2.7 "'http://docs.python.org/': None" docs/conf.py

How does that sound?  A Sphinx eclass would also be a good place for a dosphinx helper.

[1]: https://bugs.gentoo.org/show_bug.cgi?id=522794#c18
Comment 24 Michał Górny archtester Gentoo Infrastructure gentoo-dev Security 2018-04-24 16:54:25 UTC
No action for 3.5yr.  Feel free to reopen if somebody decides to actually pursue it with code.