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

Move management of calls of "cmake --build" to setup_helper/cmake.py and refactor as a CMake class #21493

Closed
wants to merge 2 commits into from

Conversation

xuhdev
Copy link
Collaborator

@xuhdev xuhdev commented Jun 6, 2019

No description provided.

@pytorchbot pytorchbot added the module: build Build system issues label Jun 6, 2019
@xuhdev xuhdev changed the title Move management of calls of "cmake --build" to setup_helper/cmake.py Move management of calls of "cmake --build" to setup_helper/cmake.py and refactor Jun 7, 2019
@xuhdev xuhdev changed the title Move management of calls of "cmake --build" to setup_helper/cmake.py and refactor Move management of calls of "cmake --build" to setup_helper/cmake.py and refactor as a CMake class Jun 7, 2019
@zou3519 zou3519 added the triaged This issue has been looked at a team member, and triaged and prioritized into an appropriate module label Jun 7, 2019
@zou3519 zou3519 requested a review from kostmo June 7, 2019 15:22
Copy link
Collaborator

@peterjc123 peterjc123 left a comment

Choose a reason for hiding this comment

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

Sorry for the late review. I didn't get why do we need this refactor? Could you explain this a little bit?

tools/build_pytorch_libs.py Outdated Show resolved Hide resolved
tools/setup_helpers/cmake.py Outdated Show resolved Hide resolved
tools/setup_helpers/cmake.py Outdated Show resolved Hide resolved
tools/setup_helpers/cmake.py Outdated Show resolved Hide resolved
tools/setup_helpers/cmake.py Outdated Show resolved Hide resolved
tools/setup_helpers/cmake.py Outdated Show resolved Hide resolved
tools/setup_helpers/cmake.py Show resolved Hide resolved
tools/setup_helpers/cmake.py Outdated Show resolved Hide resolved
@peterjc123 peterjc123 requested a review from ezyang June 10, 2019 03:44
@ezyang
Copy link
Contributor

ezyang commented Jun 10, 2019

Yeah, it would be really helpful to know the motivation behind the refactor. I personally think that one of our big antipatterns is how long our cmake invocations are; we really should strive to have as few arguments to cmake as possible (and not make it easier to add more and more arguments.)

@xuhdev
Copy link
Collaborator Author

xuhdev commented Jun 10, 2019

The purpose of this PR is a step toward better integration of the Python setup scripts and CMake. Ultimately, I would like to allow build options to be directly specified using options specified in CMakeLists.txt (without explicitly being processed in Python setup scripts), allow users to adjust build options directly via cmake-gui/ccmake/editing CMakeCache.txt (currently users must take care of both options in CMakeCache.txt and environmental variables passed to setup.py and ensure they are consistent upon rebuild), and remove a lot of system and library environment checks in Python setup scripts while CMake can already handle them pretty well.

This PR makes it easier to manage CMake related code in Python setup scripts and paves a path towards these objectives. A well structured code base is important, because the next step is probably to look at one build option at a time PyTorch currently explicitly supports in setup.py.

@ezyang I agree with you that there are many issues with current cmake invocation. The objective I described above subsumes many cmake invocation issues, because only what users have specified will be sent to CMake as arguments.

@xuhdev
Copy link
Collaborator Author

xuhdev commented Jun 10, 2019

@ezyang I should also stress that to address the long CMake invocation argument list, as stated above, I have to look into each build option one at a time. I would focus on those once we have some basic structure in Python setup scripts better organized.

@xuhdev xuhdev force-pushed the build/cmake-build branch 2 times, most recently from 15d46b9 to ae57b23 Compare June 10, 2019 21:08
@zdevito zdevito removed their request for review June 11, 2019 04:25
Copy link
Collaborator

@peterjc123 peterjc123 left a comment

Choose a reason for hiding this comment

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

LGTM, waiting for @ezyang's response

Copy link
Contributor

@ezyang ezyang left a comment

Choose a reason for hiding this comment

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

OK sure.

@ezyang
Copy link
Contributor

ezyang commented Jun 11, 2019

Things that you don't have to do this PR, but to think about for the future as you keep working on this code (a lot of these are preexisting conditions):

Python nits:

  1. More docs: for every function, write a docblock that explains what the expected type and semantics of each argument
  2. Let's try to use keyword arguments for long argument lists, like the invocation of CMake.generate

General design thoughts:

  1. For BC reasons, we do need to keep supporting passing environment variables to invocations of setup.py (also, it is the easiest way to make setup.py invocations configurable in any case), so it will be worth thinking what the terminal state of the code will be, given this constraint.
  2. We should figure out some sort of CI-based testing strategy for direct cmake invocation after the fact. Maybe something as simple as running ninja after setup.py and expecting this to be no-op.

Copy link
Contributor

@facebook-github-bot facebook-github-bot left a comment

Choose a reason for hiding this comment

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

@ezyang is landing this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

@facebook-github-bot
Copy link
Contributor

@ezyang merged this pull request in 646a7f9.

@xuhdev xuhdev deleted the build/cmake-build branch June 11, 2019 17:38
@xuhdev
Copy link
Collaborator Author

xuhdev commented Jun 11, 2019

@ezyang Thanks! Will keep these in mind.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Merged module: build Build system issues open source triaged This issue has been looked at a team member, and triaged and prioritized into an appropriate module
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants