mirror of
https://github.com/ankitects/anki.git
synced 2025-12-20 10:22:57 -05:00
support overriding pyqt via env var
Documentation to come later.
This commit is contained in:
parent
3f3f4b5c36
commit
88553acb0d
1 changed files with 35 additions and 12 deletions
|
|
@ -9,6 +9,7 @@ import os
|
||||||
import shutil
|
import shutil
|
||||||
import sys
|
import sys
|
||||||
import re
|
import re
|
||||||
|
import subprocess
|
||||||
|
|
||||||
from pip._internal.commands import create_command
|
from pip._internal.commands import create_command
|
||||||
from pip._vendor import pkg_resources
|
from pip._vendor import pkg_resources
|
||||||
|
|
@ -76,12 +77,15 @@ def install_package(pkg, directory, pip_args):
|
||||||
|
|
||||||
return pkginfo.Wheel(dist_info)
|
return pkginfo.Wheel(dist_info)
|
||||||
|
|
||||||
|
|
||||||
def _cleanup(directory, pattern):
|
def _cleanup(directory, pattern):
|
||||||
for p in glob.glob(os.path.join(directory, pattern)):
|
for p in glob.glob(os.path.join(directory, pattern)):
|
||||||
shutil.rmtree(p)
|
shutil.rmtree(p)
|
||||||
|
|
||||||
|
|
||||||
fix_none = re.compile(r"(\s*None) =")
|
fix_none = re.compile(r"(\s*None) =")
|
||||||
|
|
||||||
|
|
||||||
def copy_and_fix_pyi(source, dest):
|
def copy_and_fix_pyi(source, dest):
|
||||||
"Fix broken PyQt types."
|
"Fix broken PyQt types."
|
||||||
with open(source) as input_file:
|
with open(source) as input_file:
|
||||||
|
|
@ -90,6 +94,7 @@ def copy_and_fix_pyi(source, dest):
|
||||||
line = fix_none.sub(r"\1_ =", line)
|
line = fix_none.sub(r"\1_ =", line)
|
||||||
output_file.write(line)
|
output_file.write(line)
|
||||||
|
|
||||||
|
|
||||||
def merge_files(root, source):
|
def merge_files(root, source):
|
||||||
for dirpath, _dirnames, filenames in os.walk(source):
|
for dirpath, _dirnames, filenames in os.walk(source):
|
||||||
target_dir = os.path.join(root, os.path.relpath(dirpath, source))
|
target_dir = os.path.join(root, os.path.relpath(dirpath, source))
|
||||||
|
|
@ -104,22 +109,40 @@ def merge_files(root, source):
|
||||||
else:
|
else:
|
||||||
shutil.copy2(source_path, target_path)
|
shutil.copy2(source_path, target_path)
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
base = sys.argv[1]
|
base = sys.argv[1]
|
||||||
|
|
||||||
packages = [
|
local_site_packages = os.environ.get("PYTHON_SITE_PACKAGES")
|
||||||
("pyqt5", "pyqt5==5.15.2"),
|
if local_site_packages:
|
||||||
("pyqtwebengine", "pyqtwebengine==5.15.2"),
|
subprocess.run(
|
||||||
("pyqt5-sip", "pyqt5_sip==12.8.1"),
|
[
|
||||||
]
|
"rsync",
|
||||||
|
"-ai",
|
||||||
|
"--include=PyQt**",
|
||||||
|
"--exclude=*",
|
||||||
|
local_site_packages,
|
||||||
|
base + "/",
|
||||||
|
],
|
||||||
|
check=True,
|
||||||
|
)
|
||||||
|
with open(os.path.join(base, "__init__.py"), "w") as file:
|
||||||
|
pass
|
||||||
|
|
||||||
for (name, with_version) in packages:
|
else:
|
||||||
# install package in subfolder
|
packages = [
|
||||||
folder = os.path.join(base, "temp")
|
("pyqt5", "pyqt5==5.15.2"),
|
||||||
_pkg = install_package(with_version, folder, [])
|
("pyqtwebengine", "pyqtwebengine==5.15.2"),
|
||||||
# merge into parent
|
("pyqt5-sip", "pyqt5_sip==12.8.1"),
|
||||||
merge_files(base, folder)
|
]
|
||||||
shutil.rmtree(folder)
|
|
||||||
|
for (name, with_version) in packages:
|
||||||
|
# install package in subfolder
|
||||||
|
folder = os.path.join(base, "temp")
|
||||||
|
_pkg = install_package(with_version, folder, [])
|
||||||
|
# merge into parent
|
||||||
|
merge_files(base, folder)
|
||||||
|
shutil.rmtree(folder)
|
||||||
|
|
||||||
# add missing py.typed file
|
# add missing py.typed file
|
||||||
with open(os.path.join(base, "py.typed"), "w") as file:
|
with open(os.path.join(base, "py.typed"), "w") as file:
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue