Kara-Moon Forum
March 28, 2024, 05:03:09 PM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News: You can go back to the main site here: Kara-Moon site
 
   Home   Help Search Login Register  
Pages: [1] 2
  Print  
Author Topic: mma-gb should read .mmarc  (Read 5014 times)
sciurius
Sr. Member
****
Posts: 443



« on: November 13, 2020, 07:24:06 AM »

mma-gb does not process the .mmarc. Should it? Maybe...

In my setup, .mmarc adds some additional library locations to $_LibPath. Since mma-gb does not process .mmarc, grooves that are in the additional libraries are not available to mma-gb.

mma-gb should process the .mmarc, but probably it is better to call mma and ask for the actual library locations. Something similar to -Dk.
Logged
bvdp
Kara-Moon Master
****
Posts: 1436


WWW
« Reply #1 on: November 13, 2020, 04:34:19 PM »

Good thought. I've added this to the TODO file for mma. Problems:

  - don't want to duplicate the search/read from mma to mma-gb. Really should keep things like that in one place, and only one place

  - no way, just now, to get mma to report a specific search path. Maybe have a command like "mma -paths" to report?

Anyway, leave it with me and I'll look at it all. Thanks for the idea
Logged

My online life: http://www.mellowood.ca
sciurius
Sr. Member
****
Posts: 443



« Reply #2 on: November 13, 2020, 05:53:37 PM »

This is a close I can get:

Code:
$ echo 'print $_LibPath' | mma -nw -
/home/jv/lib/mma /usr/share/mma/lib

For serious purposes, maybe writing out the complete config (which will still be small) in JSON?
Logged
bvdp
Kara-Moon Master
****
Posts: 1436


WWW
« Reply #3 on: November 13, 2020, 06:43:57 PM »

Of course the big question is "at what point do we grab the config" to print out? After all the config files have been processed or right after the initial setting of paths (which would be before reading a .mmarc file)?
Logged

My online life: http://www.mellowood.ca
sciurius
Sr. Member
****
Posts: 443



« Reply #4 on: November 13, 2020, 10:05:18 PM »

Definitely after processing the .mmarc... That's what started this discussion.
Logged
bvdp
Kara-Moon Master
****
Posts: 1436


WWW
« Reply #5 on: November 14, 2020, 01:47:00 AM »

What do you think of this ...

Add a -x option "Print" which will take all the things passed, expand them, and simply print out the values. So, we could do:
 
    bob$ mma -xprint "\$_libpath \$_incPath"

and, magically, get the values.

Note: the "\" is just to protect the "$" from the shell.

Code (not debugged!) is simple. Just make the end of xtra.py look like this:

 
Code:

    elif opt == "PRINT":
        for a in args:
            for b in a.split():
                #FIXME trap for errors!
                b = MMA.macro.macros.expand([b])
                print(b),
        sys.exit(0)
       
    else:
        error("'%s' is an unknown -x option" % opt)

Next, it's simple to add code to mma-gb to query mma for the needed path info.
Logged

My online life: http://www.mellowood.ca
sciurius
Sr. Member
****
Posts: 443



« Reply #6 on: November 14, 2020, 09:03:08 AM »

This will do the job, for the time being... As long as there are no spaces in path names.

Alternative: --xqvars that takes a list of variables and dumps a json:

Code:
mma --xqvars _libPath,SoundFont,_MMAPath
{ "_libPath" : [ "/home/jv/lib/mma", "/usr/share/mma" ],
  "SoundFont" : "AirFont340",
  "_MMAPath" : [ "/usr/share/mma" ] }

Logged
bvdp
Kara-Moon Master
****
Posts: 1436


WWW
« Reply #7 on: November 14, 2020, 10:41:06 PM »

This is getting quite complicated Smiley The problem is reading the RC file before reporting. MMA really needs some kind of input file and creating one is getting, well, "creative". Much simpler is to:

1. Create a simple MMA file with PRINT lines in it. Simple enough for mma-gb to create a temp file with this (or even do it via stdin)

2. Call mma with the temp filename (or - and send that back, but I'm not sure if that is system independent).

3. Capture the output from the temp file, delete the temp file, process the output and live happily ever after.

If all we need are system variables ($_Libpath, $_mmapath, etc) then we don't need to read any RC files. Simple.

But, if we need to read the RC then mma's insistence on having an input file complicates life. If it were important, I'd certainly do the coding (and generate bugs), but the "read temp file" certainly seems much easier and (?) bullet proof.

Just getting a list of MMA's paths and then have the application read the RCs means that the application needs to know how to read a .mma file Smiley

Comment?
Logged

My online life: http://www.mellowood.ca
sciurius
Sr. Member
****
Posts: 443



« Reply #8 on: November 15, 2020, 02:00:47 PM »

This is getting quite complicated Smiley [...] Much simpler is to:
Agreed.

Quote
If all we need are system variables ($_Libpath, $_mmapath, etc) then we don't need to read any RC files. Simple.
Well, this is what triggered the question. I change LibPath and MMAPath in my .mmarc.

Quote
Just getting a list of MMA's paths and then have the application read the RCs means that the application needs to know how to read a .mma file Smiley

Maybe we should take this back to the drawing board.

Originally MMA was developed to be run from a single place, with a single library of modules and grooves etc.

I am probably the first user to maintain a set of private grooves, plugins, and so on in my home folder.

A first complication is that when I run mma -g it complains about me not having write access to the system files (e.g. /usr/share/mma). That is okay, but what I usually want is to update the .mmaDB files in my home folder. So it would be nice if MMA would skip the system folders. So instead of enumerating all files that were skipped:
Code:
     Processing library directory '/usr/share/mma/lib'.
     Skipping '/usr/share/mma/lib', no write access.
     Processing library directory '/usr/share/mma/lib/kara'.
        Skipped: /usr/share/mma/lib/kara/2beatp.mma
        Skipped: /usr/share/mma/lib/kara/8beatmotown.mma
        ...
     Skipping '/usr/share/mma/lib/kara', no write access.
     Processing library directory '/usr/share/mma/lib/pflib'.
        Skipped: /usr/share/mma/lib/pflib/16beat1.mma
        Skipped: /usr/share/mma/lib/pflib/16beat2.mma
        ...
Error: <Line 36>  You probably need to be 'root' to properly update your libraries.

just a simple

Code:
     Processing library directory '/usr/share/mma/lib'.
     Skipping '/usr/share/mma/lib', no write access.

To get back to the mma-gb issue: Maybe introduce two environment variables MMA_LIBRARY (or MMA_LIBPATH) and MMA_PLUGINS (MMA_PLUGPATH) that take a list of directories to be prepended to $_LibPath and $_PlugPath? It would be rather straightforward for mma and mma-gb to deal with.

Maybe MMA_LIB as well? MMA processes a fixed list of directories and considers the first directory with a subdirectory MMA to be the MMA library. It really should use a list of paths instead of a fixed dir.
Logged
bvdp
Kara-Moon Master
****
Posts: 1436


WWW
« Reply #9 on: November 15, 2020, 06:29:32 PM »

Okay. Let's do one or two things at a time.

First, the -g behaviour can be changed. I'll do it later ... don't see any problems.

Second, adding MMA_LIBPATH and MMA_PLUGPATH env variables. Again, no problem ... I think that prepending the values makes as much sense as anything else. I'll add the appropriate calls in main.py around line 64 after the call to paths.init().



Logged

My online life: http://www.mellowood.ca
sciurius
Sr. Member
****
Posts: 443



« Reply #10 on: November 15, 2020, 07:36:20 PM »

Great, thanks!
Logged
sciurius
Sr. Member
****
Posts: 443



« Reply #11 on: November 16, 2020, 09:24:20 PM »

Related...

mma -I myplugin fails if myplugin resides in a path set (or augmented) by .mmarc.
Logged
bvdp
Kara-Moon Master
****
Posts: 1436


WWW
« Reply #12 on: November 16, 2020, 10:05:11 PM »

I'll have to look at that later today ... well, just did Smiley Not that this helps, but it works here.

I created a new directory ~/mmaplugs and added, to my .mmarc file,

   setplugpath ~/mmaplugs $_plugpath

moved a plugin directory to ~/mmaplugs and ran a test file. No problems.

 ... are you sure the mmarc file is being read?
 ... did you check the command?
 ... in your song file, could you do a print $_PlugPath
 
Logged

My online life: http://www.mellowood.ca
sciurius
Sr. Member
****
Posts: 443



« Reply #13 on: November 17, 2020, 07:11:23 AM »

Oh yes, that all works...

What doesn't seem to work is the -I option (mma -I plugin). It is shortcut in options.py.
Logged
bvdp
Kara-Moon Master
****
Posts: 1436


WWW
« Reply #14 on: November 17, 2020, 04:52:56 PM »

Oh, sorry ... guess I was not doing proper reading Smiley I'll look into this.
Logged

My online life: http://www.mellowood.ca
Pages: [1] 2
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.21 | SMF © 2015, Simple Machines Valid XHTML 1.0! Valid CSS!
Page created in 0.049 seconds with 19 queries.