Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support command execution on Windows #156

Merged
merged 7 commits into from
Oct 14, 2021
Merged

Conversation

priitlatt
Copy link
Contributor

@priitlatt priitlatt commented Oct 5, 2021

In most cases the tools provided by this module are actually just more user-friendy wrappers for some other executables in the system. As such, much of the heavylifting is done by the CliProcess class, which unfortunately currently does not work on Windows:

In [1]: from codemagic.cli import CliProcess
---------------------------------------------------------------------------
ModuleNotFoundError                       Traceback (most recent call last)
<ipython-input-1-dbc669446119> in <module>
----> 1 from codemagic.cli import CliProcess

c:\users\administrator\.pyenv\pyenv-win\versions\3.9.6\lib\site-packages\codemagic\cli\__init__.py in <module>
      6 from .argument import EnvironmentArgumentValue
      7 from .argument import TypedCliArgument
----> 8 from .cli_app import CliApp
      9 from .cli_app import CliAppException
     10 from .cli_app import action

c:\users\administrator\.pyenv\pyenv-win\versions\3.9.6\lib\site-packages\codemagic\cli\cli_app.py in <module>
     34 from .argument import ArgumentFormatter
     35 from .cli_help_formatter import CliHelpFormatter
---> 36 from .cli_process import CliProcess
     37 from .cli_types import CommandArg
     38 from .cli_types import ObfuscatedCommand

c:\users\administrator\.pyenv\pyenv-win\versions\3.9.6\lib\site-packages\codemagic\cli\cli_process.py in <module>
      3 from __future__ import annotations
      4
----> 5 import fcntl
      6 import os
      7 import shlex

ModuleNotFoundError: No module named 'fcntl'

The exception above is caused because reading executed command stderr and stdout was implemented for Unix file descriptors only, which rely on fcntl. However on Windows the command streams have Win32 named pipes in the background.

To overcome this, an abstraction layer was added in the form of CliProcessStream, which takes care of platform specific code for unblocking the streams and reading from them.

@priitlatt priitlatt changed the title Import fcntl locally Support command execution on Windows Oct 13, 2021
@priitlatt priitlatt added bug Something isn't working enhancement New feature or request labels Oct 13, 2021
@priitlatt priitlatt marked this pull request as ready for review October 13, 2021 13:55
@priitlatt priitlatt merged commit 50e45d2 into master Oct 14, 2021
@priitlatt priitlatt deleted the bugfix/windows-support branch October 14, 2021 07:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants