mirror of
https://github.com/Grasscutters/mitmproxy.git
synced 2025-01-30 23:09:44 +00:00
First-order conversion of rtool to flat directory structure
This commit is contained in:
parent
e8611acb76
commit
5441683037
135
release/rtool.py
135
release/rtool.py
@ -34,7 +34,7 @@ else:
|
|||||||
RELEASE_DIR = join(os.path.dirname(os.path.realpath(__file__)))
|
RELEASE_DIR = join(os.path.dirname(os.path.realpath(__file__)))
|
||||||
DIST_DIR = join(RELEASE_DIR, "dist")
|
DIST_DIR = join(RELEASE_DIR, "dist")
|
||||||
ROOT_DIR = os.path.normpath(join(RELEASE_DIR, ".."))
|
ROOT_DIR = os.path.normpath(join(RELEASE_DIR, ".."))
|
||||||
VERSION_FILE = join(ROOT_DIR, "netlib/netlib/version.py")
|
VERSION_FILE = join(ROOT_DIR, "netlib/version.py")
|
||||||
|
|
||||||
BUILD_DIR = join(RELEASE_DIR, "build")
|
BUILD_DIR = join(RELEASE_DIR, "build")
|
||||||
PYINSTALLER_TEMP = join(BUILD_DIR, "pyinstaller")
|
PYINSTALLER_TEMP = join(BUILD_DIR, "pyinstaller")
|
||||||
@ -44,27 +44,14 @@ VENV_DIR = join(BUILD_DIR, "venv")
|
|||||||
VENV_PIP = join(VENV_DIR, VENV_BIN, "pip")
|
VENV_PIP = join(VENV_DIR, VENV_BIN, "pip")
|
||||||
VENV_PYINSTALLER = join(VENV_DIR, VENV_BIN, "pyinstaller")
|
VENV_PYINSTALLER = join(VENV_DIR, VENV_BIN, "pyinstaller")
|
||||||
|
|
||||||
ALL_PROJECTS = {
|
project = {
|
||||||
"netlib": {
|
"name": "mitmproxy",
|
||||||
"tools": [],
|
"tools": ["pathod", "pathoc", "mitmproxy", "mitmdump", "mitmweb"],
|
||||||
"dir": join(ROOT_DIR, "netlib"),
|
"dir": ROOT_DIR,
|
||||||
"python_version": "py2.py3" # this is the format in wheel filenames
|
"python_version": "py2"
|
||||||
},
|
|
||||||
"pathod": {
|
|
||||||
"tools": ["pathod", "pathoc"],
|
|
||||||
"dir": join(ROOT_DIR, "pathod"),
|
|
||||||
"python_version": "py2"
|
|
||||||
},
|
|
||||||
"mitmproxy": {
|
|
||||||
"tools": ["mitmproxy", "mitmdump", "mitmweb"],
|
|
||||||
"dir": join(ROOT_DIR, "mitmproxy"),
|
|
||||||
"python_version": "py2"
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if platform.system() == "Windows":
|
if platform.system() == "Windows":
|
||||||
ALL_PROJECTS["mitmproxy"]["tools"].remove("mitmproxy")
|
project["tools"].remove("mitmproxy")
|
||||||
|
|
||||||
projects = {}
|
|
||||||
|
|
||||||
|
|
||||||
def get_version():
|
def get_version():
|
||||||
@ -84,7 +71,7 @@ def get_snapshot_version():
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def archive_name(project):
|
def archive_name():
|
||||||
platform_tag = {
|
platform_tag = {
|
||||||
"Darwin": "osx",
|
"Darwin": "osx",
|
||||||
"Windows": "win32",
|
"Windows": "win32",
|
||||||
@ -95,18 +82,18 @@ def archive_name(project):
|
|||||||
else:
|
else:
|
||||||
ext = "tar.gz"
|
ext = "tar.gz"
|
||||||
return "{project}-{version}-{platform}.{ext}".format(
|
return "{project}-{version}-{platform}.{ext}".format(
|
||||||
project=project,
|
project=project["name"],
|
||||||
version=get_version(),
|
version=get_version(),
|
||||||
platform=platform_tag,
|
platform=platform_tag,
|
||||||
ext=ext
|
ext=ext
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def wheel_name(project):
|
def wheel_name():
|
||||||
return "{project}-{version}-{py_version}-none-any.whl".format(
|
return "{project}-{version}-{py_version}-none-any.whl".format(
|
||||||
project=project,
|
project=project["name"],
|
||||||
version=get_version(),
|
version=get_version(),
|
||||||
py_version=projects[project]["python_version"]
|
py_version=project["python_version"]
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@ -136,16 +123,11 @@ def git(args):
|
|||||||
|
|
||||||
|
|
||||||
@click.group(chain=True)
|
@click.group(chain=True)
|
||||||
@click.option(
|
def cli():
|
||||||
'--project', '-p',
|
|
||||||
multiple=True, type=click.Choice(ALL_PROJECTS.keys()), default=ALL_PROJECTS.keys()
|
|
||||||
)
|
|
||||||
def cli(project):
|
|
||||||
"""
|
"""
|
||||||
mitmproxy build tool
|
mitmproxy build tool
|
||||||
"""
|
"""
|
||||||
for name in project:
|
pass
|
||||||
projects[name] = ALL_PROJECTS[name]
|
|
||||||
|
|
||||||
|
|
||||||
@cli.command("contributors")
|
@cli.command("contributors")
|
||||||
@ -188,15 +170,15 @@ def wheels():
|
|||||||
print("Building release...")
|
print("Building release...")
|
||||||
if os.path.exists(DIST_DIR):
|
if os.path.exists(DIST_DIR):
|
||||||
shutil.rmtree(DIST_DIR)
|
shutil.rmtree(DIST_DIR)
|
||||||
for project, conf in projects.items():
|
|
||||||
print("Creating wheel for %s ..." % project)
|
print("Creating wheel for %s ..." % project["name"])
|
||||||
subprocess.check_call(
|
subprocess.check_call(
|
||||||
[
|
[
|
||||||
"python", "./setup.py", "-q",
|
"python", "./setup.py", "-q",
|
||||||
"bdist_wheel", "--dist-dir", DIST_DIR,
|
"bdist_wheel", "--dist-dir", DIST_DIR,
|
||||||
],
|
],
|
||||||
cwd=conf["dir"]
|
cwd=project["dir"]
|
||||||
)
|
)
|
||||||
|
|
||||||
print("Creating virtualenv for test install...")
|
print("Creating virtualenv for test install...")
|
||||||
if os.path.exists(VENV_DIR):
|
if os.path.exists(VENV_DIR):
|
||||||
@ -204,16 +186,14 @@ def wheels():
|
|||||||
subprocess.check_call(["virtualenv", "-q", VENV_DIR])
|
subprocess.check_call(["virtualenv", "-q", VENV_DIR])
|
||||||
|
|
||||||
with chdir(DIST_DIR):
|
with chdir(DIST_DIR):
|
||||||
for project, conf in projects.items():
|
print("Installing %s..." % project["name"])
|
||||||
print("Installing %s..." % project)
|
subprocess.check_call([VENV_PIP, "install", "-q", wheel_name()])
|
||||||
subprocess.check_call([VENV_PIP, "install", "-q", wheel_name(project)])
|
|
||||||
|
|
||||||
print("Running binaries...")
|
print("Running binaries...")
|
||||||
for project, conf in projects.items():
|
for tool in project["tools"]:
|
||||||
for tool in conf["tools"]:
|
tool = join(VENV_DIR, VENV_BIN, tool)
|
||||||
tool = join(VENV_DIR, VENV_BIN, tool)
|
print("> %s --version" % tool)
|
||||||
print("> %s --version" % tool)
|
print(subprocess.check_output([tool, "--version"]))
|
||||||
print(subprocess.check_output([tool, "--version"]))
|
|
||||||
|
|
||||||
print("Virtualenv available for further testing:")
|
print("Virtualenv available for further testing:")
|
||||||
print("source %s" % os.path.normpath(join(VENV_DIR, VENV_BIN, "activate")))
|
print("source %s" % os.path.normpath(join(VENV_DIR, VENV_BIN, "activate")))
|
||||||
@ -238,34 +218,33 @@ def bdist(ctx, use_existing_wheels, pyinstaller_version):
|
|||||||
print("Installing PyInstaller...")
|
print("Installing PyInstaller...")
|
||||||
subprocess.check_call([VENV_PIP, "install", "-q", pyinstaller_version])
|
subprocess.check_call([VENV_PIP, "install", "-q", pyinstaller_version])
|
||||||
|
|
||||||
for p, conf in projects.items():
|
if project["tools"]:
|
||||||
if conf["tools"]:
|
with Archive(join(DIST_DIR, archive_name())) as archive:
|
||||||
with Archive(join(DIST_DIR, archive_name(p))) as archive:
|
for tool in project["tools"]:
|
||||||
for tool in conf["tools"]:
|
spec = join(RELEASE_DIR, "specs/%s.spec" % tool)
|
||||||
spec = join(RELEASE_DIR, "specs/%s.spec" % tool)
|
print("Building %s binary..." % tool)
|
||||||
print("Building %s binary..." % tool)
|
subprocess.check_call(
|
||||||
subprocess.check_call(
|
[
|
||||||
[
|
VENV_PYINSTALLER,
|
||||||
VENV_PYINSTALLER,
|
"--clean",
|
||||||
"--clean",
|
"--workpath", PYINSTALLER_TEMP,
|
||||||
"--workpath", PYINSTALLER_TEMP,
|
"--distpath", PYINSTALLER_DIST,
|
||||||
"--distpath", PYINSTALLER_DIST,
|
# This is PyInstaller, so setting a
|
||||||
# This is PyInstaller, so setting a
|
# different log level obviously breaks it :-)
|
||||||
# different log level obviously breaks it :-)
|
# "--log-level", "WARN",
|
||||||
# "--log-level", "WARN",
|
spec
|
||||||
spec
|
]
|
||||||
]
|
)
|
||||||
)
|
|
||||||
|
|
||||||
# Test if it works at all O:-)
|
# Test if it works at all O:-)
|
||||||
executable = join(PYINSTALLER_DIST, tool)
|
executable = join(PYINSTALLER_DIST, tool)
|
||||||
if platform.system() == "Windows":
|
if platform.system() == "Windows":
|
||||||
executable += ".exe"
|
executable += ".exe"
|
||||||
print("> %s --version" % executable)
|
print("> %s --version" % executable)
|
||||||
subprocess.check_call([executable, "--version"])
|
subprocess.check_call([executable, "--version"])
|
||||||
|
|
||||||
archive.add(executable, os.path.basename(executable))
|
archive.add(executable, os.path.basename(executable))
|
||||||
print("Packed {}.".format(archive_name(p)))
|
print("Packed {}.".format(archive_name()))
|
||||||
|
|
||||||
|
|
||||||
@cli.command("upload-release")
|
@cli.command("upload-release")
|
||||||
@ -277,7 +256,7 @@ def upload_release(username, password, repository):
|
|||||||
Upload wheels to PyPI
|
Upload wheels to PyPI
|
||||||
"""
|
"""
|
||||||
for project in projects.keys():
|
for project in projects.keys():
|
||||||
filename = wheel_name(project)
|
filename = wheel_name()
|
||||||
print("Uploading {} to {}...".format(filename, repository))
|
print("Uploading {} to {}...".format(filename, repository))
|
||||||
subprocess.check_call([
|
subprocess.check_call([
|
||||||
"twine",
|
"twine",
|
||||||
@ -312,9 +291,9 @@ def upload_snapshot(host, port, user, private_key, private_key_password, wheel,
|
|||||||
with sftp.cd(dir_name):
|
with sftp.cd(dir_name):
|
||||||
files = []
|
files = []
|
||||||
if wheel:
|
if wheel:
|
||||||
files.append(wheel_name(project))
|
files.append(wheel_name())
|
||||||
if bdist and conf["tools"]:
|
if bdist and conf["tools"]:
|
||||||
files.append(archive_name(project))
|
files.append(archive_name())
|
||||||
|
|
||||||
for f in files:
|
for f in files:
|
||||||
local_path = join(DIST_DIR, f)
|
local_path = join(DIST_DIR, f)
|
||||||
|
Loading…
Reference in New Issue
Block a user