Skip to content

Avoiding source-tree imports during CIBW_TEST_COMMAND #1534

@joerick

Description

@joerick

Continuing from #1530 (reply in thread)

It seems that pytest defaults to 'prepend' import mode, meaning that for a source tree without a /src folder, like this

  • mymodule
    • __init__.py
    • main.py
    • extension.c
  • tests
    • test_main.py

Even when invoked as cibuildwheel does, with the wheel installed in a venv, with cwd as a random temp dir, the mymodule folder in the source tree is higher in the import order than the installed wheel.

This is a pity, the intention of changing the cwd during the test-command was to prevent this problem. I'm trying to think if there's a way that cibuildwheel can work around this...? Obviously the /src structure is best, but we can't mandate that for all cibuildwheel projects.

Another thing that I do wonder is if it's even worth changing the cwd for the test-command given this pytest default - it's a common gotcha within cibuildwheel, and if the above is universally true it's not even helping...!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions