On Mon, Apr 20, 2020 at 1:47 PM Alex Hall <alex.mojaki@gmail.com> wrote:
On Mon, Apr 20, 2020 at 7:37 PM Christopher Barker <pythonchb@gmail.com> wrote:
On Sun, Apr 19, 2020 at 3:37 AM Alex Hall <alex.mojaki@gmail.com> wrote:
```
File "setup.py", line 2232
        self.add(Extension('_decimal',
                           include_dirs=include_dirs,
                           libraries=libraries,
                           define_macros=define_macros,
                           undef_macros=undef_macros,
                           extra_compile_args=extra_compile_args,
                           sources=sources,
                           depends=depends))

I don't know about all the other examples, but in a setup.py that cries out for a more declarative approach: put all that in a dict, and call Extension('_decimal', **build_params).

Do you mean essentially writing something like:

        build_params = dict(
            include_dirs=include_dirs,
            libraries=libraries,
            define_macros=define_macros,
            undef_macros=undef_macros,
            extra_compile_args=extra_compile_args,
            sources=sources,
            depends=depends
        )
        self.add(Extension('_decimal', **build_params)

no -- that would be essentially the same, of course. And would also be addressed by the "dict uses local names" version of this proposal.

Sorry, I was being lazy -- I was more referring to setup.py files in general, which I think should be more declarative, not specifically this one, that I haven't gone to find to see how it's really being used in this case.

But in the general case, all those local names needed to be set to something at some point -- it *may* have been just as easy (or easier) to populate a dict, rather than set them to local names.

And in that example, those looked al lot to me like a bunch of parameters that would likely be shared among multiple Extensions -- so all the more reason to have them, as a set, in a dict or something.

I'm sorry I haven't taken the time to go find that example, maybe that one is as good as it gets, in which case -- <quiet_voice> never mind </quiet_voice>

-CHB



--
Christopher Barker, PhD

Python Language Consulting
  - Teaching
  - Scientific Software Development
  - Desktop GUI and Web Development
  - wxPython, numpy, scipy, Cython