Skip to content

Commit

Permalink
Freeze r2.2
Browse files Browse the repository at this point in the history
  - Remove update/branch switch from GUI
  - Remove update_deps.py
  - Freeze requirements
  - Update installers
  • Loading branch information
torzdf committed Jun 18, 2023
1 parent 82e927d commit e8dd50d
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 283 deletions.
2 changes: 1 addition & 1 deletion .install/linux/faceswap_setup_x64.sh
Original file line number Diff line number Diff line change
Expand Up @@ -405,7 +405,7 @@ clone_faceswap() {
# Clone the faceswap repo
delete_faceswap
info "Downloading Faceswap..."
yellow ; git clone --depth 1 --no-single-branch "$DL_FACESWAP" "$DIR_FACESWAP"
yellow ; git clone --depth 1 --single-branch --branch r2.2 "$DL_FACESWAP" "$DIR_FACESWAP"
}

setup_faceswap() {
Expand Down
2 changes: 1 addition & 1 deletion .install/windows/install.nsi
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ InstallDir $PROFILE\faceswap

# Install cli flags
!define flagsConda "/S /RegisterPython=0 /AddToPath=0 /D=$PROFILE\MiniConda3"
!define flagsRepo "--depth 1 --no-single-branch ${wwwRepo}"
!define flagsRepo "--depth 1 --single-branch --branch r2.2 ${wwwRepo}"
!define flagsEnv "-y python=3."

# Folders
Expand Down
228 changes: 0 additions & 228 deletions lib/gui/menu.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
""" The Menu Bars for faceswap GUI """

import gettext
import locale
import logging
import os
import sys
Expand All @@ -11,12 +10,9 @@
from tkinter import ttk
import webbrowser

from subprocess import Popen, PIPE, STDOUT

from lib.multithreading import MultiThread
from lib.serializer import get_serializer, Serializer
from lib.utils import FaceswapError
import update_deps

from .popup_configure import open_popup
from .custom_widgets import Tooltip
Expand Down Expand Up @@ -273,130 +269,9 @@ def _output_sysinfo(self):
print(info)
self.root.config(cursor="")

@classmethod
def _check_for_updates(cls, encoding: str, check: bool = False) -> bool:
""" Check whether an update is required
Parameters
----------
encoding: str
The encoding to use for decoding process returns
check: bool
``True`` if we are just checking for updates ``False`` if a check and update is to be
performed. Default: ``False``
Returns
-------
bool
``True`` if an update is required
"""
# Do the check
logger.info("Checking for updates...")
update = False
msg = ""
gitcmd = "git remote update && git status -uno"
with Popen(gitcmd, shell=True, stdout=PIPE, stderr=STDOUT, cwd=_WORKING_DIR) as cmd:
stdout, _ = cmd.communicate()
retcode = cmd.poll()
if retcode != 0:
msg = ("Git is not installed or you are not running a cloned repo. "
"Unable to check for updates")
else:
chk = stdout.decode(encoding, errors="replace").splitlines()
for line in chk:
if line.lower().startswith("your branch is ahead"):
msg = "Your branch is ahead of the remote repo. Not updating"
break
if line.lower().startswith("your branch is up to date"):
msg = "Faceswap is up to date."
break
if line.lower().startswith("your branch is behind"):
msg = "There are updates available"
update = True
break
if "have diverged" in line.lower():
msg = "Your branch has diverged from the remote repo. Not updating"
break
if not update or check:
logger.info(msg)
logger.debug("Checked for update. Update required: %s", update)
return update

def _check(self) -> None:
""" Check for updates and clone repository """
logger.debug("Checking for updates...")
self.root.config(cursor="watch")
encoding = locale.getpreferredencoding()
logger.debug("Encoding: %s", encoding)
self._check_for_updates(encoding, check=True)
self.root.config(cursor="")

@classmethod
def _do_update(cls, encoding: str) -> bool:
""" Update Faceswap
Parameters
----------
encoding: str
The encoding to use for decoding process returns
Returns
-------
bool
``True`` if update was successful
"""
logger.info("A new version is available. Updating...")
gitcmd = "git pull"
with Popen(gitcmd,
shell=True,
stdout=PIPE,
stderr=STDOUT,
bufsize=1,
cwd=_WORKING_DIR) as cmd:
while True:
out = cmd.stdout
output = "" if out is None else out.readline().decode(encoding, errors="replace")
if output == "" and cmd.poll() is not None:
break
if output:
logger.debug("'%s' output: '%s'", gitcmd, output.strip())
print(output.strip())
retcode = cmd.poll()
logger.debug("'%s' returncode: %s", gitcmd, retcode)
if retcode != 0:
logger.info("An error occurred during update. return code: %s", retcode)
retval = False
else:
retval = True
return retval

def _update(self) -> None:
""" Check for updates and clone repository """
logger.debug("Updating Faceswap...")
self.root.config(cursor="watch")
encoding = locale.getpreferredencoding()
logger.debug("Encoding: %s", encoding)
success = False
if self._check_for_updates(encoding):
success = self._do_update(encoding)
update_deps.main(is_gui=True)
if success:
logger.info("Please restart Faceswap to complete the update.")
self.root.config(cursor="")

def _build(self) -> None:
""" Build the help menu """
logger.debug("Building Help menu")

self.add_command(label=_("Check for updates..."),
underline=0,
command=lambda action="_check": self._in_thread(action)) # type:ignore
self.add_command(label=_("Update Faceswap..."),
underline=0,
command=lambda action="_update": self._in_thread(action)) # type:ignore
if self._build_branches_menu():
self.add_cascade(label=_("Switch Branch"), underline=7, menu=self._branches_menu)
self.add_separator()
self._build_recources_menu()
self.add_cascade(label=_("Resources"), underline=0, menu=self.recources_menu)
self.add_separator()
Expand All @@ -406,109 +281,6 @@ def _build(self) -> None:
command=lambda action="_output_sysinfo": self._in_thread(action)) # type:ignore
logger.debug("Built help menu")

