I am trying to build a package in a CI workflow using the build
package. By default the build
package does the build in an isolated environment. My problem is that, in my CI workflow, I need certain credential for the pip repository I am using. The isolated build environment does not inherit those credentials and is, thus, unable to install the build dependencies.
My workaround is to use python3 -m build --no-isolation
and manually install the dependencies from pyproject.toml
[build-system][requires]
into the local environment. This works but requires the [build-system][requires]
dependencies to be manually copied into the CI script. And there is an opportunity for divergence is the [build-system][requires]
changes but the CI script doesn’t.
ChatGPT gave me idea/code to do something like
$(python -c "import toml; print(' '.join(toml.load('pyproject.toml')['build-system']['requires']))")
to use python to read the dependencies. I could then store the result into a variable and use that variable in a pip install process. But this feels hacky/fragile. ChatGPT didn’t give me ideas that I found better than this.
Is there a better way to accomplish my goal using build
? I haven’t looked into hatch
or poetry
or any other build tools but it would be frustrating if this is the one thing that would make me prefer one of those since they seem unnecessarily heavyweight for what I’m trying to do.