Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use build instead of pip wheel? #126

Open
dhellmann opened this issue Jul 3, 2024 · 6 comments
Open

use build instead of pip wheel? #126

dhellmann opened this issue Jul 3, 2024 · 6 comments
Labels
enhancement New feature or request

Comments

@dhellmann
Copy link
Member

Revisit the decision to use pip wheel to build wheels. The build command supports a --no-isolation flag, which should prevent installing anything and give the same protection that flag does when running pip.

What was it that led us to switch from build to pip?

@dhellmann
Copy link
Member Author

Switching back to build might also let us change the way we build sdists by default.

@tiran
Copy link
Collaborator

tiran commented Jul 8, 2024

+1 build is the recommended tool to create sdists and wheels.

One remark about --no-isolation. build does not install any build dependencies when the flag is passed. All build dependencies from pyproject.toml must be installed manually.

@dhellmann dhellmann added the enhancement New feature or request label Jul 14, 2024
@tiran
Copy link
Collaborator

tiran commented Sep 19, 2024

We have to switch to build so we can build matplotlib with system packages. A bug in pip prevents us from passing multiple arguments to pip wheel

https://matplotlib.org/stable/install/dependencies.html#use-system-libraries

python -m pip install \
  --config-settings=setup-args="-Dsystem-freetype=true" \
  --config-settings=setup-args="-Dsystem-qhull=true" \
  .

https://meson-python.readthedocs.io/en/stable/how-to-guides/config-settings.html

Please note that, while pypa/build concatenates arguments for the same key passed to the -C option, pip up to version 23.0.1 does not offer any way to set a build config setting to a list of strings: later values for the same key passed to --config-settings override earlier ones.

This effectively limits the number of options that can be passed to each command invoked in the build process to one. This limitation is tracked in pip issue #11681. This limitation should be removed in the next version of pip.

tiran added a commit to tiran/fromager that referenced this issue Sep 19, 2024
Implements a seeder plugin that extends the seed function of virtualenv.
The plugin allows us to seed the `build` package into a new virtual env
and work around missing `setuptools` and `wheel` commands in Python
3.12+ virtual envs.

Related: python-wheel-build#126
Signed-off-by: Christian Heimes <[email protected]>
@dhellmann
Copy link
Member Author

We have to switch to build so we can build matplotlib with system packages. A bug in pip prevents us from passing multiple arguments to pip wheel

Good to know. matplotlib isn't likely to be a priority for a while, but this definitely motivates a move.

tiran added a commit to tiran/fromager that referenced this issue Sep 20, 2024
Implements a seeder plugin that extends the seed function of virtualenv.
The plugin allows us to seed the `build` package into a new virtual env
and work around missing `setuptools` and `wheel` commands in Python
3.12+ virtual envs.

The seeder plugin uses bundled wheel files just like `virtualenv` and
`ensurepip`.

Related: python-wheel-build#126
Signed-off-by: Christian Heimes <[email protected]>
tiran added a commit to tiran/fromager that referenced this issue Sep 20, 2024
Implements a seeder plugin that extends the seed function of virtualenv.
The plugin allows us to seed the `build` package into a new virtual env
and work around missing `setuptools` and `wheel` commands in Python
3.12+ virtual envs.

The seeder plugin uses bundled wheel files just like `virtualenv` and
`ensurepip`.

Related: python-wheel-build#126
Signed-off-by: Christian Heimes <[email protected]>
@tiran
Copy link
Collaborator

tiran commented Sep 23, 2024

We had an internal discussion how Fromager is going to bootstrap the build command into the build environment. @dhellmann and @shubhbapna had objections against my initial solution. My plan was to bundle build wheel with Fromager and use a virtualenv seeder plugin to inject it into the build environments, #435.

After more investigation (code digging), I found an even better, simpler, and faster way. Instead of installing the build package into our build envs, we can install it with Fromager and use its Python API. We no longer need to execute $VIRTUAL_ENV/bin/python -m build in a subprocess. The build API lets us run the hooks with a custom interpreter and runner instead: build.BuildEnv(python_executable="$VIRTUAL_ENV/bin/python"). https://build.pypa.io/en/stable/api.html#build.ProjectBuilder

@shubhbapna
Copy link
Collaborator

The build API lets us run the hooks with a custom interpreter and runner instead: build.BuildEnv(python_executable="$VIRTUAL_ENV/bin/python"). https://build.pypa.io/en/stable/api.html#build.ProjectBuilder

I like this idea!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants