question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Querying Requested Extras in build_ext

See original GitHub issue

Hi,

I am building an external CMake extension with

from setuptools import setup, Extension
from setuptools.command.build_ext import build_ext


class CMakeExtension(Extension):
    def __init__(self, name, sourcedir=''):
        Extension.__init__(self, name, sources=[])
        self.sourcedir = os.path.abspath(sourcedir)


class CMakeBuild(build_ext):
    def run(self):
        # ...

        for ext in self.extensions:
            self.build_extension(ext)

    def build_extension(self, ext):
        # ...

# ...
setup(
    # ...
    ext_modules=[CMakeExtension('openpmd_api')],
    extras_require={
        'mpi': ['mpi4py'],
    },
    # ...
)

and would like to query the user-requested extras during the build_extension step, in order to find out if the extra 'mpi' was requested (via pip install .[mpi]) or not. Is there a way to query this?

Full example: setup.py

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
jaracocommented, Mar 18, 2019

Here’s my (late) response as posted in the Gitter inquiry (I haven’t read the thread above).

That’s not possible as far as I know. If the current project depends on it to decide how to build itself, then it’s not really an extra (as intended). Extras are intended for install-time dependency resolution, not build-time. You’ll want to structure your project so it can support running with and without the extras at run-time… maybe that means building with and without the libs the extras might require, or maybe it means pushing that functionality into the extras themselves.

1reaction
pgansslecommented, Mar 5, 2019

@ax3l I do not think that “extras” are intended to control additional functionality in the build, they are intended to allow you to specify dependencies for optional runtime features (see the documentation). I could certainly be wrong because I don’t know much about the history of the “extras” feature, but it’s really about declaring metadata for the front-end.

At least the way the build tools currently work, the idea is that at build time you would build everything you support, and at install time those features would only actually be usable if you had specified the extra options. This means that either you make a hard build-time requirement of mpi, regardless of the extra options, but make it optional at install time, or you separate out the parts that require mpi into a separate package that itself has a hard requirement of mpi.

Read more comments on GitHub >

github_iconTop Results From Across the Web

QUERY/COLLECTION/SQL/OTHER FOR ALL COMPLIANCY
Hi,. I need a way of getting 5 columns out: Hostname, Last Logon Timestamp, Latest CU in SCCM, Installed CU, Compliant (true/false).
Read more >
distutils: How to pass a user defined parameter to setup.py?
Generally speaking I would suggest providing a bit more information what exactly your extra parameter should do, maybe there is a better solution...
Read more >
What is BEP and what is EIR? What is CDE? - BuildEXT
What is CDE? ; Workflow Management, Ability to automate, manage and report; Request for Information (RFI) Management ; Model Management, Version ...
Read more >
[#ARROW-2269] [Python] Cannot build bdist_wheel for Python - ASF ...
I am trying current master. I ran: {{{{ python setup.py build_ext --build-type=$ARROW_BUILD_TYPE --with-parquet --with-plasma --bundle-arrow-cpp bdist_wheel } ...
Read more >
[Solved]-Debugging ExtJS errors after build-ext.js - appsloveworld
There is no easy way on debugging ExtJS (or any other Javascript) application after you have minified the code, although there are a...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found