-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Migrate config to pyproject.toml and use uv for project management
#4627
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
Migrate config to pyproject.toml and use uv for project management
#4627
Conversation
Dynamic versioning in pyproject.toml no longer requires filtering version normalization warnings.
The mypy config change was required to check the generated sources in the target dir instead of in the venv.
The python version check will be enforced by `uv` based on the value of pyproject.toml's `requires-python`.
jtraglia
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice 🔥 this looks like a great improvement.
Let's remove some of the excess print statements & look into the linting issue.
|
I believe we need to change this from
|
Good catch, @jtraglia! I'm not sure how good the support is but we can try - added! 07849e3 |
|
Nice, sorry for all of the random feedback! I think this is almost ready to merge 😄 |
No worries, thanks for the fast feedback, it flowed well tbh! Are you happy to squash 😅 I can organize the commits if you like if that's how you do things around here )) |
Yes, we squash all PRs here now! So no need to clean anything up. |
Great! The last commit added a small update to the readme that I forgot to add earlier. |
This hides the following print: Resolved 101 packages in 3ms
jtraglia
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome, this looks great. Thanks again @danceratopz! I'm going to merge this after CI checks pass.
@leolara please follow up post-merge & open a PR if there's anything you'd like to change.
|
Ever since this was merged, File "/opt/homebrew/Cellar/[email protected]/3.13.7/Frameworks/Python.framework/Versions/3.13/lib/python3.13/pickle.py", line 1087, in save_global
raise PicklingError(
"Can't pickle %r: it's not found as %s.%s" %
(obj, module_name, name)) from None
_pickle.PicklingError: Can't pickle <class '_lru.LRU'>: it's not found as _lru.LRU |
|
It doesn't fail when only selecting a single |
|
Thanks for flagging @etan-status! The problem is described here: |
Adds `--reinstall-package=eth2spec` for `uv run` commands used with editable installs. This will ensure that `uv` doesn't used a cached version of `eth2spec` (consensus-specs) and ensure that the most recent version of repo source is used when generating test vectors during local development. Follow-up fix to: - #4627 and, in particular: - #4634
This PR modernizes the project structure by migrating configuration to
pyproject.tomland adds project management viauvand auv.locklockfile.Migrated Python spec generation from custom
setuptoolscommands to a standalone script,./pysetup/generate_specs.py.distutilswithpathlibfor modern path handling.Migrated to
uv-based dependency management with a committed lockfile for reproducible builds.Moved "low-hanging" packaging config from
setup.pyandmypy.iniintopyproject.toml.Updated Makefile to use
uv runwhile maintaining all existing developer-facing targets.Added
uvavailability check to Makefile:Removed Python version script and check;
uvhandles this.Added lockfile verification to
linttarget to catch dependency drifts.Updated CI flows to use the
astral-sh/setup-uvworkflow (docs) with caching and additionally:python-version: '3.13' withpython-version-file: "pyproject.toml"(this will use the latest supported version).cache: 'pip'fromsetup-pythonsteps.Reverted:
Updatedmypyto check the entireeth2specsource tree directly (using--explicit-package-bases) instead of checking only fork-specific packages via-p.Expand to see commands
We run:
instead of:
Benefits
Besides clean-up:
consensus-specscan now use more features ofuv.uv.lock.uvcreates the venv instead ofpython -m venv(which saves ~7s on my machine).The entireeth2specsource tree is now checked viamypy.Breaking Change
Users must install
uvthemselves, preferably viacurl(which allows Python installation anduv self update):curl -LsSf https://astral.sh/uv/install.sh | shAftwards,
makecan be used as before.Todo
FixReverted to previous mypy behavior.mypythe new errors in this PR caused by checkingeth2specsource directly instead of as an installed package-p eth2spec.Suggested Next Steps
I didn't proceed with these changes; I'd suggest tackling them as separate PRs:
eth2specpackage locationtests/core/pyspec/eth2specis very unexpected; we could move this to./src/eth2spec/.setup.pyentirely. This will require a bit of clean-up due to the non-standard location of data directories (which should be nested undereth2spec, I believe). We could move them under./src/eth2spec/resources, for example, and then move the remaining packaging config topyproject.toml._pyspec; only regenerate if they've changed (this ismake's main feature, but we're not using at the mo ;) ).pyproject.toml; it's not strictly needed if we useuv.lockfor dev and is rather restrictive if consensus-specs is ever published/used as a package../pyspecto./src/pyspec(a sibling package; it doesn't need to be published), then add./src/pysetup/generate_specs.pyas an entrypoint under[project.scripts].ruamel.yamlandmarkoneed to be in project deps; if not they could be moved as dependencies to the script.generate_specs.pyas a script (i.e., without running viapython3 -m) might additionally require renaming./pyspec/typingto./pyspec/spec_types.py(for example) to avoid shadowing Python's builtintypingmodule.