Right name for your problem is maximization of g(x) subject to linear constraint Ax = b. I.e. you have requirement that Ax=b exactly, and you want to maximize g(x) subject to this requirement.
The difference from your approach is that such formulation explicitly states that we tolerate no deviations from Ax=b, whilst your formulation allows complicated trade-offs between accuracy of Ax=b and maximization of g(x).
There exist numerous libraries for constrained nonlinear optimization. As for Python, I'd recommend scipy.optimize.minimize(), SLSQP solver.
UPDATE: if you are unsatisfied with SciPy, another option is to try ALGLIB. This library is mature and free and has Python wrapper (actually, it is C++ and C# library). It has linearly constrained optimizer called MinBLEIC, which allows to specify entire constraining matrix A as one array. The only drawback is that library has no support for numpy's ndarray, so if you prefer numpy for arrays, you have to perform conversion of ndarray to list-of-lists (see this question). Disclosure: I am one of the developers :)