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,9 +109,27 @@ 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]
|
||||||
|
|
||||||
|
local_site_packages = os.environ.get("PYTHON_SITE_PACKAGES")
|
||||||
|
if local_site_packages:
|
||||||
|
subprocess.run(
|
||||||
|
[
|
||||||
|
"rsync",
|
||||||
|
"-ai",
|
||||||
|
"--include=PyQt**",
|
||||||
|
"--exclude=*",
|
||||||
|
local_site_packages,
|
||||||
|
base + "/",
|
||||||
|
],
|
||||||
|
check=True,
|
||||||
|
)
|
||||||
|
with open(os.path.join(base, "__init__.py"), "w") as file:
|
||||||
|
pass
|
||||||
|
|
||||||
|
else:
|
||||||
packages = [
|
packages = [
|
||||||
("pyqt5", "pyqt5==5.15.2"),
|
("pyqt5", "pyqt5==5.15.2"),
|
||||||
("pyqtwebengine", "pyqtwebengine==5.15.2"),
|
("pyqtwebengine", "pyqtwebengine==5.15.2"),
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue