3

我尝试构建 Dockerfile,但遇到如下错误:

pynacl 的构建轮子失败

这是我的setup.py文件的样子

FROM python:3.6-alpine                                                          

WORKDIR /app                                                                    

COPY ./requirements.txt /app                                                    

RUN apk --no-cache add shadow \                                                 
    gcc \                                                                       
    musl-dev \                                                                  
    postgresql-dev \                                                            
    python3-dev \                                                               
    freetype-dev \                                                              
    libffi-dev \                                                                
    tiff \                                                                      
    tiff-dev \                                                                  
    tk-dev \                                                                    
    tcl-dev \                                                                   
    postgresql \                                                                
    postgresql-dev \                                                            
    jpeg \                                                                      
    jpeg-dev \                                                                  
    zlib \                                                                      
    zlib-dev \                                                                  
    nodejs \                                                                    
    yarn \                                                                      
    && addgroup -g 1000 -S www-data \                                           
    && adduser -u 1000 -S -G www-data www-data \                                
    && pip install --no-cache-dir --upgrade 'pip<19.0' \                        
    && pip install pynacl \                                                     
    && pip install --no-cache-dir -r requirements.txt \                         
    && apk del //\                                                              
        gcc \                                                                   
        musl-dev \                                                              
        tiff-dev \                                                              
        tcl-dev \                                                               
        jpeg-dev \                                                              
        zlib-dev \                                                              
        postgresql-dev \                                                        
    && rm -rf /var/cache/apk/*                                                  

RUN chown www-data:www-data .                                                   
USER www-data                                                                   

COPY --chown=www-data:www-data . /app

堆栈跟踪:

Collecting pynacl
  Downloading https://files.pythonhosted.org/packages/61/ab/2ac6dea8489fa713e2b4c6c5b549cc962dd4a842b5998d9e80cf8440b7cd/PyNaCl-1.3.0.tar.gz (3.4MB)
  Installing build dependencies: started
  Installing build dependencies: finished with status 'done'
Collecting six (from pynacl)
  Downloading https://files.pythonhosted.org/packages/73/fb/00a976f728d0d1fecfe898238ce23f502a721c0ac0ecfedb80e0d88c64e9/six-1.12.0-py2.py3-none-any.whl
Collecting cffi>=1.4.1 (from pynacl)
Collecting pycparser (from cffi>=1.4.1->pynacl)
Building wheels for collected packages: pynacl
  Running setup.py bdist_wheel for pynacl: started
  Running setup.py bdist_wheel for pynacl: finished with status 'error'
  Complete output from command /usr/local/bin/python -u -c "import setuptools, tokenize;__file__='/tmp/pip-install-7r8c18od/pynacl/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" bdist_wheel -d /tmp/pip-wheel-qkz_jt0z --python-tag cp36:
  running bdist_wheel
  running build
  running build_py
  creating build
  creating build/lib.linux-x86_64-3.6
  creating build/lib.linux-x86_64-3.6/nacl
  copying src/nacl/secret.py -> build/lib.linux-x86_64-3.6/nacl
  copying src/nacl/public.py -> build/lib.linux-x86_64-3.6/nacl
  copying src/nacl/utils.py -> build/lib.linux-x86_64-3.6/nacl
  copying src/nacl/encoding.py -> build/lib.linux-x86_64-3.6/nacl
  copying src/nacl/hash.py -> build/lib.linux-x86_64-3.6/nacl
  copying src/nacl/hashlib.py -> build/lib.linux-x86_64-3.6/nacl
  copying src/nacl/exceptions.py -> build/lib.linux-x86_64-3.6/nacl
  copying src/nacl/__init__.py -> build/lib.linux-x86_64-3.6/nacl
  copying src/nacl/signing.py -> build/lib.linux-x86_64-3.6/nacl
  creating build/lib.linux-x86_64-3.6/nacl/pwhash
  copying src/nacl/pwhash/scrypt.py -> build/lib.linux-x86_64-3.6/nacl/pwhash
  copying src/nacl/pwhash/_argon2.py -> build/lib.linux-x86_64-3.6/nacl/pwhash
  copying src/nacl/pwhash/argon2id.py -> build/lib.linux-x86_64-3.6/nacl/pwhash
  copying src/nacl/pwhash/__init__.py -> build/lib.linux-x86_64-3.6/nacl/pwhash
  copying src/nacl/pwhash/argon2i.py -> build/lib.linux-x86_64-3.6/nacl/pwhash
  creating build/lib.linux-x86_64-3.6/nacl/bindings
  copying src/nacl/bindings/crypto_secretbox.py -> build/lib.linux-x86_64-3.6/nacl/bindings
  copying src/nacl/bindings/crypto_box.py -> build/lib.linux-x86_64-3.6/nacl/bindings
  copying src/nacl/bindings/crypto_secretstream.py -> build/lib.linux-x86_64-3.6/nacl/bindings
  copying src/nacl/bindings/crypto_shorthash.py -> build/lib.linux-x86_64-3.6/nacl/bindings
  copying src/nacl/bindings/utils.py -> build/lib.linux-x86_64-3.6/nacl/bindings
  copying src/nacl/bindings/sodium_core.py -> build/lib.linux-x86_64-3.6/nacl/bindings
  copying src/nacl/bindings/crypto_scalarmult.py -> build/lib.linux-x86_64-3.6/nacl/bindings
  copying src/nacl/bindings/crypto_aead.py -> build/lib.linux-x86_64-3.6/nacl/bindings
  copying src/nacl/bindings/crypto_kx.py -> build/lib.linux-x86_64-3.6/nacl/bindings
  copying src/nacl/bindings/randombytes.py -> build/lib.linux-x86_64-3.6/nacl/bindings
  copying src/nacl/bindings/crypto_sign.py -> build/lib.linux-x86_64-3.6/nacl/bindings
  copying src/nacl/bindings/crypto_generichash.py -> build/lib.linux-x86_64-3.6/nacl/bindings
  copying src/nacl/bindings/crypto_hash.py -> build/lib.linux-x86_64-3.6/nacl/bindings
  copying src/nacl/bindings/__init__.py -> build/lib.linux-x86_64-3.6/nacl/bindings
  copying src/nacl/bindings/crypto_pwhash.py -> build/lib.linux-x86_64-3.6/nacl/bindings
  running build_clib
  Traceback (most recent call last):
    File "<string>", line 1, in <module>
    File "/tmp/pip-install-7r8c18od/pynacl/setup.py", line 255, in <module>
      "Programming Language :: Python :: 3.7",
    File "/tmp/pip-build-env-ju2hmy_4/lib/python3.6/site-packages/setuptools/__init__.py", line 143, in setup
      return distutils.core.setup(**attrs)
    File "/usr/local/lib/python3.6/distutils/core.py", line 148, in setup
      dist.run_commands()
    File "/usr/local/lib/python3.6/distutils/dist.py", line 955, in run_commands
      self.run_command(cmd)
    File "/usr/local/lib/python3.6/distutils/dist.py", line 974, in run_command
      cmd_obj.run()
    File "/tmp/pip-build-env-ju2hmy_4/lib/python3.6/site-packages/wheel/bdist_wheel.py", line 188, in run
      self.run_command('build')
    File "/usr/local/lib/python3.6/distutils/cmd.py", line 313, in run_command
      self.distribution.run_command(command)
    File "/usr/local/lib/python3.6/distutils/dist.py", line 974, in run_command
      cmd_obj.run()
    File "/usr/local/lib/python3.6/distutils/command/build.py", line 135, in run
      self.run_command(cmd_name)
    File "/usr/local/lib/python3.6/distutils/cmd.py", line 313, in run_command
      self.distribution.run_command(command)
    File "/usr/local/lib/python3.6/distutils/dist.py", line 974, in run_command
      cmd_obj.run()
    File "/tmp/pip-install-7r8c18od/pynacl/setup.py", line 159, in run
      raise Exception("ERROR: The 'make' utility is missing from PATH")
  Exception: ERROR: The 'make' utility is missing from PATH

  ----------------------------------------
  Failed building wheel for pynacl
  Running setup.py clean for pynacl
Failed to build pynacl
Installing collected packages: six, pycparser, cffi, pynacl
  Running setup.py install for pynacl: started
    Running setup.py install for pynacl: finished with status 'error'
    Complete output from command /usr/local/bin/python -u -c "import setuptools, tokenize;__file__='/tmp/pip-install-7r8c18od/pynacl/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-record-idro8sp8/install-record.txt --single-version-externally-managed --compile:
    running install
    running build
    running build_py
    creating build
    creating build/lib.linux-x86_64-3.6
    creating build/lib.linux-x86_64-3.6/nacl
    copying src/nacl/secret.py -> build/lib.linux-x86_64-3.6/nacl
    copying src/nacl/public.py -> build/lib.linux-x86_64-3.6/nacl
    copying src/nacl/utils.py -> build/lib.linux-x86_64-3.6/nacl
    copying src/nacl/encoding.py -> build/lib.linux-x86_64-3.6/nacl
    copying src/nacl/hash.py -> build/lib.linux-x86_64-3.6/nacl
    copying src/nacl/hashlib.py -> build/lib.linux-x86_64-3.6/nacl
    copying src/nacl/exceptions.py -> build/lib.linux-x86_64-3.6/nacl
    copying src/nacl/__init__.py -> build/lib.linux-x86_64-3.6/nacl
    copying src/nacl/signing.py -> build/lib.linux-x86_64-3.6/nacl
    creating build/lib.linux-x86_64-3.6/nacl/pwhash
    copying src/nacl/pwhash/scrypt.py -> build/lib.linux-x86_64-3.6/nacl/pwhash
    copying src/nacl/pwhash/_argon2.py -> build/lib.linux-x86_64-3.6/nacl/pwhash
    copying src/nacl/pwhash/argon2id.py -> build/lib.linux-x86_64-3.6/nacl/pwhash
    copying src/nacl/pwhash/__init__.py -> build/lib.linux-x86_64-3.6/nacl/pwhash
    copying src/nacl/pwhash/argon2i.py -> build/lib.linux-x86_64-3.6/nacl/pwhash
    creating build/lib.linux-x86_64-3.6/nacl/bindings
    copying src/nacl/bindings/crypto_secretbox.py -> build/lib.linux-x86_64-3.6/nacl/bindings
    copying src/nacl/bindings/crypto_box.py -> build/lib.linux-x86_64-3.6/nacl/bindings
    copying src/nacl/bindings/crypto_secretstream.py -> build/lib.linux-x86_64-3.6/nacl/bindings
    copying src/nacl/bindings/crypto_shorthash.py -> build/lib.linux-x86_64-3.6/nacl/bindings
    copying src/nacl/bindings/utils.py -> build/lib.linux-x86_64-3.6/nacl/bindings
    copying src/nacl/bindings/sodium_core.py -> build/lib.linux-x86_64-3.6/nacl/bindings
    copying src/nacl/bindings/crypto_scalarmult.py -> build/lib.linux-x86_64-3.6/nacl/bindings
    copying src/nacl/bindings/crypto_aead.py -> build/lib.linux-x86_64-3.6/nacl/bindings
    copying src/nacl/bindings/crypto_kx.py -> build/lib.linux-x86_64-3.6/nacl/bindings
    copying src/nacl/bindings/randombytes.py -> build/lib.linux-x86_64-3.6/nacl/bindings
    copying src/nacl/bindings/crypto_sign.py -> build/lib.linux-x86_64-3.6/nacl/bindings
    copying src/nacl/bindings/crypto_generichash.py -> build/lib.linux-x86_64-3.6/nacl/bindings
    copying src/nacl/bindings/crypto_hash.py -> build/lib.linux-x86_64-3.6/nacl/bindings
    copying src/nacl/bindings/__init__.py -> build/lib.linux-x86_64-3.6/nacl/bindings
    copying src/nacl/bindings/crypto_pwhash.py -> build/lib.linux-x86_64-3.6/nacl/bindings
    running build_clib
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/tmp/pip-install-7r8c18od/pynacl/setup.py", line 255, in <module>
        "Programming Language :: Python :: 3.7",
      File "/tmp/pip-build-env-ju2hmy_4/lib/python3.6/site-packages/setuptools/__init__.py", line 143, in setup
        return distutils.core.setup(**attrs)
      File "/usr/local/lib/python3.6/distutils/core.py", line 148, in setup
        dist.run_commands()
      File "/usr/local/lib/python3.6/distutils/dist.py", line 955, in run_commands
        self.run_command(cmd)
      File "/usr/local/lib/python3.6/distutils/dist.py", line 974, in run_command
        cmd_obj.run()
      File "/tmp/pip-build-env-ju2hmy_4/lib/python3.6/site-packages/setuptools/command/install.py", line 61, in run
        return orig.install.run(self)
      File "/usr/local/lib/python3.6/distutils/command/install.py", line 545, in run
        self.run_command('build')
      File "/usr/local/lib/python3.6/distutils/cmd.py", line 313, in run_command
        self.distribution.run_command(command)
      File "/usr/local/lib/python3.6/distutils/dist.py", line 974, in run_command
        cmd_obj.run()
      File "/usr/local/lib/python3.6/distutils/command/build.py", line 135, in run
        self.run_command(cmd_name)
      File "/usr/local/lib/python3.6/distutils/cmd.py", line 313, in run_command
        self.distribution.run_command(command)
      File "/usr/local/lib/python3.6/distutils/dist.py", line 974, in run_command
        cmd_obj.run()
      File "/tmp/pip-install-7r8c18od/pynacl/setup.py", line 159, in run
        raise Exception("ERROR: The 'make' utility is missing from PATH")
    Exception: ERROR: The 'make' utility is missing from PATH

    ----------------------------------------
Command "/usr/local/bin/python -u -c "import setuptools, tokenize;__file__='/tmp/pip-install-7r8c18od/pynacl/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-record-idro8sp8/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /tmp/pip-install-7r8c18od/pynacl/
You are using pip version 18.1, however version 19.0.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
4

1 回答 1

4

在您的日志中,您可以看到:

Exception: ERROR: The 'make' utility is missing from PATH

在调用 pip 之前,您需要安装make(当然还有其他工具)来编译 pynacl。

于 2019-01-25T07:11:34.917 回答