Skip to content

Remove most of the cython-specific config files by running the preprocessor.#618

Closed
emilio wants to merge 1 commit intomasterfrom
cython-prepro
Closed

Remove most of the cython-specific config files by running the preprocessor.#618
emilio wants to merge 1 commit intomasterfrom
cython-prepro

Conversation

@emilio
Copy link
Copy Markdown
Collaborator

@emilio emilio commented Nov 17, 2020

I think I'm a bit happier with this than the alternative of having to
maintain two config files.

The main changes:

  • We run the preprocessor on the cbindgen output. This is useful so
    that we can use ifdefs for cython in header/trailers.

  • If there's both <file>.toml and <file>.cython.toml, we generate a
    config file concatenating them. This is useful when cython just wants
    to avoid generating a file due to crashes or what not.

@emilio
Copy link
Copy Markdown
Collaborator Author

emilio commented Nov 17, 2020

@petrochenkov wdyt?

…cessor.

I _think_ I'm a bit happier with this than the alternative of having to
maintain two .config files.

The main changes:

 * We run the preprocessor on the cbindgen output. This is useful so
   that we can use ifdefs for cython in header/trailers.

 * If there's both <file>.toml and <file>.cython.toml, we generate a
   config file concatenating them. This is useful when cython just wants
   to avoid generating a file due to crashes or what not.
@petrochenkov
Copy link
Copy Markdown
Contributor

I'll look tomorrow.

I've been using the next trick to avoid multiple configs (for #619 in particular):

after_includes = "
#ifdef __FILE__
  something c/c++
#else
  something cython
#endif
"

(__FILE__ must always be defined for both C and C++), but it requires "something c/c++" to start with # (e.g. includes) so it doesn't break Cython.
Perhaps this can be expanded to cover <file>.cython.toml cases as well without running preprocessor.

@petrochenkov
Copy link
Copy Markdown
Contributor

Some alternative methods of solving this can be found in #620.
Perhaps we can land it partially and just keep the few remaining Cython-specific configs.

I'm not too happy about running preprocessor on generated Cython code because it doesn't match workflow used in practice, and could hide things like C-style comments or something, that would fail otherwise.

@emilio
Copy link
Copy Markdown
Collaborator Author

emilio commented Nov 25, 2020

Superseded by #620.

@emilio emilio closed this Nov 25, 2020
@emilio emilio deleted the cython-prepro branch October 21, 2025 21:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants