public inbox for gentoo-python@lists.gentoo.org
 help / color / mirror / Atom feed
* [gentoo-python] Concept for optional Python dependency and USE-flag deps in p-d-ng
@ 2012-09-09  8:33 Michał Górny
  2012-09-09 15:21 ` Mike Gilbert
  0 siblings, 1 reply; 3+ messages in thread
From: Michał Górny @ 2012-09-09  8:33 UTC (permalink / raw
  To: gentoo-python

[-- Attachment #1: Type: text/plain, Size: 2048 bytes --]

Hello,

After some thinking, I think I found an optimal solution to
implementing various kinds of Python dependencies and PYTHON_USE_WITH*.

As a note, all variable names are dirty and not official. Feel free to
suggest better ones.

1. Add a user-defined variable PYTHON_USE. If user needed any specific
flags from a Python dependency, he can set the USE dependency string
there. The string will have to follow the general rules for USE
dependencies and be correct for every Python implementation specified
in PYTHON_COMPAT (this may require USE defaults). For example:

    PYTHON_USE="ncurses,sqlite"

2. Add a eclass-defined variable PYTHON_DEPEND. It will be always
exported, and contain a dependency string created using PYTHON_COMPAT
and PYTHON_USE -- the most simple and most common one, e.g.:

    PYTHON_DEPEND="
      python_targets_pythonX_Y?
        ( dev-python/python:X.Y[ncurses,sqlite] )
    "

3. By default, just append PYTHON_DEPEND to DEPEND and RDEPEND. Provide
an option to disable that. If user wants optional Python, he can
disable it and use ${PYTHON_DEPEND} in his own *DEPEND code. (we could
also provide a quick switch to add 'python? ( )' or '$USEFLAG? ( )').

4. Finally, provide a general, parametrized dependency generator
function which will be useful in all the remaining non-common cases
which can't be handled sanely by any other solution.

For example, the following ::progress string:

  PYTHON_DEPEND="<<[xml]>> database? ( <<[gdbm]>> ) gui? ( <<[tk]>> )"

could be obtained using:

  PYTHON_COMPAT=...
  PYTHON_USE=xml
  inherit python-distutils-ng
  RDEPEND="
    ${PYTHON_DEPEND}
    database? (
      $(python-gen-depend gdbm ${PYTHON_COMPAT})
    )
    gui? (
      $(python-gen-depend tk ${PYTHON_COMPAT})
    )
  "

or even hackier (but faster):

  RDEPEND="
    ${PYTHON_DEPEND}
    database? (
      ${PYTHON_DEPEND//\[xml\]/[gdbm]}
    )
    gui? (
      ${PYTHON_DEPEND//\[xml\]/[tk]}
    )
  "

-- 
Best regards,
Michał Górny

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 316 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2012-09-09 17:29 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-09-09  8:33 [gentoo-python] Concept for optional Python dependency and USE-flag deps in p-d-ng Michał Górny
2012-09-09 15:21 ` Mike Gilbert
2012-09-09 17:30   ` Michał Górny

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox