Team Ai
Datasetpublic

codekingpro/portable-devtools

sourceHugging Faceupdated 5mo agoView on Hugging Face
1likes15kdownloads
version.py55 linesDownload Raw Back to mitmproxy
1import os2import subprocess3import sys4 5VERSION = "12.2.3"6MITMPROXY = "mitmproxy " + VERSION7 8# Serialization format version. This is displayed nowhere, it just needs to be incremented by one9# for each change in the file format.10FLOW_FORMAT_VERSION = 2111 12 13def get_dev_version() -> str:14    """15    Return a detailed version string, sourced either from VERSION or obtained dynamically using git.16    """17 18    mitmproxy_version = VERSION19 20    here = os.path.abspath(os.path.join(os.path.dirname(__file__), ".."))21    try:  # pragma: no cover22        # Check that we're in the mitmproxy repository: https://github.com/mitmproxy/mitmproxy/issues/398723        # cb0e3287090786fad566feb67ac07b8ef361b2c3 is the first mitmproxy commit.24        subprocess.run(25            ["git", "cat-file", "-e", "cb0e3287090786fad566feb67ac07b8ef361b2c3"],26            stdout=subprocess.DEVNULL,27            stderr=subprocess.DEVNULL,28            cwd=here,29            check=True,30        )31        git_describe = subprocess.check_output(32            ["git", "describe", "--tags", "--long"],33            stderr=subprocess.STDOUT,34            cwd=here,35        )36        last_tag, tag_dist_str, commit = git_describe.decode().strip().rsplit("-", 2)37        commit = commit.lstrip("g")[:7]38        tag_dist = int(tag_dist_str)39    except Exception:40        pass41    else:42        # Add commit info for non-tagged releases43        if tag_dist > 0:44            mitmproxy_version += f" (+{tag_dist}, commit {commit})"45 46    # PyInstaller build indicator, if using precompiled binary47    if getattr(sys, "frozen", False):48        mitmproxy_version += " binary"49 50    return mitmproxy_version51 52 53if __name__ == "__main__":  # pragma: no cover54    print(VERSION)55 
codekingpro/portable-devtools · Team Ai