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

Can't install 2.2.2 via brew #32

Open
wuservices opened this issue Jan 3, 2019 · 9 comments

Comments

6 participants
@wuservices
Copy link

commented Jan 3, 2019

I've been trying to fix our install and can't seem to get mopidy installed / running via brew.

Could this be an issue with the newest version?

I've gone through OS X installation instructions a few times trying to repair an existing installation on 10.13, but I also just ran through the steps on a fresh 10.14 system and got the same problem. I've also tried this with and without a PYTHONPATH.

After installing, I try to run mopidy and get this error:

$ mopidy
Traceback (most recent call last):
  File "/usr/local/bin/mopidy", line 6, in <module>
    from pkg_resources import load_entry_point
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources/__init__.py", line 3095, in <module>
    @_call_aside
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources/__init__.py", line 3081, in _call_aside
    f(*args, **kwargs)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources/__init__.py", line 3108, in _initialize_master_working_set
    working_set = WorkingSet._build_master()
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources/__init__.py", line 658, in _build_master
    ws.require(__requires__)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources/__init__.py", line 959, in require
    needed = self.resolve(parse_requirements(requirements))
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources/__init__.py", line 846, in resolve
    raise DistributionNotFound(req, requirers)
pkg_resources.DistributionNotFound: The 'Mopidy==2.2.2' distribution was not found and is required by the application

It appears that the mopidy script is pointing to the system version of Python:

$ head -n 1 `which mopidy`
#!/usr/bin/python

In contrast when I run this on another system, I see that the shebang points to homebrew's version:

$ head -n 1 `which mopidy`
#!/usr/local/opt/python@2/bin/python2.7

I tried to change this path manually to use brew's Python and then had a _gi import error, and tried the steps in #27 (comment) to resolve, but then got another error "ImportError: cannot import name _gi_gst".

I've now tried the installation instructions from scratch on a new clean machine that's never had mopidy and ended up in the same place, so it seems like the installer may be broken.

@tylerball

This comment has been minimized.

Copy link

commented Jan 4, 2019

I'm also experiencing this issue. I tried manually reseting the tap to before 8b0862c and edited the shebang to point to /usr/local/bin/python2 as well and ended up with the same missing gobject error.

@jodal jodal pinned this issue Jan 4, 2019

@korzq

This comment has been minimized.

Copy link

commented Jan 9, 2019

same here

@jodal

This comment has been minimized.

Copy link
Member

commented Jan 9, 2019

I can reproduce the issue but haven't found the time to dig into it yet. There's no obvious changes in the tap that should/could have cause this.

@johnkirstenlai

This comment has been minimized.

Copy link

commented Jan 19, 2019

Same problem here, did someone find a solution?

@johnkirstenlai

This comment has been minimized.

Copy link

commented Jan 22, 2019

Hey, I managed to solve my problem with brew reinstall pygobject pygobject3

@troyxmccall

This comment has been minimized.

Copy link
Contributor

commented Feb 7, 2019

Think I found the root cause: Homebrew-core decided to drop support for formula options. Frustrating for us, but understandable why they did it.

ie, you can't run brew install pygobject3 --with-python@2 or brew install gst-python --without-python --with-python@2 anymore

Homebrew/homebrew-core#36216

Homebrew/homebrew-core#31510

https://discourse.brew.sh/t/maintaining-a-tap-to-provide-options-for-a-formula/3871

@troyxmccall

This comment has been minimized.

Copy link
Contributor

commented Feb 7, 2019

a short-term solution (till we create our own formulas or move away from python2 deps is):

  1. brew uninstall --ignore-dependencies gst-python pygobject3

  2. brew edit gst-python

  3. replace the existing formula with hard-coded python2 references

