Skip to content

windows compatibility #288

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

Closed
sylvoslee opened this issue Jan 28, 2021 · 9 comments · Fixed by #287
Closed

windows compatibility #288

sylvoslee opened this issue Jan 28, 2021 · 9 comments · Fixed by #287
Assignees

Comments

@sylvoslee
Copy link

sylvoslee commented Jan 28, 2021

1.UnicodeDecodeError:

(debug) PS E:\project\debug> python test_idom.py
Traceback (most recent call last):
  File "test_idom.py", line 3, in <module>
    victory = idom.install("victory", fallback="loading...")
  File "C:\Users\Miniconda3\envs\debug\lib\site-packages\idom\client\module.py", line 44, in install
    Module(pkg_names.pop(), fallback=fallback)
  File "C:\Users\Miniconda3\envs\debug\lib\site-packages\idom\client\module.py", line 94, in __init__
    self._export_names = manage.web_module_exports(url_or_name)
  File "C:\Users\Miniconda3\envs\debug\lib\site-packages\idom\client\manage.py", line 24, in web_module_exports
    return find_js_module_exports_in_source(web_module_path(package_name).read_text())
  File "C:\Users\Miniconda3\envs\debug\lib\pathlib.py", line 1236, in read_text
    return f.read()
UnicodeDecodeError: 'gbk' codec can't decode byte 0x9d in position 424663: illegal multibyte sequence

I made the following change:
return find_js_module_exports_in_source(web_module_path(package_name).read_text(*encoding='utf-8'*))

2.FileNotFoundError: [WinError 2]:

Traceback (most recent call last):
  File "test_idom.py", line 3, in <module>
    material_ui = idom.install("@material-ui/core", fallback="loading...")
  File "C:\Users\Miniconda3\envs\debug\lib\site-packages\idom\client\module.py", line 41, in install
    manage.build(packages)
  File "C:\Users\Miniconda3\envs\debug\lib\site-packages\idom\client\manage.py", line 102, in build
    _npm_install(packages_to_install, temp_app_dir)
  File "C:\Users\Miniconda3\envs\debug\lib\site-packages\idom\client\manage.py", line 125, in _npm_install
    _run_subprocess(["npm", "install"] + packages, cwd)
  File "C:\Users\Miniconda3\envs\debug\lib\site-packages\idom\client\manage.py", line 134, in _run_subprocess
    subprocess.run(
  File "C:\Users\Miniconda3\envs\debug\lib\subprocess.py", line 489, in run
    with Popen(*popenargs, **kwargs) as process:
  File "C:\Users\Miniconda3\envs\debug\lib\subprocess.py", line 854, in __init__
    self._execute_child(args, executable, preexec_fn, close_fds,
  File "C:\Users\Miniconda3\envs\debug\lib\subprocess.py", line 1307, in _execute_child
    hp, ht, pid, tid = _winapi.CreateProcess(executable, args,
FileNotFoundError: [WinError 2] 

I made the following change:

def _run_subprocess(args: List[str], cwd: Path) -> None:
    try:
        subprocess.run(
            args, cwd=cwd, check=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE,*shell=True*
        )
    except subprocess.CalledProcessError as error:  # pragma: no cover
        raise subprocess.SubprocessError(error.stderr.decode()) from error
    return None

3.RuntimeError:

Traceback (most recent call last):
  File "test_idom.py", line 3, in <module>
    material_ui = idom.install("@material-ui/core", fallback="loading...")
  File "C:\Users\Miniconda3\envs\debug\lib\site-packages\idom\client\module.py", line 41, in install
    manage.build(packages)
  File "C:\Users\Miniconda3\envs\debug\lib\site-packages\idom\client\manage.py", line 118, in build
    raise RuntimeError(  # pragma: no cover
RuntimeError: Successfuly installed ['react-dom', '@material-ui/core', 'idom-client-react', 'react'] but failed to discover ['@material-ui/core'] post-install.
@rmorshea
Copy link
Collaborator

rmorshea commented Jan 28, 2021

Thanks! Will try and address this in a PR where I add Windows to my test suite: #287

@rmorshea
Copy link
Collaborator

@sylvoslee I might actually need some help to get things working. I've never used Python on Windows so I'm not really familiar with the quarks of that system. The first task would be to just get the test suite to run on Windows in CI as I'm doing in this PR #287, and then try to get the test suite to pass.

@rmorshea
Copy link
Collaborator

Also, are the issues your seeing limited to idom.install or are there other issues you're experiencing?

@rmorshea
Copy link
Collaborator

Woops accidentally closed

@rmorshea rmorshea reopened this Jan 30, 2021
@rmorshea
Copy link
Collaborator

Ok, so the suite now runs in CI. Only problem is all the tests that use selenium fail. I'm not really sure I can debug them further though without some help since there isn't really any useful information in the tracebacks. The only thing I can see is that the logs from the server show not all the files are being loaded.

On Windows:

[2021-01-30 00:32:17 -0000] - (sanic.access)[INFO][127.0.0.1:50486]: GET http://127.0.0.1:50482/  302 0
[2021-01-30 00:32:17 -0000] - (sanic.access)[INFO][127.0.0.1:50486]: GET http://127.0.0.1:50482/client/index.html  200 403
[2021-01-30 00:32:17 -0000] - (sanic.access)[INFO][127.0.0.1:50486]: GET http://127.0.0.1:50482/client/index.js  200 1016

On Linux:

[2021-01-29 16:40:55 -0800] - (sanic.access)[INFO][127.0.0.1:56132]: GET http://localhost:5000/  302 0
[2021-01-29 16:40:55 -0800] - (sanic.access)[INFO][127.0.0.1:56132]: GET http://localhost:5000/client/index.html  200 387
[2021-01-29 16:40:55 -0800] - (sanic.access)[INFO][127.0.0.1:56132]: GET http://localhost:5000/client/index.js  200 982
[2021-01-29 16:40:55 -0800] - (sanic.access)[INFO][127.0.0.1:56132]: GET http://localhost:5000/client/web_modules/idom-client-react.js  200 39291
[2021-01-29 16:40:55 -0800] - (sanic.access)[INFO][127.0.0.1:56132]: GET http://localhost:5000/client/web_modules/htm.js  200 1220
[2021-01-29 16:40:55 -0800] - (sanic.access)[INFO][127.0.0.1:56136]: GET http://localhost:5000/client/web_modules/common/index-6ed86a98.js  200 9836

Happy to hop on a call at some point to try and figure this out. Message me on Gitter and we can organize that: https://gitter.im/rmorshea

@sylvoslee
Copy link
Author

sylvoslee commented Jan 30, 2021

Tested the test-mac-windows branch,Only this one issue

Traceback (most recent call last):
  File "material_ui_button_no_action.py", line 3, in <module>
    material_ui = idom.install("@material-ui/core", fallback="loading...")
  File "E:\idom-test\idom\client\module.py", line 41, in install
    manage.build(packages)
  File "E:\idom-test\idom\client\manage.py", line 122, in build
    raise RuntimeError(  # pragma: no cover
RuntimeError: Successfuly installed ['idom-client-react', 'react-dom', '@material-ui/core', 'react', 'victory'] but failed to discover ['@material-ui/core'] post-install.

I guess it is caused by the difference in path representation. Windows uses "\" and Linux uses "/"

When package_names_to_install is compared with web_module_names()
'@material-ui/core' is different from '@material-ui\core'

package_names_to_install={'idom-client-react', 'react-dom', '@material-ui/core', 'react', 'victory'}
web_module_names()={'idom-client-react', 'react-dom', '@material-ui\core', 'htm', 'react', 'victory'}

@rmorshea
Copy link
Collaborator

rmorshea commented Jan 30, 2021

Fixed now I think. Hopefully that's been resolved.

The test suite is still failing for other reasons though. If you're able it'd be great to try and fix that so I can maintain Windows compatibility going forward.

@sylvoslee
Copy link
Author

yes,that's been resolved,thank you

@rmorshea
Copy link
Collaborator

So I just skipped the failing tests in the test suite for now and created a separate issue. #289

Unfortunately, because I don't have access to a Windows machine to resolve it myself, I'll just have to wait for some help me out.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants