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

modularize handle_requirement #453

Merged

Conversation

shubhbapna
Copy link
Collaborator

fixes #452

This is essentially a one-to-one refactor of sdist module and breaks down handle_requirement to multiple functions (no logic change). This is to help with #343

@mergify mergify bot added the ci label Sep 26, 2024
@shubhbapna shubhbapna marked this pull request as draft September 26, 2024 22:59
@shubhbapna shubhbapna force-pushed the modularize-handle-requirement branch from 4029933 to fbfc377 Compare September 27, 2024 15:09
Comment on lines 101 to 125
self.ctx.add_to_build_order(
req=req,
version=resolved_version,
source_url=source_url,
source_url_type=source_url_type,
prebuilt=pbi.pre_built,
constraint=constraint,
)
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I moved this to after building of wheels because:

  • We have graph.json that as already recorded this dependency
  • if the build fails then anyways bootstrapping stops and we don't end up using that build order file

@shubhbapna shubhbapna marked this pull request as ready for review September 27, 2024 15:23
src/fromager/bootstrapper.py Outdated Show resolved Hide resolved
src/fromager/bootstrapper.py Outdated Show resolved Hide resolved
src/fromager/bootstrapper.py Outdated Show resolved Hide resolved
src/fromager/bootstrapper.py Outdated Show resolved Hide resolved
src/fromager/bootstrapper.py Outdated Show resolved Hide resolved
@shubhbapna shubhbapna force-pushed the modularize-handle-requirement branch from fbfc377 to f13515e Compare October 2, 2024 15:44
@shubhbapna shubhbapna requested a review from tiran October 2, 2024 15:44
@shubhbapna shubhbapna force-pushed the modularize-handle-requirement branch from f13515e to 7d0dab3 Compare October 2, 2024 19:11
Copy link
Contributor

@rd4398 rd4398 left a comment

Choose a reason for hiding this comment

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

Looks good to me !
Nice work with the Boostrapper class!

logger = logging.getLogger(__name__)


class Bootstrapper:
Copy link
Member

Choose a reason for hiding this comment

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

With this new class, maybe some of the things we have in the context, like managing the build order file and graph, should move here? Or their own classes used by the bootstrapper? Those would definitely be changes for other PRs.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I think the graph is accessed in other commands as well. Maybe I can try to move build order stuff, mark_as_seen and has_been_seen

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

okay moved these to the bootstrapper class

Comment on lines +207 to +246
build_system_dependencies = dependencies.get_build_system_dependencies(
ctx=self.ctx, req=req, sdist_root_dir=sdist_root_dir
)
self._handle_build_requirements(
RequirementType.BUILD_SYSTEM,
build_system_dependencies,
)

build_backend_dependencies = dependencies.get_build_backend_dependencies(
ctx=self.ctx, req=req, sdist_root_dir=sdist_root_dir
)
self._handle_build_requirements(
RequirementType.BUILD_BACKEND,
build_backend_dependencies,
)

build_sdist_dependencies = dependencies.get_build_sdist_dependencies(
ctx=self.ctx, req=req, sdist_root_dir=sdist_root_dir
)
self._handle_build_requirements(
RequirementType.BUILD_SDIST,
build_sdist_dependencies,
)
Copy link
Member

Choose a reason for hiding this comment

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

This repetition has always bothered me, but it was never a big enough of an issue to clean up. Maybe that's another MR, to use a loop here.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Refactored it let me know if the current version is better

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

nevermind the refactor caused some e2e tests to fail so maybe it is better suited for a seperate PR

) -> None:
self.progressbar.update_total(len(build_dependencies))

for dep in self._sort_requirements(build_dependencies):
Copy link
Member

Choose a reason for hiding this comment

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

Why sort here? Were we doing that before?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yep

Copy link
Member

Choose a reason for hiding this comment

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

It might be unfortunate to lose the git history of this file. I don't know if git is smart enough to recognize that the new bootstrapper.py is mostly the same content, in a different format. One way to deal with that would be to include a commit in this PR that renames sdist.py to bootstrapper.py, and then make all of the edits in a second commit. I wouldn't expect the tests to pass on that rename commit.

I could also be overthinking it, so let's see what other reviewers think.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Why would we like to preserve the history of this file?

Copy link
Member

Choose a reason for hiding this comment

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

Maybe I'm a packrat.

I like to be able to see the evolution of code, even if that means spanning files sometimes. It's not the end of the world to not have it.

@shubhbapna shubhbapna force-pushed the modularize-handle-requirement branch from 7d0dab3 to f6ae08a Compare October 17, 2024 04:22
Signed-off-by: Shubh Bapna <[email protected]>
@shubhbapna shubhbapna force-pushed the modularize-handle-requirement branch from f6ae08a to f9cfba2 Compare October 17, 2024 04:28
@mergify mergify bot merged commit 70e212e into python-wheel-build:main Oct 17, 2024
71 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

modularize handle_requirement in the sdist module
4 participants