class GstPython < Formula
  desc "Python overrides for gobject-introspection-based pygst bindings"
  homepage "https://gstreamer.freedesktop.org/modules/gst-python.html"
  url "https://gstreamer.freedesktop.org/src/gst-python/gst-python-1.14.4.tar.xz"
  sha256 "d0fdb24f93b6d889f309d2f526b8ea9577e0084ff0a62b4623ef1aed52e85a1b"
  revision 1

  bottle do
    cellar :any
    sha256 "56c0b40edc95e09d9dd1c57d27a45267a9f86a1e3623eb94137c3b78bc226a5b" => :mojave
    sha256 "89f662099926f9fa540f3d8a89469589bf354dbaf0410adc83a19e9553ede19b" => :high_sierra
    sha256 "99d9576a745ff5fc7818a21bb0ca22232c8cc2a481693105921dd1d9292f30eb" => :sierra
  end

  depends_on "gst-plugins-base"
  depends_on "pygobject3"
  depends_on "python2"

  def install
    python_version = Language::Python.major_minor_version("python2")
    # pygi-overrides-dir switch ensures files don't break out of sandbox.
    system "./configure", "--disable-dependency-tracking",
                          "--disable-silent-rules",
                          "--prefix=#{prefix}",
                          "--with-pygi-overrides-dir=#{lib}/python#{python_version}/site-packages/gi/overrides",
                          "PYTHON=python2"
    system "make", "install"
  end

  test do
    system "#{Formula["gstreamer"].opt_bin}/gst-inspect-1.0", "python"
    # Without gst-python raises "TypeError: object() takes no parameters"
    system "python3", "-c", <<~EOS
      import gi
      gi.require_version('Gst', '1.0')
      from gi.repository import Gst
      print (Gst.Fraction(num=3, denom=5))
    EOS
  end
end
  1. brew edit pygobject3

  2. again, replace the existing formula with hard-coded python2 references

class Pygobject3 < Formula
  desc "GNOME Python bindings (based on GObject Introspection)"
  homepage "https://wiki.gnome.org/Projects/PyGObject"
  url "https://download.gnome.org/sources/pygobject/3.30/pygobject-3.30.4.tar.xz"
  sha256 "2dc1a1a444b82955e65b81c2a2511ecf8032404beba4ef1d48144168f2f64c43"

  bottle do
    cellar :any
    rebuild 1
    sha256 "b2e5a251c6d41ad8b039ea1637c39aabbfa3e055366124c7461f65711e210b68" => :mojave
    sha256 "4ac894ae8761c85bceade1626bd4c7afd1850ad8fceb32cbe2a6a852121a2661" => :high_sierra
    sha256 "b5494a628c4b090acc17a6f7510672ed8e1c9487261bffd386368d1c93f23012" => :sierra
  end

  depends_on "meson" => :build
  depends_on "ninja" => :build
  depends_on "pkg-config" => :build
  depends_on "gobject-introspection"
  depends_on "py2cairo"
  depends_on "python@2"

  def install
    mkdir "buildpy2" do
      system "meson", "--prefix=#{prefix}",
                      "-Dpycairo=true",
                      "-Dpython=python2.7",
                      ".."
      system "ninja", "-v"
      system "ninja", "install"
    end

  end

  test do
    Pathname("test.py").write <<~EOS
      import gi
      assert("__init__" in gi.__file__)
    EOS
    Language::Python.each_python(build) do |python, pyversion|
      ENV.prepend_path "PYTHONPATH", lib/"python#{pyversion}/site-packages"
      system python, "test.py"
    end
  end
end
  1. brew reinstall pygobject3 gst-python -s

-s builds the formula from source vs using bottles

@troyxmccall

This comment has been minimized.

Copy link
Contributor

commented Feb 18, 2019

in addition, if you need to restore the old formulas after the manual edits run
git -C "$(brew --repo homebrew/core)" checkout master

@troyxmccall

This comment has been minimized.

Copy link
Contributor

commented Jun 25, 2019

in the interim while the mopidy team works on the python 3 release, i've provided a workaround to the current 2.2.2 release for homebrew on this fork: https://github.com/troyxmccall/homebrew-mopidy

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.