Suggestion: allow conditional distutils directives

21 views
Skip to first unread message

Antony Lee

unread,
Jan 25, 2016, 2:25:07 AM1/25/16
to cython...@googlegroups.com
Something like

IF UNAME_SYSNAME == "Linux":
    #distutils: define_macros = FOOBAR=42
    pass # to avoid completely confusing the parser, this may help.
ELSE:
    #distutils: define_macros = FOOBAR=123
    pass

The goal being mostly to pass different compilation options/link options depending on the platform, without having to put these options in setup.py.

Thoughts?

Antony

Nathaniel Smith

unread,
Jan 25, 2016, 3:27:09 AM1/25/16
to cython...@googlegroups.com

I have no opinion on the proposal, but I think if you're going to add syntax for pragmas then you should spell it like PRAGMA or something, not use magic comments :-)

--

---
You received this message because you are subscribed to the Google Groups "cython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cython-users...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Antony Lee

unread,
Jan 25, 2016, 11:15:20 AM1/25/16
to cython...@googlegroups.com
Well, #distutils: XXX and #cython: XXX already are magic comments.

Nathaniel Smith

unread,
Jan 25, 2016, 11:48:05 AM1/25/16
to cython...@googlegroups.com

Huh, didn't know that. Well, it's still true... :-)

Robert Bradshaw

unread,
Jan 25, 2016, 1:43:24 PM1/25/16
to cython...@googlegroups.com
By the time you're introducing actual logic, I think it'd be
preferable to put it in the setup.py rather than complicate these
declarations. However, you can things conditionally via aliases:

https://github.com/cython/cython/blob/master/tests/build/inline_distutils.srctree

(Not a huge fan of that name, bug "macros" was taken...)

Antony Lee

unread,
Jan 25, 2016, 2:05:04 PM1/25/16
to cython...@googlegroups.com
Thanks for the tip.  I don't think this feature is documented anywhere?  (not in the docstring of cythonize, at least.)
(My actual use-case is a change in the name of the library linked between Linux and Windows.)
Antony

Reply all
Reply to author
Forward
0 new messages