Building a git dependency's Cython extension


I am currently working on a library A with a dependency on a library B which has a small Cython extension. Both are private GitLab repos and for now I’m using git dependencies declared in my pyproject.toml.
When I pip install library A, it pull in library B using the git url, but the Cython extension is not being built by pip so library B is not usable.
I can build library B manually and it work just fine, but ideally I would want pip to pull B and build the Cython extension so that I can install A in a single pip install.

Is that possible? Or is this unwanted behavior? In which case I guess the only option for me is to start publishing wheels on a private package index.
Any help or pointer is welcome :slight_smile:

Why is it not being build? Does pip not even try? Does it fail to get the build dependencies? Does the build itself fail? What backend are you using for project B?

Hi @MegaIng,

Thanks for your quick reply!

I have no idea why it is not being built, I spent some time looking this up on the internet to see if that was the expected behavior of pip but I couldn’t find relevant information.
I just tried it again in a fresh virtual environment with the --no-cache flag to start over cleanly and --verbose to get additional info, but pip does not even try to compile my dependency’s Cython extension.
I also have a Cython extension in library A, and this one is being compiled just fine.

Both projects use setuptools (currently version 69.5.1) as a backend.

Let me know if there is any additional info I might have overlooked that could be useful to understand what is happening.

If you provide it with a source code checkout like a Git repository, pip will always build the package into a temporary wheel then install that wheel[1]. If you don’t find a built extension in the venv after installing, that means setuptools did not build the extension. If that doesn’t happen when you develop package B separately, there might be something fishy in your Can you show us that file?

  1. except if you enable the mode with --no-use-pep-517, which works a bit differently ↩︎

@jeanas oh my god, I am such an idiot…
You were right, there was something wrong with my, I did not check it into source control :man_facepalming:

It all works like it should now, sorry for the inconvenience and thanks to the people who responded!

1 Like