def _build_branches_menu(self) -> bool:
""" Build branch selection menu.
Queries git for available branches and builds a menu based on output.
Returns
-------
bool
``True`` if menu was successfully built otherwise ``False``
"""
stdout = self._get_branches()
if stdout is None:
return False

branches = self._filter_branches(stdout)
if not branches:
return False

for branch in branches:
self._branches_menu.add_command(
label=branch,
command=lambda b=branch: self._switch_branch(b)) # type:ignore
return True

@classmethod
def _get_branches(cls) -> T.Optional[str]:
""" Get the available github branches
Returns
-------
str or ``None``
The list of branches available. If no branches were found or there was an
error then `None` is returned
"""
gitcmd = "git branch -a"
with Popen(gitcmd, shell=True, stdout=PIPE, stderr=STDOUT, cwd=_WORKING_DIR) as cmd:
stdout, _ = cmd.communicate()
retcode = cmd.poll()
if retcode != 0:
logger.debug("Unable to list git branches. return code: %s, message: %s",
retcode,
stdout.decode(locale.getpreferredencoding(),
errors="replace").strip().replace("\n", " - "))
return None
return stdout.decode(locale.getpreferredencoding(), errors="replace")

@classmethod
def _filter_branches(cls, stdout: str) -> T.List[str]:
""" Filter the branches, remove duplicates and the current branch and return a sorted
list.
Parameters
----------
stdout: str
The output from the git branch query converted to a string
Returns
-------
list[str]
Unique list of available branches sorted in alphabetical order
"""
current = None
branches = set()
for line in stdout.splitlines():
branch = line[line.rfind("/") + 1:] if "/" in line else line.strip()
if branch.startswith("*"):
branch = branch.replace("*", "").strip()
current = branch
continue
branches.add(branch)
logger.debug("Found branches: %s", branches)
if current in branches:
logger.debug("Removing current branch from output: %s", current)
branches.remove(current)

retval = sorted(list(branches), key=str.casefold)
logger.debug("Final branches: %s", retval)
return retval

@classmethod
def _switch_branch(cls, branch: str) -> None:
""" Change the currently checked out branch, and return a notification.
Parameters
----------
str
The branch to switch to
"""
logger.info("Switching branch to '%s'...", branch)
gitcmd = f"git checkout {branch}"
with Popen(gitcmd, shell=True, stdout=PIPE, stderr=STDOUT, cwd=_WORKING_DIR) as cmd:
stdout, _ = cmd.communicate()
retcode = cmd.poll()
if retcode != 0:
logger.error("Unable to switch branch. return code: %s, message: %s",
retcode,
stdout.decode(T.cast(str, locale.getdefaultlocale()),
errors="replace").strip().replace("\n", " - "))
return
logger.info("Succesfully switched to '%s'. You may want to check for updates to make sure "
"that you have the latest code.", branch)
logger.info("Please restart Faceswap to complete the switch.")

def _build_recources_menu(self) -> None:
""" Build resources menu """
# pylint: disable=cell-var-from-loop
Expand Down
28 changes: 14 additions & 14 deletions requirements/_requirements_base.txt
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
tqdm>=4.64
psutil>=5.9.0
numexpr>=2.7.3; python_version < '3.9' # >=2.8.0 conflicts in Conda
numexpr>=2.8.3; python_version >= '3.9'
opencv-python>=4.6.0.0
pillow>=9.2.0
tqdm>=4.64,<=4.65.0
psutil==5.9.0
numexpr>=2.7.3,<2.8.0; python_version < '3.9' # >=2.8.0 conflicts in Conda
numexpr>=2.8.3,<2.8.5; python_version >= '3.9'
opencv-python>=4.6.0.0,<=4.7.0.72
pillow>=9.2.0,<=9.4.0
scikit-learn==1.0.2; python_version < '3.9' # AMD needs version 1.0.2 and 1.1.0 not available in Python 3.7
scikit-learn>=1.1.0; python_version >= '3.9'
fastcluster>=1.2.6
scikit-learn>=1.1.0,<=1.2.2; python_version >= '3.9'
fastcluster==1.2.6
matplotlib>=3.4.3,<3.6.0; python_version < '3.9' # >=3.5.0 conflicts in Conda
matplotlib>=3.5.1,<3.6.0; python_version >= '3.9'
imageio>=2.19.3
imageio-ffmpeg>=0.4.7
ffmpy>=0.3.0
imageio>=2.19.3,<=2.26.0
imageio-ffmpeg>=0.4.7,<=0.4.8
ffmpy==0.3.0
# Exclude badly numbered Python2 version of nvidia-ml-py
nvidia-ml-py>=11.515,<300
tensorflow-probability<0.17
typing-extensions>=4.0.0
pywin32>=228 ; sys_platform == "win32"
tensorflow-probability>=0.14.0,<0.17
typing-extensions>=4.0.0,<=4.6.3
pywin32>=228,<=305 ; sys_platform == "win32"
6 changes: 3 additions & 3 deletions requirements/requirements_apple_silicon.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ numpy>=1.22.0,<1.24.0; python_version >= '3.8'
tensorflow-macos>=2.8.0,<2.11.0
tensorflow-deps>=2.8.0,<2.11.0
tensorflow-metal>=0.4.0,<0.7.0
libblas # Conda only
libblas==3.9.0 # Conda only
# These next 2 should have been installed, but some users complain of errors
decorator
cloudpickle
decorator>=4.4.0,<=5.1.1
cloudpickle>=2.0.0,<=2.2.1
4 changes: 2 additions & 2 deletions requirements/requirements_directml.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
numpy>=1.21.0,<1.24.0; python_version < '3.8'
numpy>=1.22.0,<1.24.0; python_version >= '3.8'
tensorflow-cpu>=2.10.0,<2.11.0
tensorflow-directml-plugin
comtypes
tensorflow-directml-plugin==0.4.0.dev230202
comtypes==1.1.10
34 changes: 0 additions & 34 deletions update_deps.py

This file was deleted.

0 comments on commit e8dd50d

Please sign in to comment.