mirror of
https://github.com/ynput/ayon-core.git
synced 2025-12-25 05:14:40 +01:00
Merged in Aardschok/config/sixfix (pull request #27)
Conflict with six.py and http.py
This commit is contained in:
commit
694d909307
1 changed files with 51 additions and 2 deletions
|
|
@ -1,11 +1,11 @@
|
|||
import os
|
||||
import site
|
||||
import uuid
|
||||
|
||||
from maya import cmds
|
||||
|
||||
from avalon import maya, io, api as avalon
|
||||
from pyblish import api as pyblish
|
||||
|
||||
from maya import cmds
|
||||
|
||||
from . import menu
|
||||
from . import lib
|
||||
|
|
@ -19,6 +19,52 @@ LOAD_PATH = os.path.join(PLUGINS_DIR, "maya", "load")
|
|||
CREATE_PATH = os.path.join(PLUGINS_DIR, "maya", "create")
|
||||
|
||||
|
||||
# This is a temporary solution with the http.py clash with six.py
|
||||
# Maya has added paths to the PYTHONPATH which are redundant as
|
||||
# many of them are paths from a pacakge, example:
|
||||
# "/some/awesome/package/core/" which should be "/some/awesome/package"
|
||||
|
||||
|
||||
def _remove_from_paths(paths, keyword, stitch=False):
|
||||
"""Remove any paths which contain the given keyword
|
||||
|
||||
>>> paths = ["foo\\foo\\foo.py", "foo\\foobar.py", "\\bar\\bar\\foo"]
|
||||
>>> _remove_from_paths(paths, keyword="bar")
|
||||
["foo\\foo\\foo.py"]
|
||||
|
||||
>>> paths = ["foo\\bar\\foobar.py", "foo\\foobar.py", "\\banana\\pie\\delicious"]
|
||||
>>> _remove_from_paths(paths, keyword="pie", stitch=True)
|
||||
"foo\\bar\\foobar.py;foo\\foobar.py"
|
||||
|
||||
Args:
|
||||
paths(list) : a list of file paths
|
||||
keyword(str) : the word to check for
|
||||
stitch(bool) : recreate a full string for PYTHONPATH
|
||||
|
||||
Returns:
|
||||
str
|
||||
Only when stitch is set to True does the function return a string
|
||||
"""
|
||||
|
||||
paths = [path for path in paths if keyword not in path]
|
||||
if stitch:
|
||||
return os.pathsep.join(paths)
|
||||
|
||||
|
||||
def remove_googleapiclient():
|
||||
"""Remove any paths which contain `googleclientapi`"""
|
||||
|
||||
keyword = "googleclientapi"
|
||||
# remove from sys.path
|
||||
# _remove_from_paths(sys.path, keyword)
|
||||
|
||||
# reconstruct pythonpaths
|
||||
pythonpaths = os.environ["PYTHONPATH"].split(os.pathsep)
|
||||
result = _remove_from_paths(pythonpaths, keyword, stitch=True)
|
||||
|
||||
os.environ["PYTHONPATH"] = result
|
||||
|
||||
|
||||
def install():
|
||||
|
||||
pyblish.register_plugin_path(PUBLISH_PATH)
|
||||
|
|
@ -32,6 +78,9 @@ def install():
|
|||
avalon.on("new", on_new)
|
||||
avalon.on("save", on_save)
|
||||
|
||||
if cmds.about(version=True) == "2018":
|
||||
remove_googleapiclient()
|
||||
|
||||
|
||||
def uninstall():
|
||||
pyblish.deregister_plugin_path(PUBLISH_PATH)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue