aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.appveyor.yml2
-rw-r--r--mitmproxy/version.py3
-rwxr-xr-xrelease/rtool.py108
-rw-r--r--tox.ini1
4 files changed, 77 insertions, 37 deletions
diff --git a/.appveyor.yml b/.appveyor.yml
index 160cdf73..7ef9d8b8 100644
--- a/.appveyor.yml
+++ b/.appveyor.yml
@@ -36,7 +36,7 @@ test_script:
- ps: |
$Env:VERSION = $(python mitmproxy/version.py)
$Env:SKIP_MITMPROXY = "python -c `"print('skip mitmproxy')`""
- tox -e wheel
+ tox -e rtool -- wheel
tox -e rtool -- bdist
- ps: |
diff --git a/mitmproxy/version.py b/mitmproxy/version.py
index 3cae2a04..c901cb67 100644
--- a/mitmproxy/version.py
+++ b/mitmproxy/version.py
@@ -1,5 +1,4 @@
-IVERSION = (3, 0, 0)
-VERSION = ".".join(str(i) for i in IVERSION)
+VERSION = "3.0.0"
PATHOD = "pathod " + VERSION
MITMPROXY = "mitmproxy " + VERSION
diff --git a/release/rtool.py b/release/rtool.py
index 271392ba..14a0a078 100755
--- a/release/rtool.py
+++ b/release/rtool.py
@@ -4,6 +4,7 @@ import contextlib
import fnmatch
import os
import platform
+import re
import runpy
import shlex
import shutil
@@ -79,26 +80,38 @@ def git(args: str) -> str:
return subprocess.check_output(["git"] + shlex.split(args)).decode()
-def get_version() -> str:
- return runpy.run_path(VERSION_FILE)["VERSION"]
+def get_version(dev: bool = False, build: bool = False) -> str:
+ version = runpy.run_path(VERSION_FILE)["VERSION"]
+ version = re.sub(r"\.dev.+?$", "", version) # replace dev suffix if present.
-
-def get_snapshot_version() -> str:
last_tag, tag_dist, commit = git("describe --tags --long").strip().rsplit("-", 2)
+ commit = commit.lstrip("g")[:7]
tag_dist = int(tag_dist)
- if tag_dist == 0:
- return get_version()
+
+ if tag_dist > 0 and dev:
+ dev_tag = ".dev{tag_dist:04}".format(tag_dist=tag_dist)
else:
- # remove the 'g' prefix added by recent git versions
- if commit.startswith('g'):
- commit = commit[1:]
+ dev_tag = ""
+ if tag_dist > 0 and build:
# The wheel build tag (we use the commit) must start with a digit, so we include "0x"
- return "{version}dev{tag_dist:04}-0x{commit}".format(
- version=get_version(), # this should already be the next version
- tag_dist=tag_dist,
- commit=commit
- )
+ build_tag = "-0x{commit}".format(commit=commit)
+ else:
+ build_tag = ""
+
+ return version + dev_tag + build_tag
+
+
+def set_version(dev: bool) -> None:
+ """
+ Update version information in mitmproxy's version.py to either include the dev version or not.
+ """
+ v = get_version(dev)
+ with open(VERSION_FILE) as f:
+ content = f.read()
+ content = re.sub(r'^VERSION = ".+?"', 'VERSION = "{}"'.format(v), content)
+ with open(VERSION_FILE, "w") as f:
+ f.write(content)
def archive_name(bdist: str) -> str:
@@ -116,7 +129,7 @@ def archive_name(bdist: str) -> str:
def wheel_name() -> str:
return "mitmproxy-{version}-py3-none-any.whl".format(
- version=get_version(),
+ version=get_version(True),
)
@@ -179,6 +192,23 @@ def contributors():
f.write(contributors_data.encode())
+@cli.command("wheel")
+def make_wheel():
+ """
+ Build a Python wheel
+ """
+ set_version(True)
+ try:
+ subprocess.check_call([
+ "tox", "-e", "wheel",
+ ], env={
+ **os.environ,
+ "VERSION": get_version(True),
+ })
+ finally:
+ set_version(False)
+
+
@cli.command("bdist")
def make_bdist():
"""
@@ -206,24 +236,30 @@ def make_bdist():
excludes.append("mitmproxy.tools.web")
if tool != "mitmproxy_main":
excludes.append("mitmproxy.tools.console")
- subprocess.check_call(
- [
- "pyinstaller",
- "--clean",
- "--workpath", PYINSTALLER_TEMP,
- "--distpath", PYINSTALLER_DIST,
- "--additional-hooks-dir", PYINSTALLER_HOOKS,
- "--onefile",
- "--console",
- "--icon", "icon.ico",
- # This is PyInstaller, so setting a
- # different log level obviously breaks it :-)
- # "--log-level", "WARN",
- ]
- + [x for e in excludes for x in ["--exclude-module", e]]
- + PYINSTALLER_ARGS
- + [tool]
- )
+
+ # Overwrite mitmproxy/version.py to include commit info
+ set_version(True)
+ try:
+ subprocess.check_call(
+ [
+ "pyinstaller",
+ "--clean",
+ "--workpath", PYINSTALLER_TEMP,
+ "--distpath", PYINSTALLER_DIST,
+ "--additional-hooks-dir", PYINSTALLER_HOOKS,
+ "--onefile",
+ "--console",
+ "--icon", "icon.ico",
+ # This is PyInstaller, so setting a
+ # different log level obviously breaks it :-)
+ # "--log-level", "WARN",
+ ]
+ + [x for e in excludes for x in ["--exclude-module", e]]
+ + PYINSTALLER_ARGS
+ + [tool]
+ )
+ finally:
+ set_version(False)
# Delete the spec file - we're good without.
os.remove("{}.spec".format(tool))
@@ -299,7 +335,11 @@ def upload_snapshot(host, port, user, private_key, private_key_password, wheel,
for f in files:
local_path = join(DIST_DIR, f)
- remote_filename = f.replace(get_version(), get_snapshot_version())
+ remote_filename = re.sub(
+ r"{version}(\.dev\d+(-0x[0-9a-f]+)?)?".format(version=get_version()),
+ get_version(True, True),
+ f
+ )
symlink_path = "../{}".format(f.replace(get_version(), "latest"))
# Upload new version
diff --git a/tox.ini b/tox.ini
index 5c2b25ae..02d9a57b 100644
--- a/tox.ini
+++ b/tox.ini
@@ -51,6 +51,7 @@ commands =
pathoc --version
[testenv:rtool]
+passenv = SKIP_MITMPROXY SNAPSHOT_HOST SNAPSHOT_PORT SNAPSHOT_USER SNAPSHOT_PASS RTOOL_KEY
deps =
-rrequirements.txt
pyinstaller==3.3.1