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

Setup.py -- Argprase, Cmake Args, and caching #40

Merged
merged 11 commits into from
May 10, 2019

Conversation

erikwijmans
Copy link
Contributor

@erikwijmans erikwijmans commented May 9, 2019

Motivation and Context

See #38 and #36 for more context

Rewrite the arg parsing in setup.py to use argparse as this allows for easier extension in the future and gives a nice --help message!

Adds a command line flag for passing arguments to cmake. Note that due to argparse's parsing, cmake args must be assed as --cmake-args="....". Doing --cmake-args "...." (no =) won't work :(
This can be passed to pip via the CMAKE_ARGS environment variable.

Adds caching of arguments passed to setup.py via a simple json file written into the build_temp dir. Arguments can be cached by adding --cache-args to the invocation of setup.py, any current argument cache is ignored. I have blacked listed force_cmake and cache_args from the cache.

@mosra I pointed this PR at your PR as we are both playing with things in setup.py

How Has This Been Tested

Running around and building things.

Types of changes

  • New feature (non-breaking change which adds functionality)

Erik Wijmans and others added 6 commits May 9, 2019 12:03
…#39)

The overloaded setHelp() function led to many accidents where option
help was mistakenly set as global help (as seen here as well), the
overload got renamed to setGlobalHelp() to avoid such mistakes.
@erikwijmans erikwijmans requested review from mosra and msavva May 9, 2019 22:47
@facebook-github-bot facebook-github-bot added the CLA Signed Do not delete this pull request or issue due to inactivity. label May 9, 2019
@erikwijmans erikwijmans changed the title Setup py etw Setup.py -- Argprase, Cmake Args, and caching May 9, 2019
Copy link
Collaborator

@mosra mosra left a comment

Choose a reason for hiding this comment

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

Wonderful 👍 Tried locally with the suggested tiny change and the following command-line

python setup.py --cache-args --no-update-submodules --cmake-args="-DUSE_SYSTEM_PYBIND11=ON -DUSE_SYSTEM_ASSIMP=ON -DUSE_SYSTEM_GLFW=ON -DUSE_SYSTEM_MAGNUM=ON -DUSE_SYSTEM_EIGEN=ON" build_ext --build-temp=build-test --parallel=3

and everything went as expected. Caching for subsequent builds working well too, so the following invocation was enough next time:

python setup.py build_ext --build-temp=build-test --parallel=3

I assume the build_ext options can't be cached that easily, right? This is already more than good enough, tho, thanks for that.

setup.py Outdated Show resolved Hide resolved
Fix builder args

Co-Authored-By: Vladimír Vondruš <mosra@centrum.cz>
@erikwijmans
Copy link
Contributor Author

I’ll think about if there’s an easy way to cache the build_ext options.

One thing you can do is add those to the setup.cfg as build_ext will read args from there also.

@erikwijmans
Copy link
Contributor Author

Give that a try. I also made --build-temp=build the default as that is nicer for helping people debug things.

@erikwijmans erikwijmans requested a review from mosra May 10, 2019 17:56
Copy link
Collaborator

@mosra mosra left a comment

Choose a reason for hiding this comment

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

Works wonders! Thank you.

@mosra mosra mentioned this pull request May 10, 2019
11 tasks
Copy link
Collaborator

@msavva msavva left a comment

Choose a reason for hiding this comment

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

LGTM 👍 Should do wonders to improve the build experience!

@erikwijmans erikwijmans merged commit fdc057e into setup-py-improvements May 10, 2019
@erikwijmans erikwijmans deleted the setup-py-etw branch May 10, 2019 21:59
mosra added a commit that referenced this pull request May 13, 2019
* setup.py: option to don't run git submodule update if modules already exist.

* setup.py: make it possible to *reduce* the amount of jobs.

* Setup.py -- Argprase, Cmake Args, and caching (#40)

* Argparse
* --cmake-args
* Caching of arguments to build_ext and argparse
Ram81 pushed a commit to Ram81/habitat-web-sim that referenced this pull request Dec 10, 2020
* setup.py: option to don't run git submodule update if modules already exist.

* setup.py: make it possible to *reduce* the amount of jobs.

* Setup.py -- Argprase, Cmake Args, and caching (facebookresearch#40)

* Argparse
* --cmake-args
* Caching of arguments to build_ext and argparse
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed Do not delete this pull request or issue due to inactivity.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants