Skip to content

CI fails because of import errors with C extensions #3910

Closed

Description

@JoaoRodrigues

Opening an issue to discuss how to handle the CI failures we've been having for a little while, that prevent tests from running on multiple platforms. I referenced this issue originally in #3876, and others have hit it too (e.g. #3898).

I tracked down the problem to two separate issues:

  1. There is a piece of code in run_tests.py that inserts ../build/lib.* in sys.path before running the tests. I assume this code is there to allow us running tests without doing pip install. Commenting this code lets the tests run successfully.

  2. With python=3.7, we are running an old version of pip/setuptools that does not create a build/ folder in the repo root. As a result, because of (1) above, we only append the source directory (without the compiled code) to PYTHONPATH and so, any code that needs to import a compiled extension will fail. We can avoid the problem by adding --use-feature=in-tree-build to the pip install command, which is the default behavior for recent versions of pip.

Now, why is this happening all of a sudden? The only thing I can point to is a version change in setuptools:

  • Downloading setuptools-62.0.0-py3-none-any.whl (1.1 MB) on April 8th.
  • Downloading setuptools-62.1.0-py3-none-any.whl (1.1 MB) on April 11th.

I think the reason the Linux runners are not failing (on the main fork, they fail on my fork) is because of a cache issue and the linux-prep CI step.

From this "investigation", we have two options I believe. One is to drop the lines in run_tests.py, which I think we should. We should recommend people to use pip install -e . if they want to constantly monitor changes in the source, although I'm not sure that will work if you make changes to the C extensions. Then again, whoever edits those should know that there be dragons anyway 🐲 :) The second option is to add the --use-feature=in-tree-build to pip while we support python=3.7.

What are your thoughts? @mdehoon @peterjc

PS. We can also consider dropping run_tests.py altogether. I've been a happy user of pytest, which would require some, but not much, intervention to our tests to run since pytest is fully compatible with unittest. To mimic run_tests.py we'd need to add some tags to tests/modules we would like to skip (e.g. --offline option). Biggest advantage of this move would be concurrent test execution (specially on our local machines, since GHA is single-process).

Activity

  1. mdehoon commented on Apr 25, 2022

    @mdehoon
    Contributor

    @JoaoRodrigues I don't have a strong opinion about this, so I'll let you and @peterjc decide.

  2. peterjc commented on Apr 25, 2022

    @peterjc
    Member

    That 'magic' in run_tests.py has been there a very long time, and may have been specifically for the Martel C code (think super regular expressions) Biopython once used? Does anything obviously break for local use and testing if we drop those lines?

    I personally have been using pip install -e . for some time, but rarely if ever touch the C code.

    (Looking at pytest is also worth trying medium term, or sooner if someone has an itch to scratch)

  3. peterjc commented on Apr 25, 2022

    @peterjc
    Member

    The timing does make setuptools look like the most likely cause.

  4. JoaoRodrigues commented on Apr 25, 2022

    @JoaoRodrigues
    MemberAuthor

    Thanks for the comments. As for removing the lines, nothing breaks as far as I see. I'll remove them on my test branch and let CI run to completion to make sure. I'll try running locally again too in a couple different ways. If that passes, I'll remove them and push.

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions