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

Enforce Python venv usage, install meson and ninja via venv pip #329

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

lhearachel
Copy link
Collaborator

Ubuntu 24.04 ships with Python 3.12 as the default system installation, which enforces PEP 668. The present installation instructions for the project do not wholly account for this nor make it easy for non-savvy users to decide on how to resolve the externally-managed-environment error. The easiest way to resolve it which many users will come across is to run the pip install command with the --break-system-packages switch, which is ill-advised for a whole host of reasons.

The correct path forward, instead, is to enforce usage of meson and ninja via a virtual environment, per recommendations in PEP 668. This change-set:

  1. Adds a new target which will create the virtual environment, defaulting to .venv,
  2. Creates dependencies for the .venv on the targets which build mwrap and $(BUILD)/build.ninja, and
  3. Wraps all invocations of meson and ninja in an implicit venv activate.

As a secondary benefit to this procedure, we now have the full breadth of PyPI at our disposal, should we wish to make use of external dependencies from it in our Python-based tooling. However, this must be met with scrutiny, and we should establish clear guidelines on what dependencies will be permitted as extensions to Python's standard library.

requirements.txt Outdated
@@ -0,0 +1,2 @@
meson >= 1.3.*
Copy link
Collaborator Author

@lhearachel lhearachel Jan 2, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would like for us to evaluate pinning this version requirement to a more recent minor-version, now that we are enforcing installation via a venv managed by the Makefile. I think it may also make sense to have a venv-update target which performs a pip install --update on the requirements.txt list.

It may even make sense for us to fold that into the existing make update target. Thoughts?

@lhearachel lhearachel force-pushed the make-venv branch 5 times, most recently from 3d7fe60 to 1489216 Compare January 2, 2025 03:50
@lhearachel lhearachel marked this pull request as draft January 2, 2025 03:56
@lhearachel lhearachel force-pushed the make-venv branch 8 times, most recently from 8b003d0 to 706bfe0 Compare January 2, 2025 04:38
@lhearachel lhearachel marked this pull request as ready for review January 2, 2025 04:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant