Skip to content

Should we allow relative includes? (i.e. #include "../_ssl.h") #121223

Description

@skirpichev

Feature or enhancement

Proposal:

          Can we avoid the relative include? They tend to produce problems further down the road.

Originally posted by @erlend-aasland in #120894 (comment)

There are few more examples:

$ git grep '#include .*\.\.\/'
Include/internal/mimalloc/mimalloc/track.h:#include "../src/prim/windows/etw.h"
Modules/_blake2/blake2b_impl.c:#include "../hashlib.h"
Modules/_blake2/blake2s_impl.c:#include "../hashlib.h"
Modules/_ctypes/callproc.c:#include "../_complex.h"          // complex
Modules/_hacl/internal/Hacl_Hash_MD5.h:#include "../Hacl_Hash_MD5.h"
Modules/_hacl/internal/Hacl_Hash_SHA1.h:#include "../Hacl_Hash_SHA1.h"
Modules/_hacl/internal/Hacl_Hash_SHA2.h:#include "../Hacl_Hash_SHA2.h"
Modules/_hacl/internal/Hacl_Hash_SHA3.h:#include "../Hacl_Hash_SHA3.h"
Modules/_ssl/cert.c:#include "../_ssl.h"
Modules/_ssl/misc.c:#include "../_ssl.h"
Modules/_testinternalcapi/set.c:#include "../_testcapi/util.h"  // NULLABLE, RETURN_INT
Objects/mimalloc/prim/osx/prim.c:#include "../unix/prim.c"
Parser/lexer/lexer.c:#include "../tokenizer/helpers.h"
Parser/tokenizer/file_tokenizer.c:#include "../lexer/state.h"
Parser/tokenizer/file_tokenizer.c:#include "../lexer/lexer.h"
Parser/tokenizer/file_tokenizer.c:#include "../lexer/buffer.h"
Parser/tokenizer/helpers.c:#include "../lexer/state.h"
Parser/tokenizer/helpers.h:#include "../lexer/state.h"
Parser/tokenizer/readline_tokenizer.c:#include "../lexer/lexer.h"
Parser/tokenizer/readline_tokenizer.c:#include "../lexer/state.h"
Parser/tokenizer/readline_tokenizer.c:#include "../lexer/buffer.h"
Parser/tokenizer/string_tokenizer.c:#include "../lexer/state.h"
Parser/tokenizer/utf8_tokenizer.c:#include "../lexer/state.h"
Python/Python-tokenize.c:#include "../Parser/lexer/state.h"
Python/Python-tokenize.c:#include "../Parser/lexer/lexer.h"
Python/Python-tokenize.c:#include "../Parser/tokenizer/tokenizer.h"
Python/Python-tokenize.c:#include "../Parser/pegen.h"      // _PyPegen_byte_offset_to_character_offset()

Has this already been discussed elsewhere?

This is a minor feature, which does not need previous discussion elsewhere

Links to previous discussion of this feature:

No response

Activity

  1. kumaraditya303 commented on Jul 3, 2024

    @kumaraditya303
    Contributor

    Note that mimalloc is copied from upstream, I don't think we should be changing it here.

  2. picnixz commented on Jul 15, 2025

    @picnixz
    Member

    Same for HACL*.

  3. vstinner commented on Aug 5, 2025

    @vstinner
    Member

    It seems like we have multiple C files using relative includes, and I'm not aware of any practical issue, so I suggest to simply closing this issue.

  4. added
    pendingThe issue will be closed if no feedback is provided
    on Aug 5, 2025
  5. skirpichev commented on Aug 5, 2025

    @skirpichev
    MemberAuthor

    @erlend-aasland, could you more elaborate about problems, mentioned in your comment?

  6. erlend-aasland commented on Aug 6, 2025

    @erlend-aasland
    Contributor

    @erlend-aasland, could you more elaborate about problems, mentioned in your comment?

    I don't remember the reason for raising this issue. I'm fine with closing the issue, as Victor suggests.

  7. removed
    pendingThe issue will be closed if no feedback is provided
    on Aug 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    buildThe build process and cross-buildextension-modulesC modules in the Modules dirinterpreter-core(Objects, Python, Grammar, and Parser dirs)type-featureA feature request or enhancement

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions