nat-n / poethepoet

A task runner that works well with poetry.
https://poethepoet.natn.io/
MIT License
1.4k stars 58 forks source link

Investigate making the implementation of shell tasks more window friendly. #1

Closed nat-n closed 4 years ago

nat-n commented 4 years ago

This code hasn't been tested on windows and probably won't work, but it probably could. A windows developer is needed to try it out and find a more robust cross platform solution.

abn commented 4 years ago

Posting details of a failed CI run to help with debugging the issue.

2020-07-25T23:22:40.6982019Z �[36;1mpoetry run poe generate�[0m
2020-07-25T23:22:40.6982120Z �[36;1mpoetry run poe test�[0m
2020-07-25T23:22:40.6992850Z shell: C:\Program Files\Git\bin\bash.EXE --noprofile --norc -e -o pipefail {0}
2020-07-25T23:22:40.6992971Z env:
2020-07-25T23:22:40.6993123Z   pythonLocation: C:\hostedtoolcache\windows\Python\3.7.8\x64
2020-07-25T23:22:40.6993807Z   PATH: /c/Users/runneradmin/.poetry/bin:/mingw64/bin:/usr/bin:/c/Users/runneradmin/bin:/c/Users/runneradmin/AppData/Roaming/Python/Python37/Scripts:/c/hostedtoolcache/windows/Python/3.7.8/x64/Scripts:/c/hostedtoolcache/windows/Python/3.7.8/x64:/c/Program Files/Mercurial:/c/Program Files/MongoDB/Server/4.2/bin:/c/ProgramData/kind:/c/vcpkg:/c/cf-cli:/c/Program Files (x86)/NSIS:/c/Program Files/Mercurial:/c/hostedtoolcache/windows/stack/2.3.1/x64:/c/ProgramData/chocolatey/lib/ghc.8.10.1/tools/ghc-8.10.1/bin:/c/Program Files/dotnet:/c/mysql-5.7.21-winx64/bin:/c/Program Files/Java/jdk8u262-b10/bin:/c/SeleniumWebDrivers/GeckoDriver:/c/Program Files (x86)/sbt/bin:/c/Rust/.cargo/bin:/c/Program Files (x86)/GitHub CLI:/bin:/c/hostedtoolcache/windows/go/1.14.4/x64/bin:/c/hostedtoolcache/windows/Python/3.7.8/x64/Scripts:/c/hostedtoolcache/windows/Python/3.7.8/x64:/c/hostedtoolcache/windows/Ruby/2.5.8/x64/bin:/c/npm/prefix:/c/Program Files (x86)/Microsoft SDKs/Azure/CLI2/wbin:/c/windows/system32:/c/windows:/c/windows/System32/Wbem:/c/windows/System32/WindowsPowerShell/v1.0:/c/windows/System32/OpenSSH:/c/ProgramData/Chocolatey/bin:/c/Program Files/Docker:/c/Program Files/PowerShell/7:/c/Program Files/dotnet:/c/Program Files/Microsoft SQL Server/130/Tools/Binn:/c/Program Files/Microsoft SQL Server/Client SDK/ODBC/170/Tools/Binn:/c/Program Files (x86)/Microsoft SQL Server/110/DTS/Binn:/c/Program Files (x86)/Microsoft SQL Server/120/DTS/Binn:/c/Program Files (x86)/Microsoft SQL Server/130/DTS/Binn:/c/Program Files (x86)/Microsoft SQL Server/140/DTS/Binn:/c/Program Files (x86)/Microsoft SQL Server/150/DTS/Binn:/c/Program Files (x86)/Windows Kits/10/Windows Performance Toolkit:/c/Program Files/Microsoft Service Fabric/bin/Fabric/Fabric.Code:/c/Program Files/Microsoft SDKs/Service Fabric/Tools/ServiceFabricLocalClusterManager:/c/Program Files/nodejs:/c/Program Files/OpenSSL/bin:/c/Strawberry/c/bin:/c/Strawberry/perl/site/bin:/c/Strawberry/perl/bin:/cmd:/mingw64/bin:/usr/bin:/c/tools/php:/c/Program Files (x86)/sbt/bin:/c/Program Files (x86)/Subversion/bin:/c/SeleniumWebDrivers/ChromeDriver:/c/SeleniumWebDrivers/EdgeDriver:/c/ProgramData/chocolatey/lib/maven/apache-maven-3.6.3/bin:/c/Program Files/CMake/bin:/c/Program Files/Amazon/AWSCLIV2:/c/Program Files/Amazon/SessionManagerPlugin/bin:/c/Program Files/Amazon/AWSSAMCLI/bin:/c/Program Files (x86)/Google/Cloud SDK/google-cloud-sdk/bin:/c/Users/runneradmin/.dotnet/tools:/c/Users/runneradmin/AppData/Local/Microsoft/WindowsApps
2020-07-25T23:22:40.6994440Z ##[endgroup]
2020-07-25T23:22:41.6489510Z Poe => generate
2020-07-25T23:22:41.8304093Z Traceback (most recent call last):
2020-07-25T23:22:41.8305868Z   File "c:\hostedtoolcache\windows\python\3.7.8\x64\lib\runpy.py", line 193, in _run_module_as_main
2020-07-25T23:22:41.8306265Z     "__main__", mod_spec)
2020-07-25T23:22:41.8306568Z   File "c:\hostedtoolcache\windows\python\3.7.8\x64\lib\runpy.py", line 85, in _run_code
2020-07-25T23:22:41.8306795Z     exec(code, run_globals)
2020-07-25T23:22:41.8307048Z   File "d:\a\python-betterproto\python-betterproto\.venv\Scripts\poe.exe\__main__.py", line 7, in <module>
2020-07-25T23:22:41.8307329Z   File "d:\a\python-betterproto\python-betterproto\.venv\lib\site-packages\poethepoet\__init__.py", line 10, in main
2020-07-25T23:22:41.8307559Z     result = app(cli_args=sys.argv[1:])
2020-07-25T23:22:41.8307813Z   File "d:\a\python-betterproto\python-betterproto\.venv\lib\site-packages\poethepoet\app.py", line 50, in __call__
2020-07-25T23:22:41.8308032Z     self.run_task()
2020-07-25T23:22:41.8309712Z   File "d:\a\python-betterproto\python-betterproto\.venv\lib\site-packages\poethepoet\app.py", line 78, in run_task
2020-07-25T23:22:41.8310465Z     dry=self.ui["dry_run"],
2020-07-25T23:22:41.8310794Z   File "d:\a\python-betterproto\python-betterproto\.venv\lib\site-packages\poethepoet\task\base.py", line 106, in run
2020-07-25T23:22:41.8311042Z     self._handle_run(list(extra_args), project_dir, env, dry)
2020-07-25T23:22:41.8311321Z   File "d:\a\python-betterproto\python-betterproto\.venv\lib\site-packages\poethepoet\task\script.py", line 47, in _handle_run
2020-07-25T23:22:41.8311557Z     self._execute(project_dir, cmd, env)
2020-07-25T23:22:41.8311816Z   File "d:\a\python-betterproto\python-betterproto\.venv\lib\site-packages\poethepoet\task\base.py", line 170, in _execute
2020-07-25T23:22:41.8312042Z     return poetry_env.execute(*cmd, env=env)
2020-07-25T23:22:41.8312299Z   File "d:\a\python-betterproto\python-betterproto\.venv\lib\site-packages\poetry\utils\env.py", line 1099, in execute
2020-07-25T23:22:41.8312535Z     return super(VirtualEnv, self).execute(bin, *args, **kwargs)
2020-07-25T23:22:41.8312796Z   File "d:\a\python-betterproto\python-betterproto\.venv\lib\site-packages\poetry\utils\env.py", line 907, in execute
2020-07-25T23:22:41.8313023Z     exe = subprocess.Popen([bin] + list(args), **kwargs)
2020-07-25T23:22:41.8313270Z   File "c:\hostedtoolcache\windows\python\3.7.8\x64\lib\subprocess.py", line 800, in __init__
2020-07-25T23:22:41.8313487Z     restore_signals, start_new_session)
2020-07-25T23:22:41.8313740Z   File "c:\hostedtoolcache\windows\python\3.7.8\x64\lib\subprocess.py", line 1207, in _execute_child
2020-07-25T23:22:41.8313956Z     startupinfo)
2020-07-25T23:22:41.8314150Z TypeError: environment can only contain strings
2020-07-25T23:22:41.9184342Z ##[error]Process completed with exit code 1.
2020-07-25T23:22:41.9326103Z Post job cleanup.
2020-07-25T23:22:42.1988296Z Cleaning up orphan processes
abn commented 4 years ago

@nat-n you can consider looking at https://github.com/python-poetry/poetry/blob/master/poetry/utils/shell.py on how shell is handled.

nat-n commented 4 years ago

@abn Thanks for the help.

This change adds support for running shell tasks via git-bash or wsl bash if available on windows, and also adds windows environments to CI and fixes various other issues encountered for windows.

It also removes the dependency on poetry and instead uses the poetry run cli for running tasks from outside of the target env.