Page 1 of 1

Modifying Source Code

PostPosted: Fri Mar 18, 2016 7:06 pm
by nee-
Hi,

For a college project I'm working on I want to use MakeHuman to carry out some automated tasks. As the software is not built for automation, I'll to change some of the source code I was using in order to achieve this functionality.

Is there is a procedure for modifying the source code? My intention is to add some command line arguments and make the application run a plugin I've been developing.

Also, in terms of the project being open source, how would I make the modified source code available afterwards?

I tried looking on the Wiki but the FAQ link seems to point to an incomplete page.

Any guidance would be greatly appreciated.

Thanks!

Re: Modifying Source Code

PostPosted: Fri Mar 18, 2016 7:51 pm
by Aranuvir

Re: Modifying Source Code

PostPosted: Fri Mar 18, 2016 8:09 pm
by nee-
I'm aware of the cmd version already. I actually require more modifications to than this, so I still need to adapt the source code further to this.

Thanks though!

Re: Modifying Source Code

PostPosted: Fri Mar 18, 2016 11:37 pm
by joepal
nee- wrote:Is there is a procedure for modifying the source code? My intention is to add some command line arguments and make the application run a plugin I've been developing.


I don't understand the question. The files are plain text python files, so just go ahead and edit them?

However, it'd be probably be more maintainable if you implemented your changes/additions via a plugin instead of making changes in the core files. Otherwise you'd have to re-patch after each update to MH. For plugins, looking in 7_scripting is a good start.

nee- wrote:Also, in terms of the project being open source, how would I make the modified source code available afterwards?


The best way is to make a fork of MH on BitBucket. Once you're pleased with your changes you can either make a pull request (if you think they should be committed back to MH) or publish a link here to your repo if you think the changes are too large to fit in the main code.

Re: Modifying Source Code

PostPosted: Sat Mar 19, 2016 11:55 am
by nee-
joepal wrote:I don't understand the question. The files are plain text python files, so just go ahead and edit them?

I just wanted to check in case there any requests I had to make before forking and modifying the code, which your answer has cleared up for me. Thanks!

joepal wrote:However, it'd be probably be more maintainable if you implemented your changes/additions via a plugin instead of making changes in the core files. Otherwise you'd have to re-patch after each update to MH. For plugins, looking in 7_scripting is a good start.

I did create a plugin. I just require that it auto runs with some command line arguments when the application is launched, which is why I need to modify the source code.

Thanks again!

Re: Modifying Source Code

PostPosted: Sat Mar 19, 2016 12:21 pm
by joepal
nee- wrote:I did create a plugin. I just require that it auto runs with some command line arguments when the application is launched, which is why I need to modify the source code.


Wouldn't it then be easier to read the command line arguments from inside the plugin's initializer and take the appropriate actions there? The initializer always runs at application startup as long as the plugin is enabled.

An alternative is using environment variables instead of command line arguments. Those are very easy to read everywhere.

For example, if you launch makehuman thusly:

Code: Select all
DO_THIS_AND_THAT=1 python makehuman.py


Then you can in your plugin's initializer ("load()") do

Code: Select all
import os
def load(app):
    if 'DO_THIS_AND_THAT' in os.environ:
        print("Yup, I should do this and that")