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

Improve error message when python 3 not available - Fix for #1385 #1392

Merged
merged 7 commits into from Apr 27, 2020

Conversation

lkarthee
Copy link
Contributor

#1385

In this PR, I have made python optional in CMakeLists.txt . I have tested locally by bumping the required version to 3.8 which is not existing on my Mac.

I have noticed that the below tests are run from python file - test/run-c-api-examples.py.

  • c_api_example(callback)
  • c_api_example(finalize)
  • c_api_example(global)
  • c_api_example(hello)
  • c_api_example(hostref)
  • c_api_example(multi)
  • c_api_example(memory)
  • c_api_example(reflect)
  • c_api_example(serialize)
  • c_api_example(start)
  • c_api_example(table)
  • c_api_example(trap)

Do we need to port run-c-api-examples.py to gtest file or cpp file?

@sbc100
Copy link
Member

sbc100 commented Apr 22, 2020

Can't you already do this by building with -DBUILD_TESTS=OFF?

wabt's primary test runner ./test/run-tests.py is also written in python. If you don't have python the only possible tests you could run are the gtest unittests and i'm not sure it worth the extra option to allow just those tests to build built.

@sbc100
Copy link
Member

sbc100 commented Apr 22, 2020

Also, if you do want to run tests, isn't it easy install python3 on mac?

@lkarthee
Copy link
Contributor Author

Installing python3 is easy. I use pyenv to manage python versions. I wanted to contribute to this project, so I picked up #1385 with good-first-bug tag.

To test this PR I used a python version 3.8 which is not installed in my MacBook as I don't have Windows as mentioned in #1385.

All 5 CI checks have python3 enabled and run python tests - they won't test the scenario where python3 is not installed.

@sbc100
Copy link
Member

sbc100 commented Apr 22, 2020

Would you mind instead improving the error message, e.g. "python3 is required to for wabt testing, please either install it or build with -DBUILD_TESTS=OFF".

@lkarthee
Copy link
Contributor Author

I will modify the PR accordingly.

@lkarthee lkarthee changed the title making python optional for build - Fix for #1385 Improve error message when python 3 not available - Fix for #1385 Apr 23, 2020
@lkarthee
Copy link
Contributor Author

I have made required changes. See sample error message (ignore exact versions like 3.7.3 and 3.8 in the error message).

-- Could NOT find PythonInterp: Found unsuitable version "3.7.3", but required is at least "3.8" (found /usr/bin/python3)
CMake Error at CMakeLists.txt:587 (message):
  Python 3 is required for wabt testing.  Please install it.

  If you want to proceed without installing python 3, either add -no-tests to
  make target (example: make clang-debug-no-tests) or run cmake with
  -DBUILD_TESTS=OFF.


-- Configuring incomplete, errors occurred!

CMakeLists.txt Outdated
endif ()
else()
message(FATAL_ERROR "Python 3 is required for wabt testing. Please install it. \nIf you want to proceed without installing python 3, either add -no-tests to make target (example: make clang-debug-no-tests) or run cmake with -DBUILD_TESTS=OFF.")
endif(PYTHONINTERP_FOUND)
Copy link
Member

Choose a reason for hiding this comment

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

Seem like you could just put this error in an if an "if (NOT PYTHONINTERP_FOUND) .. endif()" above that the rest of the file would be left unchanged?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

@aardappel
Copy link
Contributor

Would be better if instead it displayed that warning and then turned tests off for you, rather than failing.
Tests are mostly for contributors to WABT, and should not concern people simply trying to build the binaries.

@binji
Copy link
Member

binji commented Apr 23, 2020

I tend to agree with @aardappel here. @sbc100, does that seem OK to you?

@sbc100
Copy link
Member

sbc100 commented Apr 23, 2020

Fine with me. We can set BUILD_TESTS to false is python is not found.

@sbc100
Copy link
Member

sbc100 commented Apr 23, 2020

Or should we even just have BUILD_TESTS default to OFF?

@binji
Copy link
Member

binji commented Apr 24, 2020

I like having it default to on, personally.

@lkarthee
Copy link
Contributor Author

Should I revert the initial commit of this PR?

  • BUILD_TESTS default is ON (No change in existing code)
  • skip tests when python3 >= 3.5.

@sbc100
Copy link
Member

sbc100 commented Apr 24, 2020

I think the conclusion is:

  1. BUILD_TESTS defaults to ON
  2. BUILD_TESTS gets forced to OFF if python is now found

@lkarthee
Copy link
Contributor Author

lkarthee commented Apr 24, 2020

  • skip tests when python3 >= 3.5.

Got it - Oops typo, it should have been < sign (in my previous comment).

CMakeLists.txt Outdated
@@ -464,6 +464,13 @@ if (NOT EMSCRIPTEN)
)
endif ()

# Python 3.5 is the version shipped in Ubuntu Xenial
find_package(PythonInterp 3.5)
if(NOT PYTHONINTERP_FOUND)
Copy link
Member

Choose a reason for hiding this comment

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

how about AND BUILD_TESTS == ON there?

Otherwise lgtm!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

added this check.

@lkarthee
Copy link
Contributor Author

Cmake prints a message when suitable version is not found. This will appear irrespective of BUILD_TEST is ON or OFF.

When BUILD_TESTS=OFF and python3 not found

.......
-- Check size of size_t - done
-- Could NOT find PythonInterp: Found unsuitable version "3.7.3", but required is at least "3.8" (found /usr/bin/python3)
-- Looking for pthread.h
.......

When BUILD_TESTS=ON and python3 not found

.......
-- Check size of size_t - done
-- Could NOT find PythonInterp: Found unsuitable version "3.7.3", but required is at least "3.8" (found /usr/bin/python3)
CMake Warning at CMakeLists.txt:471 (message):
  Skipping tests.  Python 3 is required for wabt testing.  Please install
  python3 to run tests.


-- Looking for pthread.h
.......

Copy link
Member

@binji binji left a comment

Choose a reason for hiding this comment

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

lgtm, thanks for doing this!

@binji binji merged commit 068f604 into WebAssembly:master Apr 27, 2020
@lkarthee lkarthee deleted the python_check_optional branch May 6, 2020 01:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants