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
opencv migrations #16640
opencv migrations #16640
Conversation
poke @iMichka |
Formula/opencv.rb
Outdated
@@ -0,0 +1,158 @@ | |||
class Opencv3 < Formula |
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.
class should be opencv
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.
And the other one misses AT2
Formula/opencv.rb
Outdated
class Opencv3 < Formula | ||
desc "Open source computer vision library, version 3" | ||
homepage "http://opencv.org/" | ||
revision 1 |
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.
not needed since it's an upgrade 2.4.13.2 -> 3.2.0
Formula/opencv@2.rb
Outdated
@@ -0,0 +1,98 @@ | |||
class Opencv < Formula |
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.
class needs to be opencvat2
d6061a6
to
e2e1c7c
Compare
Formula/opencv.rb
Outdated
depends_on :java => :optional | ||
depends_on :python3 => :optional | ||
|
||
with_python = build.with?("python") || build.with?("python3") |
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.
numpy only has "without" options now so no options should be needed
Formula/opencv@2.rb
Outdated
homepage "http://opencv.org/" | ||
url "https://github.com/opencv/opencv/archive/2.4.13.2.tar.gz" | ||
sha256 "4b00c110e6c54943cbbb7cf0d35c5bc148133ab2095ee4aaa0ac0a4f67c58080" | ||
revision 1 |
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 is technically a new formula
I think the python3 thing is solved by this PR that got abandoned: Homebrew/brew#2499 It tells you to setup your path and stuff to make it work. |
Formula/opencv.rb
Outdated
sha256 "8a067e3e026195ea3ee5cda836f25231abb95b82b7aa25f0d585dc27b06c3630" | ||
end | ||
|
||
def arg_switch(opt) |
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 is not idiomatic in core
Formula/opencv@2.rb
Outdated
depends_on :java => :optional | ||
depends_on :ant if build.with? "java" | ||
|
||
def arg_switch(opt) |
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 is not idiomatic in core
Formula/opencv.rb
Outdated
|
||
option :cxx11 | ||
|
||
depends_on :ant => :build if build.with? "java" |
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.
the java option doesn't exist yet up here. it has to be below depends_on :java => :optional
Do we want to consider the update to version 3.3.0 or are we doing this in a separate step? https://github.com/Homebrew/homebrew-science/pull/6078 It removes a bunch of code, which is nice. |
Formula/opencv@2.rb
Outdated
depends_on "ffmpeg" => :optional | ||
depends_on "tbb" => :optional | ||
depends_on :java => :optional | ||
depends_on :ant if build.with? "java" |
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.
should be marked as => :build
Formula/opencv.rb
Outdated
option "with-contrib", 'Build "extra" contributed modules' | ||
option "with-java", "Build with Java support" | ||
option "with-tbb", "Enable parallel code in OpenCV using Intel TBB" | ||
option "without-numpy", "Use a numpy you've installed yourself instead of a Homebrew-packaged numpy" |
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 don't think we need this
Formula/opencv.rb
Outdated
option "without-numpy", "Use a numpy you've installed yourself instead of a Homebrew-packaged numpy" | ||
option "without-python", "Build without Python support" | ||
|
||
option :cxx11 |
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.
can we just make this the default?
Formula/opencv.rb
Outdated
depends_on "ffmpeg" => :optional | ||
depends_on "tbb" => :optional | ||
depends_on :java => :optional | ||
depends_on :python3 => :optional |
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.
can we build with support for both?
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.
There is only one PYTHONPATH; and opencv relies on it. Supporting Python 2 and 3 together broke people's build when using Python 3. This is why there is a check for that somewhere in the formula. But I would be willing to remove it and see what happens.
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.
If we can't support both, I think we need to just pick one. This formula shouldn't be built from source as a matter of course.
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.
Let's try to re-enable both and see what happens :)
Formula/opencv.rb
Outdated
|
||
if build.with? "python3" | ||
# Reset PYTHONPATH, workaround for https://github.com/Homebrew/homebrew-science/pull/4885 | ||
ENV["PYTHONPATH"] = "" |
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'd probably just put ENV.delete("PYTHONPATH") at the beginning of install and leave it at that.
Formula/opencv.rb
Outdated
args << "-DENABLE_AVX2=ON" if Hardware::CPU.avx2? | ||
end | ||
|
||
inreplace buildpath/"3rdparty/ippicv/downloader.cmake", |
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.
what's going on here? has this been reported?
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.
opencv 3.3.0 fixes this. See PR in homebrew science.
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.
We should upgrade to that as part of the same PR.
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.
If 3.3.0 goes in science first that's OK.
Formula/opencv.rb
Outdated
"${OPENCV_ICV_PLATFORM}" | ||
resource("icv-macosx").stage buildpath/"3rdparty/ippicv/downloads/macosx" | ||
|
||
mkdir "macbuild" do |
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.
build
Formula/opencv.rb
Outdated
|
||
mkdir "macbuild" do | ||
system "cmake", "..", *args | ||
system "make" |
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.
does just make install fail?
we should add a formula rename for opencv3 to opencv |
Formula/opencv.rb
Outdated
@@ -0,0 +1,157 @@ | |||
class Opencv < Formula | |||
desc "Open source computer vision library, version 3" | |||
homepage "http://opencv.org/" |
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.
actually does need revision 1 if we're going to do the formula rename from opencv3
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.
We should upgrade to 3.3.0 as part of the same PR, so it won't be needed.
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.
(If 3.3.0 goes in science first that's OK, and then we can revision bump here.)
Formula/opencv.rb
Outdated
end | ||
end | ||
|
||
head do |
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 think we have enough problems with these formulae not to need head.
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.
There are some websites/blog posts out there recommending to build opencv with --head
. Never understood why. But it allowed me to close tens issues just based on the fact that it was head. So +1 on removing it.
Formula/opencv.rb
Outdated
end | ||
end | ||
|
||
option "with-contrib", 'Build "extra" contributed modules' |
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.
feels out of scope since quality control is going to be low
Formula/opencv@2.rb
Outdated
args << "-DENABLE_AVX=ON" if Hardware::CPU.avx? | ||
end | ||
|
||
mkdir "macbuild" do |
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.
build
Formula/opencv@2.rb
Outdated
|
||
mkdir "macbuild" do | ||
system "cmake", "..", *args | ||
system "make" |
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.
does just make install fail
Formula/opencv.rb
Outdated
pythons = build.with?("python3") ? ["with-python3"] : [] | ||
depends_on "numpy" => [:recommended] + pythons if with_python | ||
|
||
# Dependencies use fortran, which leads to spurious messages about gcc |
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.
is this still a thing?
Formula/opencv.rb
Outdated
# Dependencies use fortran, which leads to spurious messages about gcc | ||
cxxstdlib_check :skip | ||
|
||
resource "icv-macosx" do |
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.
can we do without this? It says third party
Formula/opencv.rb
Outdated
depends_on "libtiff" | ||
depends_on "openexr" | ||
depends_on :python => :recommended unless MacOS.version > :snow_leopard | ||
depends_on "ffmpeg" => :optional |
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.
any reason not to make this default on?
1506241
to
ac0fce0
Compare
@BrewTestBot test this please |
@iMichka how do you feel about the current state? are we ready to merge? |
I'll build it locally and give it a quick try, I want to see what happens with the python2/python3 import problems reported in science. I have some time now, so I'll report back to you in 1 or 2 hours. Is there a way to not have the following error:
Can you set the variable to something like |
Also we need a PR in science to remove opencv/opencv3. You closed https://github.com/Homebrew/homebrew-science/pull/5996, so either it needs to be re-opened or a new one needs to be created. |
Ok so I built the formula as is. The formula does not build python2 bindings. This is probably due to this line:
Is this the wanted behaviour? There is an option to build without python2, but this would only be useful under Snow Leopard or older? |
@iMichka that line isn't relevant. It should build the python2 bindings due to
See the The formula probably needs to use The same should be used in the test block. |
@iMichka this is actually working for me:
Both python2 and python3 bindings get built. |
Python2 does not got built: Only the python3 .so gets installed |
You can also see this the configuration section:
It picks up the wrong Python 2 (system python). |
It should say
|
ac0fce0
to
0ff95ed
Compare
|
EOS | ||
system ENV.cxx, "test.cpp", "-I#{include}", "-L#{lib}", "-o", "test" | ||
assert_equal version.to_s, shell_output("./test").strip | ||
assert_match version.to_s, shell_output("python -c 'import cv2; print(cv2.__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.
Can the opencv@2 test block be also run for both Python versions with Language::Python.each_python(build) do |python, _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.
Err no please disregard that comment, it does not have python3 support anyway :)
|
0ff95ed
to
461ed02
Compare
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.
+1 good to go :)
Starting again on opencv migrations.
Open issues that need to be dealt with:
(other issues are old, closed, CUDA-related or do not provide enough information to act upon)