pycoder pycoder - 2 months ago 6
Git Question

Maintaining a Lite and Pro Version of Python Project with Git/PyCharm


I am wrapping up a python project, and I am considering releasing a it with pro/lite versions. I don't want duplicate code laying around, of course, but I can't release a free version with many of the capabilities of the pro version only disabled with a few if checks: the code is for a Blender add-on and therefore will be easily edited and turned into a pro version if the features are still there.


What is the best way to maintain a project like this using Git/Pycharm (or am I better off to just not worry about a lite version) without duplicate code? I have read that using multiple Git branches is not the way to go.


I do realize that there have been many similar questions about this topic. However, many of these deal with using Xcode, and many more do not have clear answers. Don't get me wrong, I know I could do this a number of ways - but I am looking for the best way, the cleanest way.


Here's basic idea, based on you segregating out code into different modules. Right now, the concept is having 2 different download points. But it doesn't have to be, that's your call.

Regardless of which packaging/distribution approach you take, you'll have to separate out codelines into different code modules. Even if it's just one download.

lite/ - installed from github.lite

#things you want in common between pro and lite
#i.e. what would be your "duplicate code"
def common_func1():

Note: I would not put stuff common to both pro and lite directly into lite/, because you want to present a unified API by exposing pro in lite, but you don't want to also have pro import lite, because that would risk circular import dependencies.

lite/ - installed from github.lite

#things you want in common between pro and lite
import lite.common_core
#or import lite.common_core as common

def lite_function1():

def lite_function2():

    #you need to determine an appropriate path strategy
    #a pypi-installed pro package should be available on the sys.path
    from pro.main import *
    # or import pro.main as pro
except ImportError:

#client code can now call functions from the lite and pro

pro/ - installed from

import lite.common_core

def pro_function1():

You could have lite be a requirement of the pro pypi package, so that the user would still have only one download if they started that way.

Also, wrt to the answer you pointed to re git branches, another way to think of it is that you might be trying to fix/enhance say pro. So, from pro's master, you'd want the freedom to create a new branch and still be aware of lite's master (because you depend on it). That kinda bookkeeping is going to be difficult if you are juggling pro and lite on the same repo, with branches used to separate out pro/lite.