  The Oslo method comprises a set of analysis techniques designed to extract
nuclear level density and average $\gamma$-decay strength function from a set
of excitation-energy tagged $\gamma$-ray spectra. Here we present a new
software implementation of the entire Oslo method, called OMpy. We provide a
summary of the theoretical basis and derive the essential equations used in the
Oslo method. In addition to the functionality of the original analysis code,
the new implementation includes novel components such as a rigorous method to
propagate uncertainties throughout all steps of the Oslo method using a Monte
Carlo approach. The resulting level density and $\gamma$-ray strength function
have to be normalized to auxiliary data. The normalization is performed
simultaneously for both quantities, thus preserving all correlations. The
software is verified by the analysis of a synthetic spectrum and compared to
the results of the previous implementation, the oslo-method-software.
