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

sonata on OS X #67

Open
z--m-n opened this issue Aug 17, 2014 · 8 comments
Open

sonata on OS X #67

z--m-n opened this issue Aug 17, 2014 · 8 comments

Comments

@z--m-n
Copy link

z--m-n commented Aug 17, 2014

Sonata seems to work fine on OS X with homebrew. I did have to change one line of code to make it work (see below). My notes:

  1. Installed the Sonata dependencies:

    brew install mpd
    brew install python3
    brew install gtk+3
    brew install --with-python --with-python3 pygobject3
    pip3 install python-mpd2

    On 2014-08-17 this added (with a lot of dependencies):

    mpd 0.18.12
    python 3.4.1
    gtk+3 3.12.2
    pygobject3 3.12.2
    python-mpd2 0.5.3
  2. Created a ~/.mpdconf file and restarted mpd.

  3. Downloaded sonata from github. On first try, ./run-sonata exits with an error:

    File "/path-to-sonata/sonata/launcher.py", line 106, in run
      locale.bindtextdomain('sonata', locales_path)
    AttributeError: 'module' object has no attribute 'bindtextdomain'

    In sonata/launcher.py

    locale.bindtextdomain('sonata', locales_path)

    was changed to

    gettext.bindtextdomain('sonata', locales_path)
  4. After this, ./run-sonata exits with a different error (not related to sonata):

    (run-sonata:99034): GLib-GIO-ERROR **: Settings schema 'org.gtk.Settings.FileChooser' is not installed

    Perhaps we only need the last line, but I ran the following three commands:

    brew install gsettings-desktop-schemas
    glib-compile-schemas /usr/local/Cellar/gtk+3/3.12.2/share/glib-2.0/schemas/
    export GSETTINGS_SCHEMA_DIR=/usr/local/Cellar/gtk+3/3.12.2/share/glib-2.0/schemas/

    Then ./run-sonata.py launched on OS X (Mavericks) and connected to the local mpd server -- made my day!

  5. As final touch: made a launcher app using the Applescript Editor, by saving the lines below as "Application" and updating the icon to something recognisable. (Note: any updates to gtk will need updates to the script)

    tell application "Terminal"
     do script "export GSETTINGS_SCHEMA_DIR=/usr/local/Cellar/gtk+3/3.12.2/share/glib-2.0/schemas/; /path-to-sonata/run-sonata ; exit"
    end tell
multani added a commit that referenced this issue Sep 3, 2014
It doesn't work on OSX (per #67) and even so, the documentation says it
should not be used unless in specific cases, which we are not
considering in Sonata.

For more information, see
https://docs.python.org/3/library/locale.html#access-to-message-catalogs
@multani
Copy link
Owner

multani commented Sep 3, 2014

Hi,
thanks for the feedback! I changed the .bindtextdomain() call to use the function from gettext instead of locale. I don't know why it doesn't work on OS X, but it sems to be better like this anyway.

I'l be glad to add the launcher you made into the repository, it can be installed while doing python setup.py install, but I have no OS X, so I can't really do anything for it.
The export GSETTINGS_SCHEMA_DIR line you have in your script can be removed and suposed to be in the profile initialisation script instead, I believe it's also useful for other GTK applications.

@ahti
Copy link

ahti commented Sep 6, 2014

In the applescript, you can replace /usr/local/Cellar/gtk+3/3.13.2 with /usr/local/opt/gtk+3. Then it won't need to be changed when gtk+3 is updated.

@multani
Copy link
Owner

multani commented Sep 7, 2014

What if Gtk is installed somewhere else, like the user's own directory?
I still think it doesn't have to be in this script and should be set
outside, in the user environment...

@z--m-n
Copy link
Author

z--m-n commented Sep 16, 2014

Hi,
thanks for the suggestion, ahti. Indeed the better path to use for gtk+3 installed with homebrew.

I agree with multani that env settings should not be part of a launcher script/app, certainly not this static. On OS X, Gtk+3 could easily be installed elsewhere, already by using different package manager than homebrew.

On my system GSETTINGS_SCHEMA_DIR is not set by default (not in .bashrc). I did not add it, because I am not sure if other applications require a different path.

If the goal is an OS X launcher, some thoughts:

  1. The apple script code above is a rough startpoint. In my case a terminal window (with bash) sets the path to homebrew installed libraries before launching sonata. The terminal window stays open with command line output for sonata/gtk+3. This is not a very pretty solution.
  2. OS X applescript does have a shell command, which I think would not start a terminal window, but it lacks the needed environment vars and path settings. I have not looked into working with this yet.
  3. I am new to OS X, but I see apps being installed as a single zip file with pretty much every dependency contained within it. Perhaps this is the OS X way to go?

I hope an experienced OS X developer reads this and can suggest a better way to launch (or package) sonata on OS X.

@ahti
Copy link

ahti commented Nov 14, 2014

Just found this way back in my inbox, sorry for taking so long to respond.

Setting the GSETTINGS_SCHEMA_DIR in .bashrc, .profile, etc. would not work since on OSX, those do not affect the environment of applications launched by the Finder.

As you said, a single .app that contains all dependencies is indeed the way most GUI applications are distributed. I am not very experienced with python, but a quick google-search turned up py2app. Another hurdle is that OSX does not come with Python 3, so that might have to be bundled as well as gtk, etc.

@multani
Copy link
Owner

multani commented Mar 1, 2015

As mentionned in #75, removing locale.bindtextdomain as I did in 2c533b3 actually prevents Gtk to translate the dialogs.
I don't have access to OS X so I can't really test this but there should be a way to have everything to work on all platform. Is any of you guys can try to get this locale.bindtextdomain function to work?

@kurisuke
Copy link
Collaborator

kurisuke commented Mar 1, 2015

It seems the bindtextdomain() function ist actually not provided by the OSX libc, which seems to be perfectly acceptable behaviour, as it is specific to GNU gettext.. I will update push request #75 to check whether the function is actually available in the locale module (hasattr). But I still have no idea how to ensure translation of the glade dialogs on OSX, as I don't have access to this platform.

@Cimbali
Copy link

Cimbali commented Mar 4, 2017

See this SO post for an OSX solution. Still requires gettext as a dependency.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants