Modifying Source Code

This forum is aimed at user contributions, in the form of assets, side projects, code patches and similar.

Moderator: joepal

Modifying Source Code

Postby nee- » Fri Mar 18, 2016 7:06 pm

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!
nee-
 
Posts: 5
Joined: Tue Jan 05, 2016 12:14 am

Re: Modifying Source Code

Postby Aranuvir » Fri Mar 18, 2016 7:51 pm

Aranuvir
 
Posts: 1314
Joined: Sun Oct 12, 2014 2:12 pm

Re: Modifying Source Code

Postby nee- » Fri Mar 18, 2016 8:09 pm

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!
nee-
 
Posts: 5
Joined: Tue Jan 05, 2016 12:14 am

Re: Modifying Source Code

Postby joepal » Fri Mar 18, 2016 11:37 pm

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.
Joel Palmius (LinkedIn)
MakeHuman Infrastructure Manager
http://www.palmius.com/joel
joepal
 
Posts: 4465
Joined: Wed Jun 04, 2008 11:20 am

Re: Modifying Source Code

Postby nee- » Sat Mar 19, 2016 11:55 am

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!
nee-
 
Posts: 5
Joined: Tue Jan 05, 2016 12:14 am

Re: Modifying Source Code

Postby joepal » Sat Mar 19, 2016 12:21 pm

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")
Joel Palmius (LinkedIn)
MakeHuman Infrastructure Manager
http://www.palmius.com/joel
joepal
 
Posts: 4465
Joined: Wed Jun 04, 2008 11:20 am


Return to User contributions

Who is online

Users browsing this forum: No registered users and 1 guest