From cd15d111f3b835b336dc6536e7bc0d6fd7cab634 Mon Sep 17 00:00:00 2001 From: Ondrej Samohel Date: Tue, 12 Jan 2021 12:00:40 +0100 Subject: [PATCH] move acre and pyblish-base to requirements --- .gitmodules | 7 ----- build.ps1 | 74 +++++++++++++++++++++++++++++++++++++----------- igniter/tools.py | 4 +-- requirements.txt | 2 ++ setup.py | 4 +-- start.py | 1 - 6 files changed, 64 insertions(+), 28 deletions(-) diff --git a/.gitmodules b/.gitmodules index f08a36506c..20aa3a3e8d 100644 --- a/.gitmodules +++ b/.gitmodules @@ -2,19 +2,12 @@ path = repos/avalon-core url = git@github.com:pypeclub/avalon-core.git branch = develop -[submodule "repos/pyblish-base"] - path = repos/pyblish-base - url = git@github.com:pyblish/pyblish-base.git [submodule "repos/avalon-unreal-integration"] path = repos/avalon-unreal-integration url = git@github.com:pypeclub/avalon-unreal-integration.git [submodule "repos/maya-look-assigner"] path = repos/maya-look-assigner url = git@github.com:pypeclub/maya-look-assigner.git -[submodule "repos/acre"] - path = repos/acre - url = git@github.com:antirotor/acre.git - branch = fix/unformatted-tokens [submodule "pype/modules/ftrack/python2_vendor/ftrack-python-api"] path = pype/modules/ftrack/python2_vendor/ftrack-python-api url = https://bitbucket.org/ftrack/ftrack-python-api.git diff --git a/build.ps1 b/build.ps1 index 39ce90e36a..ec118a43f3 100644 --- a/build.ps1 +++ b/build.ps1 @@ -13,7 +13,6 @@ PS> .\build.ps1 #> - function Exit-WithCode($exitcode) { # Only exit this host process if it's a child of another PowerShell parent process... $parentPID = (Get-CimInstance -ClassName Win32_Process -Filter "ProcessId=$PID" | Select-Object -Property ParentProcessId).ParentProcessId @@ -23,6 +22,18 @@ function Exit-WithCode($exitcode) { exit $exitcode } +if ($PSVersionTable.PSVersion.Major -lt 7) { + Write-Host "!!! " -NoNewline -ForegroundColor Red + Write-Host "You are using old version of PowerShell. $($PSVersionTable.PSVersion.Major).$($PSVersionTable.PSVersion.Minor)" + Write-Host "Please update to at least 7.0 - https://github.com/PowerShell/PowerShell/releases" + Exit-WithCode 1 +} + +$arguments=$ARGS +if($arguments -eq "--skip-venv") { + $skip_venv=$true +} + $art = @' @@ -76,22 +87,39 @@ if(($matches[1] -lt 3) -or ($matches[2] -lt 7)) { Exit-WithCode 1 } Write-Host "OK [ $p ]" -ForegroundColor green -Write-Host ">>> " -NoNewline -ForegroundColor green -Write-Host "Creating virtual env ..." -& python -m venv venv -Write-Host ">>> " -NoNewline -ForegroundColor green -Write-Host "Entering venv ..." -try { - . (".\venv\Scripts\Activate.ps1") + + +if ($skip_venv -ne $true) { + Write-Host ">>> " -NoNewline -ForegroundColor green + Write-Host "Creating virtual env ..." + & python -m venv venv + Write-Host ">>> " -NoNewline -ForegroundColor green + Write-Host "Entering venv ..." + try { + . (".\venv\Scripts\Activate.ps1") + } + catch { + Write-Host "!!! Failed to activate" -ForegroundColor red + Write-Host $_.Exception.Message + Exit-WithCode 1 + } + Write-Host ">>> " -NoNewline -ForegroundColor green + Write-Host "Installing packages to new venv ..." + & pip install -r .\requirements.txt +} else { + Write-Host "*** " -NoNewline -ForegroundColor yellow + Write-Host "Skipping creaton of venv ..." + Write-Host ">>> " -NoNewline -ForegroundColor green + Write-Host "Entering venv ..." + try { + . (".\venv\Scripts\Activate.ps1") + } + catch { + Write-Host "!!! Failed to activate" -ForegroundColor red + Write-Host $_.Exception.Message + Exit-WithCode 1 + } } -catch { - Write-Host "!!! Failed to activate" -ForegroundColor red - Write-Host $_.Exception.Message - Exit-WithCode 1 -} -Write-Host ">>> " -NoNewline -ForegroundColor green -Write-Host "Installing packages to new venv ..." -& pip install -r .\requirements.txt Write-Host ">>> " -NoNewline -ForegroundColor green Write-Host "Cleaning cache files ... " -NoNewline @@ -99,7 +127,21 @@ Get-ChildItem . -Filter "*.pyc" -Force -Recurse | Remove-Item -Force Get-ChildItem . -Filter "__pycache__" -Force -Recurse | Remove-Item -Force -Recurse Write-Host "OK" -ForegroundColor green +# store original PYTHONPATH +Write-Host ">>> " -NoNewline -ForegroundColor green +Write-Host "Storing original PYTHONPATH ... " -NoNewline +$original_pythonpath = $env:PYTHONPATH +Write-Host "OK" -ForegroundColor green +$new_pythonpath = Get-ChildItem -Directory -Path .\ | Microsoft.PowerShell.Utility\Join-String -Property FullName -DoubleQuote -Separator ';' +$env:PYTHONPATH = $env:PYTHONPATH + ";" + $new_pythonpath +Write-Host ">>> " -NoNewline -ForegroundColor green +Write-Host "Adding repos to PYTHONPATH ..." + Write-Host ">>> " -NoNewline -ForegroundColor green Write-Host "Building Pype ..." & python setup.py build +Write-Host ">>> " -NoNewline -ForegroundColor green +Write-Host "Restoring original PYTHONPATH ... " -NoNewline +$env:PYTHONPATH = $original_pythonpath +Write-Host "OK" -ForegroundColor green deactivate diff --git a/igniter/tools.py b/igniter/tools.py index a06c444e62..387a1934b1 100644 --- a/igniter/tools.py +++ b/igniter/tools.py @@ -82,13 +82,13 @@ def validate_path_string(path: str) -> (bool, str): def add_acre_to_sys_path(): - """Add full path of acre module to sys.path on ignitation.""" + """Add full path of acre module to sys.path on ignition.""" try: # Skip if is possible to import import acre except ImportError: - # Full path to acred repository related to current file + # Full path to acre repository related to current file acre_dir = os.path.join( os.path.dirname(os.path.dirname(os.path.abspath(__file__))), "repos", diff --git a/requirements.txt b/requirements.txt index f7d46a8dcc..3263431948 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,3 +1,4 @@ +git+https://github.com/antirotor/acre.git@fix/unformatted-tokens aiohttp aiohttp_json_rpc appdirs @@ -18,6 +19,7 @@ log4mongo git+https://github.com/pypeclub/OpenTimelineIO.git@develop pathlib2 Pillow +pyblish-base pycodestyle pydocstyle pylint diff --git a/setup.py b/setup.py index 287f8706c8..964c088e4f 100644 --- a/setup.py +++ b/setup.py @@ -73,8 +73,8 @@ buildOptions = dict( executables = [ - Executable("start.py", base=None, targetName="pype_console"), - Executable("start.py", base=base, targetName="pype") + Executable("start.py", base=None, target_name="pype_console"), + Executable("start.py", base=base, target_name="pype") ] setup( diff --git a/start.py b/start.py index dc34c51ba7..b18e908417 100644 --- a/start.py +++ b/start.py @@ -110,7 +110,6 @@ def set_environments() -> None: better handling of environments """ - # FIXME: remove everything except global env = load_environments(["global"]) env = acre.merge(env, dict(os.environ)) os.environ.clear()