4

我正在将 Poetry 安装在我的 Raspberry pi 3b+(Lite buster 2020 年 2 月)的容器中。我使用图像arm32v7/python:3.7-slim-buster

这是Dockerfile

FROM arm32v7/python:3.7-slim-buster
RUN apt-get update
RUN apt-get install libssl-dev -y
RUN apt-get install libffi-dev
RUN apt-get install build-essential -y
RUN pip install poetry
RUN pip install --upgrade pip

COPY ./pyproject.toml /app/
WORKDIR /app/
RUN poetry install --no-dev

COPY ./rpiserver /app/rpiserver
RUN poetry install --no-dev
ENTRYPOINT poetry

当 docker 运行该步骤时,poetry install --no-dev它会安装许多包,包括orjson(2.6.3),它需要“Rust nightly 工具链”。所以失败了!

这是错误消息:

Writing lock file


Package operations: 33 installs, 0 updates, 0 removals

  - Installing six (1.14.0)
  - Installing promise (2.3)
  - Installing rx (1.6.1)
  - Installing graphql-core (2.3.1)
  - Installing aniso8601 (7.0.0)
  - Installing certifi (2019.11.28)
  - Installing chardet (3.0.4)
  - Installing click (7.1.1)
  - Installing dnspython (1.16.0)
  - Installing graphql-relay (2.0.1)
  - Installing h11 (0.9.0)
  - Installing httptools (0.1.1)
  - Installing idna (2.9)
  - Installing markupsafe (1.1.1)
  - Installing urllib3 (1.25.8)
  - Installing uvloop (0.14.0)
  - Installing websockets (8.1)
  - Installing aiofiles (0.4.0)
  - Installing async-exit-stack (1.0.1)
  - Installing async-generator (1.10)
  - Installing email-validator (1.0.5)
  - Installing graphene (2.1.8)
  - Installing itsdangerous (1.1.0)
  - Installing jinja2 (2.11.1)
  - Installing orjson (2.6.3)

[EnvCommandError]
Command ['/root/.cache/pypoetry/virtualenvs/rpiserver-9TtSrW0h-py3.7/bin/pip', 'install', '--no-deps', 'orjson==2.6.3'] errored with the following return code 1, and output: 
Collecting orjson==2.6.3
  Downloading https://files.pythonhosted.org/packages/8e/7c/e9a6f52e344c480be42fddeb1a0593283ecc1c06293ef210af4521a5b6f5/orjson-2.6.3.tar.gz (526kB)
  Installing build dependencies: started
  Installing build dependencies: finished with status 'error'
  ERROR: Command errored out with exit status 1:
   command: /root/.cache/pypoetry/virtualenvs/rpiserver-9TtSrW0h-py3.7/bin/python /root/.cache/pypoetry/virtualenvs/rpiserver-9TtSrW0h-py3.7/lib/python3.7/site-packages/pip install --ignore-installed --no-user --prefix /tmp/pip-build-env-wsqo2pr0/overlay --no-warn-script-location --no-binary :none: --only-binary :none: -i https://pypi.org/simple -- 'maturin>=0.7.9,<0.8'
       cwd: None
  Complete output (60 lines):
  Collecting maturin<0.8,>=0.7.9
    Downloading https://files.pythonhosted.org/packages/a1/ab/531984f5c304e56b47da35df5ea3ed8d862d114551720a434ebb34ce44db/maturin-0.7.9.tar.gz (80kB)
    Installing build dependencies: started
    Installing build dependencies: finished with status 'done'
    Getting requirements to build wheel: started
    Getting requirements to build wheel: finished with status 'done'
      Preparing wheel metadata: started
      Preparing wheel metadata: finished with status 'done'
  Collecting toml~=0.10.0 (from maturin<0.8,>=0.7.9)
    Downloading https://files.pythonhosted.org/packages/a2/12/ced7105d2de62fa7c8fb5fce92cc4ce66b57c95fb875e9318dba7f8c5db0/toml-0.10.0-py2.py3-none-any.whl
  Building wheels for collected packages: maturin
    Building wheel for maturin (PEP 517): started
    Building wheel for maturin (PEP 517): finished with status 'error'
    ERROR: Command errored out with exit status 1:
     command: /root/.cache/pypoetry/virtualenvs/rpiserver-9TtSrW0h-py3.7/bin/python /root/.cache/pypoetry/virtualenvs/rpiserver-9TtSrW0h-py3.7/lib/python3.7/site-packages/pip/_vendor/pep517/_in_process.py build_wheel /tmp/tmp2f8vk9ny
         cwd: /tmp/pip-install-aos7ep0k/maturin
    Complete output (36 lines):
    running bdist_wheel
    running build
    installing to build/bdist.linux-armv7l/wheel
    running install
    Traceback (most recent call last):
      File "/root/.cache/pypoetry/virtualenvs/rpiserver-9TtSrW0h-py3.7/lib/python3.7/site-packages/pip/_vendor/pep517/_in_process.py", line 207, in <module>
        main()
      File "/root/.cache/pypoetry/virtualenvs/rpiserver-9TtSrW0h-py3.7/lib/python3.7/site-packages/pip/_vendor/pep517/_in_process.py", line 197, in main
        json_out['return_val'] = hook(**hook_input['kwargs'])
      File "/root/.cache/pypoetry/virtualenvs/rpiserver-9TtSrW0h-py3.7/lib/python3.7/site-packages/pip/_vendor/pep517/_in_process.py", line 141, in build_wheel
        metadata_directory)
      File "/tmp/pip-build-env-txy57zgb/overlay/lib/python3.7/site-packages/setuptools/build_meta.py", line 209, in build_wheel
        wheel_directory, config_settings)
      File "/tmp/pip-build-env-txy57zgb/overlay/lib/python3.7/site-packages/setuptools/build_meta.py", line 194, in _build_with_temp_dir
        self.run_setup()
      File "/tmp/pip-build-env-txy57zgb/overlay/lib/python3.7/site-packages/setuptools/build_meta.py", line 142, in run_setup
        exec(compile(code, __file__, 'exec'), locals())
      File "setup.py", line 97, in <module>
        zip_safe=False,
      File "/tmp/pip-build-env-txy57zgb/overlay/lib/python3.7/site-packages/setuptools/__init__.py", line 145, in setup
        return distutils.core.setup(**attrs)
      File "/usr/local/lib/python3.7/distutils/core.py", line 148, in setup
        dist.run_commands()
      File "/usr/local/lib/python3.7/distutils/dist.py", line 966, in run_commands
        self.run_command(cmd)
      File "/usr/local/lib/python3.7/distutils/dist.py", line 985, in run_command
        cmd_obj.run()
      File "/tmp/pip-build-env-txy57zgb/overlay/lib/python3.7/site-packages/wheel/bdist_wheel.py", line 228, in run
        self.run_command('install')
      File "/usr/local/lib/python3.7/distutils/cmd.py", line 313, in run_command
        self.distribution.run_command(command)
      File "/usr/local/lib/python3.7/distutils/dist.py", line 985, in run_command
        cmd_obj.run()
      File "setup.py", line 54, in run
        "cargo not found in PATH. Please install rust "
    RuntimeError: cargo not found in PATH. Please install rust (https://www.rust-lang.org/tools/install) and try again
    ----------------------------------------
    ERROR: Failed building wheel for maturin
    Running setup.py clean for maturin
  Failed to build maturin
  ERROR: Could not build wheels for maturin which use PEP 517 and cannot be installed directly
  WARNING: You are using pip version 19.2.3, however version 20.0.2 is available.
  You should consider upgrading via the 'pip install --upgrade pip' command.
  ----------------------------------------
ERROR: Command errored out with exit status 1: /root/.cache/pypoetry/virtualenvs/rpiserver-9TtSrW0h-py3.7/bin/python /root/.cache/pypoetry/virtualenvs/rpiserver-9TtSrW0h-py3.7/lib/python3.7/site-packages/pip install --ignore-installed --no-user --prefix /tmp/pip-build-env-wsqo2pr0/overlay --no-warn-script-location --no-binary :none: --only-binary :none: -i https://pypi.org/simple -- 'maturin>=0.7.9,<0.8' Check the logs for full command output.
WARNING: You are using pip version 19.2.3, however version 20.0.2 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.

ERROR: Service 'server' failed to build: The command '/bin/sh -c poetry install --no-dev' returned a non-zero code: 1

我没有找到任何说要安装 Rust 的 Poetry 文档(因为orjson需要maturin,哪个需要cargo,哪个需要 Rust?对吗?)。

为了解决这个问题,我决定通过编辑 Dockerfile 在我的镜像中安装cargomaturin

但是我遇到了一个新问题。

这是我的 Dockerfile:

FROM arm32v7/python:3.7-slim-buster
RUN apt-get update
RUN apt-get install libssl-dev -y
RUN apt-get install libffi-dev
RUN apt-get install build-essential -y
RUN pip install poetry
RUN pip install --upgrade pip

COPY ./pyproject.toml /app/
WORKDIR /app/
RUN apt-get install cargo -y
RUN pip install maturin
RUN poetry install --no-dev

COPY ./rpiserver /app/rpiserver
RUN poetry install --no-dev
ENTRYPOINT poetry

这是错误消息:

Building wheels for collected packages: maturin
  Building wheel for maturin (PEP 517): started
  Building wheel for maturin (PEP 517): still running...
  Building wheel for maturin (PEP 517): still running...
  Building wheel for maturin (PEP 517): finished with status 'error'
  ERROR: Command errored out with exit status 1:
   command: /usr/local/bin/python /usr/local/lib/python3.7/site-packages/pip/_vendor/pep517/_in_process.py build_wheel /tmp/tmp6vyv1zmu
       cwd: /tmp/pip-install-cqvpc5wg/maturin
  Complete output (369 lines):
  running bdist_wheel
  running build
  installing to build/bdist.linux-armv7l/wheel
  running install
      Updating crates.io index
   Downloading crates ...
    Downloaded serde_json v1.0.50
    Downloaded sha2 v0.8.1
    Downloaded shlex v0.1.1
    Downloaded failure v0.1.7
    Downloaded walkdir v2.3.1
    Downloaded tempfile v3.1.0
    Downloaded cargo_metadata v0.9.1
    Downloaded bytesize v1.0.0
    Downloaded digest v0.8.1
    Downloaded toml v0.5.6
    Downloaded zip v0.5.5
    Downloaded structopt v0.3.12
    Downloaded serde v1.0.105
    Downloaded flate2 v1.0.14
    Downloaded base64 v0.12.0
    Downloaded regex v1.3.6
    Downloaded reqwest v0.10.4
    Downloaded tar v0.4.26
    Downloaded rpassword v4.0.5
    Downloaded cbindgen v0.13.2
    Downloaded platform-info v0.0.1
    Downloaded platforms v0.2.1
    Downloaded goblin v0.2.1
    Downloaded pretty_env_logger v0.4.0
    Downloaded serde_derive v1.0.105
    Downloaded crc32fast v1.2.0
    Downloaded ryu v1.0.3
    Downloaded bytes v0.5.4
    Downloaded proc-macro2 v1.0.10
    Downloaded cfg-if v0.1.10
    Downloaded generic-array v0.12.3
    Downloaded rand v0.7.3
    Downloaded time v0.1.42
    Downloaded futures-util v0.3.4
    Downloaded pin-project-lite v0.1.4
    Downloaded mime v0.3.16
    Downloaded url v2.1.1
    Downloaded serde_urlencoded v0.6.1
    Downloaded lazy_static v1.4.0
    Downloaded mime_guess v2.0.3
    Downloaded http-body v0.3.1
    Downloaded failure_derive v0.1.7
    Downloaded same-file v1.0.6
    Downloaded thread_local v1.0.1
    Downloaded opaque-debug v0.2.3
    Downloaded block-buffer v0.7.3
    Downloaded percent-encoding v2.1.0
    Downloaded semver v0.9.0
    Downloaded remove_dir_all v0.5.2
    Downloaded futures-core v0.3.4
    Downloaded bzip2 v0.3.3
    Downloaded base64 v0.11.0
    Downloaded structopt-derive v0.4.5
    Downloaded xattr v0.2.2
    Downloaded filetime v0.2.9
    Downloaded miniz_oxide v0.3.6
    Downloaded log v0.4.8
    Downloaded quote v1.0.3
    Downloaded itoa v0.4.5
    Downloaded podio v0.1.6
    Downloaded memchr v2.3.3
    Downloaded aho-corasick v0.7.10
    Downloaded clap v2.33.0
    Downloaded fake-simd v0.1.2
    Downloaded tokio-rustls v0.13.0
    Downloaded hyper-rustls v0.20.0
    Downloaded http v0.2.1
    Downloaded backtrace v0.3.46
    Downloaded tokio v0.2.15
    Downloaded hyper v0.13.4
    Downloaded webpki-roots v0.18.0
    Downloaded syn v1.0.17
    Downloaded regex-syntax v0.6.17
    Downloaded rustls v0.17.0
    Downloaded libc v0.2.68
    Downloaded env_logger v0.7.1
    Downloaded adler32 v1.0.4
    Downloaded getrandom v0.1.14
    Downloaded rand_core v0.5.1
    Downloaded fnv v1.0.6
    Downloaded rand_chacha v0.2.2
    Downloaded typenum v1.11.2
    Downloaded slab v0.4.2
    Downloaded webpki v0.21.2
    Downloaded iovec v0.1.4
    Downloaded want v0.3.0
    Downloaded proc-macro-nested v0.1.4
    Downloaded ct-logs v0.6.0
    Downloaded futures-channel v0.3.4
    Downloaded httparse v1.3.4
    Downloaded textwrap v0.11.0
    Downloaded bitflags v1.2.1
    Downloaded rustc-demangle v0.1.16
    Downloaded unicode-width v0.1.7
    Downloaded ansi_term v0.11.0
    Downloaded net2 v0.2.33
    Downloaded pin-project v0.4.8
    Downloaded dtoa v0.4.5
    Downloaded atty v0.2.14
    Downloaded vec_map v0.8.1
    Downloaded pin-utils v0.1.0-alpha.4
    Downloaded strsim v0.8.0
    Downloaded futures-macro v0.3.4
    Downloaded proc-macro-hack v0.5.15
    Downloaded futures-io v0.3.4
    Downloaded unicase v2.6.0
    Downloaded tower-service v0.3.0
    Downloaded num_cpus v1.12.0
    Downloaded scroll v0.10.1
    Downloaded semver-parser v0.7.0
    Downloaded byteorder v1.3.4
    Downloaded synstructure v0.12.3
    Downloaded proc-macro-error v0.4.12
    Downloaded futures-task v0.3.4
    Downloaded unicode-xid v0.2.0
    Downloaded byte-tools v0.3.1
    Downloaded matches v0.1.8
    Downloaded mio v0.6.21
    Downloaded heck v0.3.1
    Downloaded block-padding v0.1.5
    Downloaded plain v0.2.3
    Downloaded rustls-native-certs v0.3.0
    Downloaded h2 v0.2.4
    Downloaded idna v0.2.0
    Downloaded bzip2-sys v0.1.8+1.0.8
    Downloaded encoding_rs v0.8.22
    Downloaded termcolor v1.1.0
    Downloaded humantime v1.3.0
    Downloaded sct v0.6.0
    Downloaded openssl-probe v0.1.2
    Downloaded tokio-util v0.3.1
    Downloaded try-lock v0.2.2
    Downloaded ppv-lite86 v0.2.6
    Downloaded version_check v0.9.1
    Downloaded unicode-bidi v0.3.4
    Downloaded futures-sink v0.3.4
    Downloaded pin-project-internal v0.4.8
    Downloaded proc-macro-error-attr v0.4.12
    Downloaded scroll_derive v0.10.1
    Downloaded indexmap v1.3.2
    Downloaded untrusted v0.7.0
    Downloaded unicode-segmentation v1.6.0
    Downloaded unicode-normalization v0.1.12
    Downloaded winapi v0.3.8
    Downloaded backtrace-sys v0.1.35
    Downloaded quick-error v1.2.3
    Downloaded syn-mid v0.5.0
    Downloaded autocfg v1.0.0
    Downloaded cc v1.0.50
    Downloaded smallvec v1.2.0
    Downloaded ring v0.16.12
    Downloaded spin v0.5.2
     Compiling libc v0.2.68
     Compiling proc-macro2 v1.0.10
     Compiling log v0.4.8
     Compiling unicode-xid v0.2.0
     Compiling memchr v2.3.3
     Compiling syn v1.0.17
     Compiling cc v1.0.50
     Compiling cfg-if v0.1.10
     Compiling autocfg v1.0.0
     Compiling slab v0.4.2
     Compiling proc-macro-nested v0.1.4
     Compiling version_check v0.9.1
     Compiling getrandom v0.1.14
     Compiling spin v0.5.2
     Compiling bytes v0.5.4
  error[E0432]: unresolved import `std::io::IoSlice`
   --> /root/.cargo/registry/src/github.com-1ecc6299db9ec823/bytes-0.5.4/src/buf/buf_impl.rs:4:5
    |
  4 | use std::io::IoSlice;
    |     ^^^^^^^^^^^^^^^^ no `IoSlice` in `io`

  error[E0432]: unresolved import `std::io::IoSlice`
   --> /root/.cargo/registry/src/github.com-1ecc6299db9ec823/bytes-0.5.4/src/buf/ext/chain.rs:7:15
    |
  7 | use std::io::{IoSlice};
    |               ^^^^^^^ no `IoSlice` in `io`

  error[E0433]: failed to resolve: could not find `IoSliceMut` in `io`
      --> /root/.cargo/registry/src/github.com-1ecc6299db9ec823/bytes-0.5.4/src/buf/buf_mut.rs:1075:29
       |
  1075 |         IoSliceMut(std::io::IoSliceMut::new(buf))
       |                             ^^^^^^^^^^ could not find `IoSliceMut` in `io`

  error[E0433]: failed to resolve: could not find `IoSliceMut` in `io`
      --> /root/.cargo/registry/src/github.com-1ecc6299db9ec823/bytes-0.5.4/src/buf/buf_mut.rs:1082:29
       |
  1082 |         IoSliceMut(std::io::IoSliceMut::new(unsafe {
       |                             ^^^^^^^^^^ could not find `IoSliceMut` in `io`

  error[E0412]: cannot find type `IoSliceMut` in module `std::io`
      --> /root/.cargo/registry/src/github.com-1ecc6299db9ec823/bytes-0.5.4/src/buf/buf_mut.rs:1061:36
       |
  1061 | pub struct IoSliceMut<'a>(std::io::IoSliceMut<'a>);
       |                                    ^^^^^^^^^^ not found in `std::io`
  help: possible candidate is found in another module, you can import it into scope
       |
  1    | use crate::buf::buf_mut::IoSliceMut;
       |

  error[E0658]: naming constants with `_` is unstable (see issue #54912)
     --> /root/.cargo/registry/src/github.com-1ecc6299db9ec823/bytes-0.5.4/src/bytes.rs:911:1
      |
  911 | const _: [(); 0 - mem::align_of::<Shared>() % 2] = []; // Assert that the alignment of `Shared` is divisible by 2.
      | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

  error[E0658]: use of unstable library feature 'alloc': this library is unlikely to be stabilized in its current form or name (see issue #27783)
    --> /root/.cargo/registry/src/github.com-1ecc6299db9ec823/bytes-0.5.4/src/lib.rs:76:1
     |
  76 | extern crate alloc;
     | ^^^^^^^^^^^^^^^^^^^

  error[E0658]: use of unstable library feature 'maybe_uninit' (see issue #53491)
   --> /root/.cargo/registry/src/github.com-1ecc6299db9ec823/bytes-0.5.4/src/buf/buf_mut.rs:1:29
    |
  1 | use core::{cmp, mem::{self, MaybeUninit}, ptr, usize};
    |                             ^^^^^^^^^^^

  error[E0658]: use of unstable library feature 'maybe_uninit' (see issue #53491)
      --> /root/.cargo/registry/src/github.com-1ecc6299db9ec823/bytes-0.5.4/src/buf/buf_mut.rs:1080:24
       |
  1080 | impl<'a> From<&'a mut [MaybeUninit<u8>]> for IoSliceMut<'a> {
       |                        ^^^^^^^^^^^^^^^

  error[E0658]: use of unstable library feature 'maybe_uninit' (see issue #53491)
     --> /root/.cargo/registry/src/github.com-1ecc6299db9ec823/bytes-0.5.4/src/buf/buf_mut.rs:165:38
      |
  165 |     fn bytes_mut(&mut self) -> &mut [MaybeUninit<u8>];
      |                                      ^^^^^^^^^^^^^^^

  error[E0658]: use of unstable library feature 'maybe_uninit' (see issue #53491)
     --> /root/.cargo/registry/src/github.com-1ecc6299db9ec823/bytes-0.5.4/src/buf/buf_mut.rs:970:38
      |
  970 |     fn bytes_mut(&mut self) -> &mut [MaybeUninit<u8>] {
      |                                      ^^^^^^^^^^^^^^^

  error[E0658]: use of unstable library feature 'maybe_uninit' (see issue #53491)
      --> /root/.cargo/registry/src/github.com-1ecc6299db9ec823/bytes-0.5.4/src/buf/buf_mut.rs:1003:38
       |
  1003 |     fn bytes_mut(&mut self) -> &mut [MaybeUninit<u8>] {
       |                                      ^^^^^^^^^^^^^^^

  error[E0658]: use of unstable library feature 'maybe_uninit' (see issue #53491)
      --> /root/.cargo/registry/src/github.com-1ecc6299db9ec823/bytes-0.5.4/src/buf/buf_mut.rs:1013:45
       |
  1013 |         let ptr = self.as_mut_ptr() as *mut MaybeUninit<u8>;
       |                                             ^^^^^^^^^^^^^^^

  error[E0658]: use of unstable library feature 'maybe_uninit' (see issue #53491)
      --> /root/.cargo/registry/src/github.com-1ecc6299db9ec823/bytes-0.5.4/src/buf/buf_mut.rs:1081:27
       |
  1081 |     fn from(buf: &'a mut [MaybeUninit<u8>]) -> IoSliceMut<'a> {
       |                           ^^^^^^^^^^^^^^^

  error[E0658]: use of unstable library feature 'maybe_uninit' (see issue #53491)
      --> /root/.cargo/registry/src/github.com-1ecc6299db9ec823/bytes-0.5.4/src/buf/buf_mut.rs:1085:39
       |
  1085 |             mem::transmute::<&'a mut [MaybeUninit<u8>], &'a mut [u8]>(buf)
       |                                       ^^^^^^^^^^^^^^^

  error[E0658]: use of unstable library feature 'maybe_uninit' (see issue #53491)
     --> /root/.cargo/registry/src/github.com-1ecc6299db9ec823/bytes-0.5.4/src/buf/buf_mut.rs:880:38
      |
  880 |     fn bytes_mut(&mut self) -> &mut [MaybeUninit<u8>] {
      |                                      ^^^^^^^^^^^^^^^
  ...
  956 |     deref_forward_bufmut!();
      |     ------------------------ in this macro invocation

  error[E0658]: use of unstable library feature 'maybe_uninit' (see issue #53491)
     --> /root/.cargo/registry/src/github.com-1ecc6299db9ec823/bytes-0.5.4/src/buf/buf_mut.rs:880:38
      |
  880 |     fn bytes_mut(&mut self) -> &mut [MaybeUninit<u8>] {
      |                                      ^^^^^^^^^^^^^^^
  ...
  960 |     deref_forward_bufmut!();
      |     ------------------------ in this macro invocation

  error[E0658]: use of unstable library feature 'maybe_uninit' (see issue #53491)
   --> /root/.cargo/registry/src/github.com-1ecc6299db9ec823/bytes-0.5.4/src/buf/ext/chain.rs:4:5
    |
  4 | use core::mem::MaybeUninit;
    |     ^^^^^^^^^^^^^^^^^^^^^^

  error[E0658]: use of unstable library feature 'maybe_uninit' (see issue #53491)
     --> /root/.cargo/registry/src/github.com-1ecc6299db9ec823/bytes-0.5.4/src/buf/ext/chain.rs:189:38
      |
  189 |     fn bytes_mut(&mut self) -> &mut [MaybeUninit<u8>] {
      |                                      ^^^^^^^^^^^^^^^

  error[E0658]: use of unstable library feature 'maybe_uninit' (see issue #53491)
   --> /root/.cargo/registry/src/github.com-1ecc6299db9ec823/bytes-0.5.4/src/buf/ext/limit.rs:3:17
    |
  3 | use core::{cmp, mem::MaybeUninit};
    |                 ^^^^^^^^^^^^^^^^

  error[E0658]: use of unstable library feature 'maybe_uninit' (see issue #53491)
    --> /root/.cargo/registry/src/github.com-1ecc6299db9ec823/bytes-0.5.4/src/buf/ext/limit.rs:66:38
     |
  66 |     fn bytes_mut(&mut self) -> &mut [MaybeUninit<u8>] {
     |                                      ^^^^^^^^^^^^^^^

  error[E0658]: use of unstable library feature 'maybe_uninit' (see issue #53491)
     --> /root/.cargo/registry/src/github.com-1ecc6299db9ec823/bytes-0.5.4/src/bytes_mut.rs:909:47
      |
  909 |     fn maybe_uninit_bytes(&mut self) -> &mut [mem::MaybeUninit<u8>] {
      |                                               ^^^^^^^^^^^^^^^^^^^^

  error[E0658]: use of unstable library feature 'maybe_uninit' (see issue #53491)
     --> /root/.cargo/registry/src/github.com-1ecc6299db9ec823/bytes-0.5.4/src/bytes_mut.rs:914:51
      |
  914 |             slice::from_raw_parts_mut(ptr as *mut mem::MaybeUninit<u8>, len)
      |                                                   ^^^^^^^^^^^^^^^^^^^^

  error[E0658]: use of unstable library feature 'maybe_uninit' (see issue #53491)
     --> /root/.cargo/registry/src/github.com-1ecc6299db9ec823/bytes-0.5.4/src/bytes_mut.rs:977:38
      |
  977 |     fn bytes_mut(&mut self) -> &mut [mem::MaybeUninit<u8>] {
      |                                      ^^^^^^^^^^^^^^^^^^^^

     Compiling lazy_static v1.4.0
  error: aborting due to 24 previous errors

  Some errors occurred: E0412, E0432, E0433, E0658.
  For more information about an error, try `rustc --explain E0412`.
  error: Could not compile `bytes`.
  warning: build failed, waiting for other jobs to finish...
  error: build failed
  Traceback (most recent call last):
    File "/usr/local/lib/python3.7/site-packages/pip/_vendor/pep517/_in_process.py", line 257, in <module>
      main()
    File "/usr/local/lib/python3.7/site-packages/pip/_vendor/pep517/_in_process.py", line 240, in main
      json_out['return_val'] = hook(**hook_input['kwargs'])
    File "/usr/local/lib/python3.7/site-packages/pip/_vendor/pep517/_in_process.py", line 182, in build_wheel
      metadata_directory)
    File "/tmp/pip-build-env-fmh7uvxq/overlay/lib/python3.7/site-packages/setuptools/build_meta.py", line 209, in build_wheel
      wheel_directory, config_settings)
    File "/tmp/pip-build-env-fmh7uvxq/overlay/lib/python3.7/site-packages/setuptools/build_meta.py", line 194, in _build_with_temp_dir
      self.run_setup()
    File "/tmp/pip-build-env-fmh7uvxq/overlay/lib/python3.7/site-packages/setuptools/build_meta.py", line 142, in run_setup
      exec(compile(code, __file__, 'exec'), locals())
    File "setup.py", line 97, in <module>
      zip_safe=False,
    File "/tmp/pip-build-env-fmh7uvxq/overlay/lib/python3.7/site-packages/setuptools/__init__.py", line 145, in setup
      return distutils.core.setup(**attrs)
    File "/usr/local/lib/python3.7/distutils/core.py", line 148, in setup
      dist.run_commands()
    File "/usr/local/lib/python3.7/distutils/dist.py", line 966, in run_commands
      self.run_command(cmd)
    File "/usr/local/lib/python3.7/distutils/dist.py", line 985, in run_command
      cmd_obj.run()
    File "/tmp/pip-build-env-fmh7uvxq/overlay/lib/python3.7/site-packages/wheel/bdist_wheel.py", line 228, in run
      self.run_command('install')
    File "/usr/local/lib/python3.7/distutils/cmd.py", line 313, in run_command
      self.distribution.run_command(command)
    File "/usr/local/lib/python3.7/distutils/dist.py", line 985, in run_command
      cmd_obj.run()
    File "setup.py", line 58, in run
      ["cargo", "rustc", "--bin", "maturin", "--", "-C", "link-arg=-s"]
    File "/usr/local/lib/python3.7/subprocess.py", line 363, in check_call
      raise CalledProcessError(retcode, cmd)
  subprocess.CalledProcessError: Command '['cargo', 'rustc', '--bin', 'maturin', '--', '-C', 'link-arg=-s']' returned non-zero exit status 101.
  ----------------------------------------
  ERROR: Failed building wheel for maturin
Failed to build maturin
ERROR: Could not build wheels for maturin which use PEP 517 and cannot be installed directly
ERROR: Service 'server' failed to build: The command '/bin/sh -c pip install maturin' returned a non-zero code: 1

为什么在这种情况下我需要 Rust?

4

1 回答 1

1

诗歌不依赖于 Rust。

但是您依赖于orjson,它至少部分地在 Rust中实现。因此,从源代码安装它需要一个 Rust 工具链和maturin构建工具

像以前一样添加pip install maturin回您的项目,或者更好的是,将其添加到项目的依赖项中。Dockerfile

您还需要安装cargo. 多阶段构建可能是最好的解决方案,但最简单的可能是将软件包安装到现有映像中,例如通过类似

RUN apt-get install cargo

在你的Dockerfile.


¹二进制轮子可能可用于某些平台,在这种情况下可能不需要 Rust 工具,但由于pip尝试从源代码构建,我怀疑没有兼容的轮子可用于 ARM。

于 2020-04-04T17:03:21.837 回答