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

Fails to build on Windows: FromUtf8Error #1403

Closed
rtentser opened this issue Jan 26, 2021 · 5 comments · Fixed by #1405
Closed

Fails to build on Windows: FromUtf8Error #1403

rtentser opened this issue Jan 26, 2021 · 5 comments · Fixed by #1405
Labels

Comments

@rtentser
Copy link

rtentser commented Jan 26, 2021

🐛 Bug Reports

error: failed to run custom build command for `pyo3 v0.13.1`

Caused by:
  process didn't exit successfully: `C:\Users\Рома\Sources\helloCargo\target\debug\build\pyo3-44c835d8235e3b6f\build-script-build` (exit code: 1)
  --- stderr
  Error: FromUtf8Error { bytes: [118, 101, 114, 115, 105, 111, 110, 95, 109, 97, 106, 111, 114, 32, 51, 13, 10, 118, 101, 114, 115, 105, 111, 110, 95, 109, 105, 110, 111, 114, 32, 56, 13, 10, 105, 109, 112, 108, 101, 109, 101, 
110, 116, 97, 116, 105, 111, 110, 32, 67, 80, 121, 116, 104, 111, 110, 13, 10, 108, 100, 95, 118, 101, 114, 115, 105, 111, 110, 32, 51, 46, 56, 13, 10, 98, 97, 115, 101, 95, 112, 114, 101, 102, 105, 120, 32, 67, 58, 92, 85, 115, 101, 114, 115, 92, 208, 238, 236, 224, 92, 65, 112, 112, 68, 97, 116, 97, 92, 76, 111, 99, 97, 108, 92, 80, 114, 111, 103, 114, 97, 109, 115, 92, 80, 121, 116, 104, 111, 110, 92, 80, 121, 116, 104, 111, 110, 51, 56, 13, 10, 102, 114, 97, 109, 101, 119, 111, 114, 107, 32, 70, 97, 108, 115, 101, 13, 10, 115, 104, 97, 114, 101, 100, 32, 70, 97, 108, 115, 101, 13, 10, 101, 120, 101, 99, 117, 116, 97, 98, 108, 101, 32, 67, 58, 92, 85, 115, 101, 114, 115, 92, 208, 238, 236, 224, 92, 65, 112, 112, 68, 97, 116, 97, 92, 76, 111, 99, 97, 108, 92, 80, 114, 111, 103, 114, 97, 109, 115, 92, 80, 121, 116, 104, 111, 110, 92, 80, 121, 116, 104, 111, 110, 51, 56, 92, 112, 121, 116, 104, 
111, 110, 46, 101, 120, 101, 13, 10, 99, 97, 108, 99, 115, 105, 122, 101, 95, 112, 111, 105, 110, 116, 101, 114, 32, 56, 13, 10], error: Utf8Error { valid_up_to: 95, error_len: Some(1) } }
warning: build failed, waiting for other jobs to finish...
error: build failed

🌍 Environment

  • Your operating system and version:
    Windows 10

  • Your python version:
    3.8.7

  • How did you install python (e.g. apt or pyenv)? Did you use a virtualenv?:
    Manual installation (exe from official site).

  • Your Rust version (rustc --version):
    1.49.0 (e1884a8e3 2020-12-29)

  • Your PyO3 version:
    0.12.4, 0.13.1

  • Have you tried using latest PyO3 master (replace version = "0.x.y" with git = "https://github.com/PyO3/pyo3")?:
    Yes. Same error.

💥 Reproducing

Just add

[dependencies.pyo3]
version = "0.13"
features = ["extension-module"]

to a project generated by cargo new and build.

@davidhewitt
Copy link
Member

Thanks for the report. It looks to me like the PyO3 build script is incorrect here to be using String::from_utf8 on line 584.

This playground containing the bytes and using from_utf8_lossy shows that it's the filesystem paths which are causing issues. https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=2a4c45bd2580b60f1d4df2c7110c6f6d

May I ask what system encoding you're using? I would guess Windows-1251, by comparing the problematic bytes.

@rtentser
Copy link
Author

Yes, it can be. I've made a mistake of using cyrillic username when installed the system.

@davidhewitt
Copy link
Member

@rtentser can you please try using the branch in #1405 on your system to confirm it fixes the bug?

The following in your Cargo.toml should be enough:

pyo3 = { git = "https://github.com/davidhewitt/pyo3", branch = "build-script-encoding" }

@rtentser
Copy link
Author

Yes, it builds now. Thank you!

@davidhewitt
Copy link
Member

Perfect, thanks for the bug report and confirming the fix!

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

Successfully merging a pull request may close this issue.

2 participants