-
-
Notifications
You must be signed in to change notification settings - Fork 182
Allow building CPython from a local source directory #236
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
Conversation
"%s_VERSION" | ||
% entry.upper() | ||
.replace("-", "_") | ||
.replace(".", "_"): DOWNLOADS[entry]["version"], | ||
"%s_VERSION" % entry.upper().replace("-", "_").replace(".", "_"): DOWNLOADS[ | ||
entry | ||
]["version"], |
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.
Sorry, some of these look like format-on-save. I can revert.
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.
I thought I had black formatting on for all the Python files in this repo. It is possible I haven't picked up a modern version of black yet.
I'd welcome PRs to integrate ruff :)
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.
I'll open a pull request to add Ruff :D
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.
This approach seems pretty reasonable.
A potential alternative worth considering is using the docker -v
functionality to bind mount the source checkout into the build environment. You would need to hack up build-cpython.sh
to copy the source files into the /build
directory. I think always normalizing to a source archive makes a lot of sense.
I agree it would be nice to have smarter version resolution or Git (both local and remote repo) integration. But those could be added later.
I'm sure you figured this out, but the build-main.py
script and the way we use PYBUILD_*
environment variables to thread state around is super hacky. Evolved complexity. If you have ideas for simplifying, I'm all ears. Maybe we could integrate rye or uv to make bootstrapping the build environment simpler?
"%s_VERSION" | ||
% entry.upper() | ||
.replace("-", "_") | ||
.replace(".", "_"): DOWNLOADS[entry]["version"], | ||
"%s_VERSION" % entry.upper().replace("-", "_").replace(".", "_"): DOWNLOADS[ | ||
entry | ||
]["version"], |
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.
I thought I had black formatting on for all the Python files in this repo. It is possible I haven't picked up a modern version of black yet.
I'd welcome PRs to integrate ruff :)
This comment was marked as outdated.
This comment was marked as outdated.
@indygreg I'm blocked by #238 on verifying that we can use this new flag in Linux, but I made sure everything works in CI in my fork.
Yeah the normalization makes sense to me for now. It's not really a bottleneck.
I can open issues to track those.
I'm not ready to make any drastic changes, but I'll keep it in mind. I actually didn't think it was too bad.
Honestly I was impressed by your bootstrapping :) I'd definitely be willing to add |
Just to check in here again, is there something you are looking for before this can be merged? Should I just stack another pull request that starts to make use of this? Since |
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.
This looks good. I'm waiting for it to pass CI (I pushed a branch out-of-band) before I merge.
As a first step towards #139, adds the ability to build from a local source directory instead of downloading CPython from
python.org
via a new--python-source <path>
build option.e.g. tested by cloning CPython at tag
v3.12.1
then buildingI also tested this with the latest commit on the CPython
3.12
branch.There are a lot of assumptions about build information being available in the
DOWNLOADS
file, which makes this a little brittle. I also only implemented this for Unix.I tried to make as minimal of a change as possible i.e. instead of refactoring to allow an unpacked source directory to be passed around we put the given source in an archive simulating a download. We could follow this with some more changes to abstract Python source downloads.
Additional safeguards could be added to avoid common mistakes, like ensuring that:
PYBUILD_PYTHON_VERSION
version is compatible with the--python
version--python-source
path exists--python-source
paths are resolved based on the original invocation working directoryAdditionally, we could improve usability by:
PYBUILD_PYTHON_VERSION
from the source filesNext steps for testing in-progress CPython builds would involve: