public inbox for gentoo-python@lists.gentoo.org
 help / color / mirror / Atom feed
From: "Michał Górny" <mgorny@gentoo.org>
To: gentoo-python@lists.gentoo.org
Subject: [gentoo-python] Concept for optional Python dependency and USE-flag deps in p-d-ng
Date: Sun, 9 Sep 2012 10:33:37 +0200	[thread overview]
Message-ID: <20120909103337.2eb72f49@pomiocik.lan> (raw)

[-- 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 --]

             reply	other threads:[~2012-09-09  8:32 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-09-09  8:33 Michał Górny [this message]
2012-09-09 15:21 ` [gentoo-python] Concept for optional Python dependency and USE-flag deps in p-d-ng Mike Gilbert
2012-09-09 17:30   ` Michał Górny

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20120909103337.2eb72f49@pomiocik.lan \
    --to=mgorny@gentoo.org \
    --cc=gentoo-python@lists.gentoo.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox