使用GitHub Actions构建Lambda的Python应用程序在pipenv上失败。

huangapple go评论88阅读模式
英文:

Building Python app for Lambda using GitHub Actions fails on pipenv

问题

I'm using GitHub Actions to build a Docker container for a Python Lambda function. This same project worked fine when last built a year ago, but it is now failing. Another Lambda is also using the same Dockerfile and Pipfile today, but with typer instead of pysqlite3-binary, and that function works fine…

Dockerfile

  1. FROM public.ecr.aws/lambda/python:3.10 AS base
  2. # Set up environment
  3. ENV LANG C.UTF-8
  4. ENV LC_ALL C.UTF-8
  5. ENV PYTHONDONTWRITEBYTECODE 1
  6. ENV PYTHONFAULTHANDLER 1
  7. FROM base AS python-deps
  8. RUN pip install pipenv
  9. COPY Pipfile* ./
  10. RUN PIPENV_VENV_IN_PROJECT=1 pipenv install --deploy
  11. FROM base as runtime
  12. COPY --from=python-deps ${LAMBDA_TASK_ROOT}/.venv/lib/python*/site-packages ./
  13. COPY app app
  14. # Set the CMD to your handler (could also be done as a parameter override outside of the Dockerfile)
  15. CMD [ "app.app.handler" ]

Pipfile

  1. [[source]]
  2. url = "https://pypi.org/simple"
  3. verify_ssl = true
  4. name = "pypi"
  5. [packages]
  6. requests = "*"
  7. boto3 = "*"
  8. jinja2 = "*"
  9. pytz = "*"
  10. pysqlite3-binary = { version = "*", platform_machine = "== 'x86_64'" }
  11. [dev-packages]
  12. isort = "*"
  13. black = "*"
  14. flake8 = "*"
  15. [requires]
  16. python_version = "3.10"

When I make a change to the repo, the container gets re-built on GH and fails with this error:

  1. Status: Downloaded newer image for public.ecr.aws/lambda/python:3.10
  2. ---> ecba6236d1f5
  3. Step 2/13 : ENV LANG C.UTF-8
  4. ---> Running in bd0cb33a39b7
  5. Removing intermediate container bd0cb33a39b7
  6. ---> 5d5aafca5928
  7. ...
  8. ...

Please note that the content you provided includes code and terminal output, which is not recommended to be translated as it may lose its original meaning and context. If you have specific questions or need assistance with any part of this content, please feel free to ask.

英文:

I'm using GitHub Actions to build a Docker container for a Python Lambda function. This same project worked fine when last built a year ago, but it is now failing. Another Lambda is also using the same Dockerfile and Pipfile today, but with typer instead of pysqlite3-binary, and that function works fine…

Dockerfile

  1. FROM public.ecr.aws/lambda/python:3.10 AS base
  2. # Set up environment
  3. ENV LANG C.UTF-8
  4. ENV LC_ALL C.UTF-8
  5. ENV PYTHONDONTWRITEBYTECODE 1
  6. ENV PYTHONFAULTHANDLER 1
  7. FROM base AS python-deps
  8. RUN pip install pipenv
  9. COPY Pipfile* ./
  10. RUN PIPENV_VENV_IN_PROJECT=1 pipenv install --deploy
  11. FROM base as runtime
  12. COPY --from=python-deps ${LAMBDA_TASK_ROOT}/.venv/lib/python*/site-packages ./
  13. COPY app app
  14. # Set the CMD to your handler (could also be done as a parameter override outside of the Dockerfile)
  15. CMD [ "app.app.handler" ]

Pipfile

  1. [[source]]
  2. url = "https://pypi.org/simple"
  3. verify_ssl = true
  4. name = "pypi"
  5. [packages]
  6. requests = "*"
  7. boto3 = "*"
  8. jinja2 = "*"
  9. pytz = "*"
  10. pysqlite3-binary = { version = "*", platform_machine = "== 'x86_64'" }
  11. [dev-packages]
  12. isort = "*"
  13. black = "*"
  14. flake8 = "*"
  15. [requires]
  16. python_version = "3.10"

When I make a change to the repo, the container gets re-built on GH and fails with this error:

  1. Status: Downloaded newer image for public.ecr.aws/lambda/python:3.10
  2. ---> ecba6236d1f5
  3. Step 2/13 : ENV LANG C.UTF-8
  4. ---> Running in bd0cb33a39b7
  5. Removing intermediate container bd0cb33a39b7
  6. ---> 5d5aafca5928
  7. Step 3/13 : ENV LC_ALL C.UTF-8
  8. ---> Running in 13dfbc245a61
  9. Removing intermediate container 13dfbc245a61
  10. ---> 7e8a6fd1ec61
  11. Step 4/13 : ENV PYTHONDONTWRITEBYTECODE 1
  12. ---> Running in 900f2dff8a5d
  13. Removing intermediate container 900f2dff8a5d
  14. ---> 73f224622e4b
  15. Step 5/13 : ENV PYTHONFAULTHANDLER 1
  16. ---> Running in 3d811c817fa7
  17. Removing intermediate container 3d811c817fa7
  18. ---> 927e8c0bdb65
  19. Step 6/13 : FROM base AS python-deps
  20. ---> 927e8c0bdb65
  21. Step 7/13 : RUN pip install pipenv
  22. ---> Running in 20c336e3f13d
  23. Collecting pipenv
  24. Downloading pipenv-2023.6.2-py3-none-any.whl (2.9 MB)
  25. ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 2.9/2.9 MB 50.8 MB/s eta 0:00:00
  26. Collecting virtualenv-clone>=0.2.5
  27. Downloading virtualenv_clone-0.5.7-py3-none-any.whl (6.6 kB)
  28. Collecting virtualenv>=20.17.1
  29. Downloading virtualenv-20.23.0-py3-none-any.whl (3.3 MB)
  30. ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 3.3/3.3 MB 120.7 MB/s eta 0:00:00
  31. Collecting certifi
  32. Downloading certifi-2023.5.7-py3-none-any.whl (156 kB)
  33. ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 157.0/157.0 kB 47.2 MB/s eta 0:00:00
  34. Collecting setuptools>=67.0.0
  35. Downloading setuptools-67.8.0-py3-none-any.whl (1.1 MB)
  36. ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 1.1/1.1 MB 107.9 MB/s eta 0:00:00
  37. Collecting distlib<1,>=0.3.6
  38. Downloading distlib-0.3.6-py2.py3-none-any.whl (468 kB)
  39. ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 468.5/468.5 kB 84.2 MB/s eta 0:00:00
  40. Collecting filelock<4,>=3.11
  41. Downloading filelock-3.12.0-py3-none-any.whl (10 kB)
  42. Collecting platformdirs<4,>=3.2
  43. Downloading platformdirs-3.5.1-py3-none-any.whl (15 kB)
  44. Installing collected packages: distlib, virtualenv-clone, setuptools, platformdirs, filelock, certifi, virtualenv, pipenv
  45. Attempting uninstall: setuptools
  46. Found existing installation: setuptools 65.5.1
  47. Uninstalling setuptools-65.5.1:
  48. Successfully uninstalled setuptools-65.5.1
  49. Successfully installed certifi-2023.5.7 distlib-0.3.6 filelock-3.12.0 pipenv-2023.6.2 platformdirs-3.5.1 setuptools-67.8.0 virtualenv-20.23.0 virtualenv-clone-0.5.7
  50. WARNING: Running pip as the 'root' user can result in broken permissions and conflicting behaviour with the system package manager. It is recommended to use a virtual environment instead: https://pip.pypa.io/warnings/venv
  51. Notice: A new release of pip is available: 23.0.1 -> 23.1.2
  52. Notice: To update, run: pip install --upgrade pip
  53. Removing intermediate container 20c336e3f13d
  54. ---> 2b3608b3c998
  55. Step 8/13 : COPY Pipfile* ./
  56. ---> c00128bf188c
  57. Step 9/13 : RUN PIPENV_VENV_IN_PROJECT=1 pipenv install --deploy
  58. ---> Running in 28e5ca31efea
  59. Creating a virtualenv for this project...
  60. Pipfile: /var/task/Pipfile
  61. Using /var/lang/bin/python3 (3.10.11) to create virtualenv...
  62. created virtual environment CPython3.10.11.final.0-64 in 712ms
  63. creator CPython3Posix(dest=/var/task/.venv, clear=False, no_vcs_ignore=False, global=False)
  64. seeder FromAppData(download=False, pip=bundle, setuptools=bundle, wheel=bundle, via=copy, app_data_dir=/root/.local/share/virtualenv)
  65. added seed packages: pip==23.1.2, setuptools==67.7.2, wheel==0.40.0
  66. activators BashActivator,CShellActivator,FishActivator,NushellActivator,PowerShellActivator,PythonActivator
  67. Successfully created virtual environment!
  68. Virtualenv location: /var/task/.venv
  69. Installing dependencies from Pipfile.lock (fe6451)...
  70. An error occurred while installing boto3==1.26.147 --hash=sha256:45ed158defbf554d051c4f3eae9a1ca3c1039dd29a528e884f47a06ad0ac17a1 --hash=sha256:ccfbdb6e9ebdf943e222c88c9a8f161a8a607f3dbdbf3b1b0eed25c1d8cb215e! Will try again.
  71. An error occurred while installing botocore==1.29.147 ; python_version >= '3.7' --hash=sha256:67a7ce69fc6d44a881b01964a76edb00b4e87723a8cc596339d306d8eb321fec --hash=sha256:f7433bcce5ef7baad2fdd29f97c9fdcf8de4ec1cf577ae308901caf778ed48c2! Will try again.
  72. An error occurred while installing certifi==2023.5.7 ; python_version >= '3.6' --hash=sha256:0f0d56dc5a6ad56fd4ba36484d6cc34451e1c6548c61daad8c320169f91eddc7 --hash=sha256:c6c2e98f5c7869efca1f8916fed228dd91539f9f1b444c314c06eef02980c716! Will try again.
  73. An error occurred while installing charset-normalizer==3.1.0 ; python_full_version >= '3.7.0' --hash=sha256:04afa6387e2b282cf78ff3dbce20f0cc071c12dc8f685bd40960cc68644cfea6 --hash=sha256:04eefcee095f58eaabe6dc3cc2262f3bcd776d2c67005880894f447b3f2cb9c1 --hash=sha256:0be65ccf618c1e7ac9b849c315cc2e8a8751d9cfdaa43027d4f6624bd587ab7e --hash=sha256:0c95f12b74681e9ae127728f7e5409cbbef9cd914d5896ef238cc779b8152373 --hash=sha256:0ca564606d2caafb0abe6d1b5311c2649e8071eb241b2d64e75a0d0065107e62 --hash=sha256:10c93628d7497c81686e8e5e557aafa78f230cd9e77dd0c40032ef90c18f2230 --hash=sha256:fca62a8301b605b954ad2e9c3666f9d97f63872aa4efcae5492baca2056b74ab! Will try again.
  74. An error occurred while installing idna==3.4 ; python_version >= '3.5' --hash=sha256:814f528e8dead7d329833b91c5faa87d60bf71824cd12a7530b5526063d02cb4 --hash=sha256:90b77e79eaa3eba6de819a0c442c0b4ceefc341a7a2ab77d7562bf49f425c5c2! Will try again.
  75. An error occurred while installing jinja2==3.1.2 --hash=sha256:31351a702a408a9e7595a8fc6150fc3f43bb6bf7e319770cbc0db9df9437e852 --hash=sha256:6088930bfe239f0e6710546ab9c19c9ef35e29792895fed6e6e31a023a182a61! Will try again.
  76. An error occurred while installing jmespath==1.0.1 ; python_version >= '3.7' --hash=sha256:02e2e4cc71b5bcab88332eebf907519190dd9e6e82107fa7f83b1003a6252980 --hash=sha256:90261b206d6defd58fdd5e85f478bf633a2901798906be2ad389150c5c60edbe! Will try again.
  77. An error occurred while installing markupsafe==2.1.3 ; python_version >= '3.7' --hash=sha256:05fb21170423db021895e1ea1e1f3ab3adb85d1c2333cbc2310f2a26bc77272e --hash=sha256:0a4e4a1aff6c7ac4cd55792abf96c915634c2b97e3cc1c7129578aa68ebd754e --hash=sha256:10bbfe99883db80bdbaff2dcf681dfc6533a614f700da1287707e8a5d78a8431 --hash=sha256:fec21693218efe39aa7f8599346e90c705afa52c5b31ae019b2e57e8f6542bb2! Will try again.
  78. An error occurred while installing pysqlite3-binary ; platform_machine == 'x86_64'! Will try again.
  79. An error occurred while installing python-dateutil==2.8.2 ; python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3' --hash=sha256:0123cacc1627ae19ddf3c27a5de5bd67ee4586fbdd6440d9748f8abb483d3e86 --hash=sha256:961d03dc3453ebbc59dbdea9e4e11c5651520a876d0f4db161e8674aae935da9! Will try again.
  80. An error occurred while installing pytz==2023.3 --hash=sha256:1d8ce29db189191fb55338ee6d0387d82ab59f3d00eac103412d64e0ebd0c588 --hash=sha256:a151b3abb88eda1d4e34a9814df37de2a80e301e68ba0fd856fb9b46bfbbbffb! Will try again.
  81. An error occurred while installing requests==2.31.0 --hash=sha256:58cd2187c01e70e6e26505bca751777aa9f2ee0b7f4300988b709f44e013003f --hash=sha256:942c5a758f98d790eaed1a29cb6eefc7ffb0d1cf7af05c3d2791656dbd6ad1e1! Will try again.
  82. An error occurred while installing s3transfer==0.6.1 ; python_version >= '3.7' --hash=sha256:3c0da2d074bf35d6870ef157158641178a4204a6e689e82546083e31e0311346 --hash=sha256:640bb492711f4c0c0905e1f62b6aaeb771881935ad27884852411f8e9cacbca9! Will try again.
  83. An error occurred while installing six==1.16.0 ; python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3' --hash=sha256:1e61c37477a1626458e36f7b1d82aa5c9b094fa4802892072e49de9c60c4c926 --hash=sha256:8abb2f1d86890a2dfb989f9a77cfcfd3e47c2a354b01111771326f8aa26e0254! Will try again.
  84. An error occurred while installing urllib3==1.26.16 ; python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3, 3.4, 3.5' --hash=sha256:8d36afa7616d8ab714608411b4a3b13e58f463aee519024578e062e141dce20f --hash=sha256:8f135f6502756bde6b2a9b28989df5fbe87c9970cecaa69041edcce7f0589b14! Will try again.
  85. Installing initially failed dependencies...
  86. [pipenv.exceptions.InstallError]: Collecting boto3==1.26.147 (from -r /tmp/pipenv-lco3dh4l-requirements/pipenv-0jwjkrl4-hashed-reqs.txt (line 1))
  87. [pipenv.exceptions.InstallError]: Using cached boto3-1.26.147-py3-none-any.whl (135 kB)
  88. [pipenv.exceptions.InstallError]: Collecting botocore==1.29.147 (from -r /tmp/pipenv-lco3dh4l-requirements/pipenv-0jwjkrl4-hashed-reqs.txt (line 2))
  89. [pipenv.exceptions.InstallError]: Using cached botocore-1.29.147-py3-none-any.whl (10.8 MB)
  90. [pipenv.exceptions.InstallError]: Collecting certifi==2023.5.7 (from -r /tmp/pipenv-lco3dh4l-requirements/pipenv-0jwjkrl4-hashed-reqs.txt (line 3))
  91. [pipenv.exceptions.InstallError]: Using cached certifi-2023.5.7-py3-none-any.whl (156 kB)
  92. [pipenv.exceptions.InstallError]: Collecting charset-normalizer==3.1.0 (from -r /tmp/pipenv-lco3dh4l-requirements/pipenv-0jwjkrl4-hashed-reqs.txt (line 4))
  93. [pipenv.exceptions.InstallError]: Using cached charset_normalizer-3.1.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (199 kB)
  94. [pipenv.exceptions.InstallError]: Collecting idna==3.4 (from -r /tmp/pipenv-lco3dh4l-requirements/pipenv-0jwjkrl4-hashed-reqs.txt (line 5))
  95. [pipenv.exceptions.InstallError]: Using cached idna-3.4-py3-none-any.whl (61 kB)
  96. [pipenv.exceptions.InstallError]: Collecting jinja2==3.1.2 (from -r /tmp/pipenv-lco3dh4l-requirements/pipenv-0jwjkrl4-hashed-reqs.txt (line 6))
  97. [pipenv.exceptions.InstallError]: Using cached Jinja2-3.1.2-py3-none-any.whl (133 kB)
  98. [pipenv.exceptions.InstallError]: Collecting jmespath==1.0.1 (from -r /tmp/pipenv-lco3dh4l-requirements/pipenv-0jwjkrl4-hashed-reqs.txt (line 7))
  99. [pipenv.exceptions.InstallError]: Using cached jmespath-1.0.1-py3-none-any.whl (20 kB)
  100. [pipenv.exceptions.InstallError]: Collecting markupsafe==2.1.3 (from -r /tmp/pipenv-lco3dh4l-requirements/pipenv-0jwjkrl4-hashed-reqs.txt (line 8))
  101. [pipenv.exceptions.InstallError]: Using cached MarkupSafe-2.1.3-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (25 kB)
  102. [pipenv.exceptions.InstallError]: Collecting pysqlite3-binary (from -r /tmp/pipenv-lco3dh4l-requirements/pipenv-0jwjkrl4-hashed-reqs.txt (line 9))
  103. [pipenv.exceptions.InstallError]: ERROR: In --require-hashes mode, all requirements must have their versions pinned with ==. These do not:
  104. [pipenv.exceptions.InstallError]: pysqlite3-binary from https://files.pythonhosted.org/packages/e5/af/750aa272a8282f6518a8532f31c51cc9e49815c626cf0df8cdf181367b52/pysqlite3_binary-0.5.0-cp310-cp310-manylinux_2_24_x86_64.whl (from -r /tmp/pipenv-lco3dh4l-requirements/pipenv-0jwjkrl4-hashed-reqs.txt (line 9))
  105. ERROR: Couldn't install package: [Requirement(_name='boto3', vcs=None, req=NamedRequirement(name='boto3', version='==1.26.147', req=Requirement.parse('boto3==1.26.147'), extras=[], editable=False, _parsed_line=<Line (editable=False, name=boto3, path=None, uri=None, extras=(), markers=None, vcs=None, specifier===1.26.147, pyproject=None, pyproject_requires=None, pyproject_backend=None, ireq=boto3==1.26.147)>), markers=None, _specifiers='==1.26.147', index='pypi', editable=False, hashes=frozenset({'sha256:ccfbdb6e9ebdf943e222c88c9a8f161a8a607f3dbdbf3b1b0eed25c1d8cb215e', 'sha256:45ed158defbf554d051c4f3eae9a1ca3c1039dd29a528e884f47a06ad0ac17a1'}), extras=(), abstract_dep=None, _line_instance=<Line (editable=False, name=boto3, path=None, uri=None, extras=(), markers=None, vcs=None, specifier===1.26.147, pyproject=None, pyproject_requires=None, pyproject_backend=None, ireq=boto3==1.26.147)>, _ireq=None), Requirement(_name='botocore', vcs=None, req=NamedRequirement(name='botocore', version='==1.29.147', req=Requirement.parse('botocore==1.29.147; python_version >= "3.7"'), extras=[], editable=False, _parsed_line=<Line (editable=False, name=botocore, path=None, uri=None, extras=(), markers=python_version >= '3.7', vcs=None, specifier===1.29.147, pyproject=None, pyproject_requires=None, pyproject_backend=None, ireq=botocore==1.29.147)>), markers='python_version >= "3.7"', _specifiers='==1.29.147', index=None, editable=False, hashes=frozenset({'sha256:f7433bcce5ef7baad2fdd29f97c9fdcf8de4ec1cf577ae308901caf778ed48c2', 'sha256:67a7ce69fc6d44a881b01964a76edb00b4e87723a8cc596339d306d8eb321fec'}), extras=(), abstract_dep=None, _line_instance=<Line (editable=False, name=botocore, path=None, uri=None, extras=(), markers=python_version >= '3.7', vcs=None, specifier===1.29.147, pyproject=None, pyproject_requires=None, pyproject_backend=None, ireq=botocore==1.29.147)>, _ireq=None), Requirement(_name='certifi', vcs=None, req=NamedRequirement(name='certifi', version='==2023.5.7', req=Requirement.parse('certifi==2023.5.7; python_version >= "3.6"'), extras=[], editable=False, _parsed_line=<Line (editable=False, name=certifi, path=None, uri=None, extras=(), markers=python_version >= '3.6', vcs=None, specifier===2023.5.7, pyproject=None, pyproject_requires=None, pyproject_backend=None, ireq=certifi==2023.5.7)>), markers='python_version >= "3.6"', _specifiers='==2023.5.7', index=None, editable=False, hashes=frozenset({'sha256:0f0d56dc5a6ad56fd4ba36484d6cc34451e1c6548c61daad8c320169f91eddc7', 'sha256:c6c2e98f5c7869efca1f8916fed228dd91539f9f1b444c314c06eef02980c716'}), extras=(), abstract_dep=None, _line_instance=<Line (editable=False, name=certifi, path=None, uri=None, extras=(), markers=python_version >= '3.6', vcs=None, specifier===2023.5.7, pyproject=None, pyproject_requires=None, pyproject_backend=None, ireq=certifi==2023.5.7)>, _ireq=None), Requirement(_name='charset-normalizer', vcs=None, req=NamedRequirement(name='charset-normalizer', version='==3.1.0', req=Requirement.parse('charset-normalizer==3.1.0; python_full_version >= "3.7.0"'), extras=[], editable=False, _parsed_line=<Line (editable=False, name=charset-normalizer, path=None, uri=None, extras=(), markers=python_full_version >= '3.7.0', vcs=None, specifier===3.1.0, pyproject=None, pyproject_requires=None, pyproject_backend=None, ireq=charset-normalizer==3.1.0)>), markers='python_full_version >= "3.7.0"', _specifiers='==3.1.0', index=None, editable=False, hashes=frozenset({'sha256:04afa6387e2b282cf78ff3dbce20f0cc071c12dc8f685bd40960cc68644cfea6', 'sha256:cca4def576f47a09a943666b8f829606bcb17e2bc2d5911a46c8f8da45f56755', 'sha256:e0ac8959c929593fee38da1c2b64ee9778733cdf03c482c9ff1d508b6b593b2b', 'sha256:4155b51ae05ed47199dc5b2a4e62abccb274cee6b01da5b895099b61b1982974', 'sha256:cf6511efa4801b9b38dc5546d7547d5b5c6ef4b081c60b23e4d941d0eba9cbeb'}), extras=(), abstract_dep=None, _line_instance=<Line (editable=False, name=charset-normalizer, path=None, uri=None, extras=(), markers=python_full_version >= '3.7.0', vcs=None, specifier===3.1.0, pyproject=None, pyproject_requires=None, pyproject_backend=None, ireq=charset-normalizer==3.1.0)>, _ireq=None), Requirement(_name='idna', vcs=None, req=NamedRequirement(name='idna', version='==3.4', req=Requirement.parse('idna==3.4; python_version >= "3.5"'), extras=[], editable=False, _parsed_line=<Line (editable=False, name=idna, path=None, uri=None, extras=(), markers=python_version >= '3.5', vcs=None, specifier===3.4, pyproject=None, pyproject_requires=None, pyproject_backend=None, ireq=idna==3.4)>), markers='python_version >= "3.5"', _specifiers='==3.4', index=None, editable=False, hashes=frozenset({'sha256:90b77e79eaa3eba6de819a0c442c0b4ceefc341a7a2ab77d7562bf49f425c5c2', 'sha256:814f528e8dead7d329833b91c5faa87d60bf71824cd12a7530b5526063d02cb4'}), extras=(), abstract_dep=None, _line_instance=<Line (editable=False, name=idna, path=None, uri=None, extras=(), markers=python_version >= '3.5', vcs=None, specifier===3.4, pyproject=None, pyproject_requires=None, pyproject_backend=None, ireq=idna==3.4)>, _ireq=None), Requirement(_name='jinja2', vcs=None, req=NamedRequirement(name='jinja2', version='==3.1.2', req=Requirement.parse('jinja2==3.1.2'), extras=[], editable=False, _parsed_line=<Line (editable=False, name=jinja2, path=None, uri=None, extras=(), markers=None, vcs=None, specifier===3.1.2, pyproject=None, pyproject_requires=None, pyproject_backend=None, ireq=jinja2==3.1.2)>), markers=None, _specifiers='==3.1.2', index='pypi', editable=False, hashes=frozenset({'sha256:6088930bfe239f0e6710546ab9c19c9ef35e29792895fed6e6e31a023a182a61', 'sha256:31351a702a408a9e7595a8fc6150fc3f43bb6bf7e319770cbc0db9df9437e852'}), extras=(), abstract_dep=None, _line_instance=<Line (editable=False, name=jinja2, path=None, uri=None, extras=(), markers=None, vcs=None, specifier===3.1.2, pyproject=None, pyproject_requires=None, pyproject_backend=None, ireq=jinja2==3.1.2)>, _ireq=None), Requirement(_name='jmespath', vcs=None, req=NamedRequirement(name='jmespath', version='==1.0.1', req=Requirement.parse('jmespath==1.0.1; python_version >= "3.7"'), extras=[], editable=False, _parsed_line=<Line (editable=False, name=jmespath, path=None, uri=None, extras=(), markers=python_version >= '3.7', vcs=None, specifier===1.0.1, pyproject=None, pyproject_requires=None, pyproject_backend=None, ireq=jmespath==1.0.1)>), markers='python_version >= "3.7"', _specifiers='==1.0.1', index=None, editable=False, hashes=frozenset({'sha256:90261b206d6defd58fdd5e85f478bf633a2901798906be2ad389150c5c60edbe', 'sha256:02e2e4cc71b5bcab88332eebf907519190dd9e6e82107fa7f83b1003a6252980'}), extras=(), abstract_dep=None, _line_instance=<Line (editable=False, name=jmespath, path=None, uri=None, extras=(), markers=python_version >= '3.7', vcs=None, specifier===1.0.1, pyproject=None, pyproject_requires=None, pyproject_backend=None, ireq=jmespath==1.0.1)>, _ireq=None), Requirement(_name='markupsafe', vcs=None, req=NamedRequirement(name='markupsafe', version='==2.1.3', req=Requirement.parse('markupsafe==2.1.3; python_version >= "3.7"'), extras=[], editable=False, _parsed_line=<Line (editable=False, name=markupsafe, path=None, uri=None, extras=(), markers=python_version >= '3.7', vcs=None, specifier===2.1.3, pyproject=None, pyproject_requires=None, pyproject_backend=None, ireq=markupsafe==2.1.3)>), markers='python_version >= "3.7"', _specifiers='==2.1.3', index=None, editable=False, hashes=frozenset({'sha256:b076b6226fb84157e3f7c971a47ff3a679d837cf338547532ab866c57930dbee', 'sha256:ad9e82fb8f09ade1c3e1b996a6337afac2b8b9e365f926f5a61aacc71adc5b3c', 'sha256:fec21693218efe39aa7f8599346e90c705afa52c5b31ae019b2e57e8f6542bb2', 'sha256:69c0f17e9f5a7afdf2cc9fb2d1ce6aabdb3bafb7f38017c0b77862bcec2bbad8', 'sha256:962f82a3086483f5e5f64dbad880d31038b698494799b097bc59c2edf392fce6'}), extras=(), abstract_dep=None, _line_instance=<Line (editable=False, name=markupsafe, path=None, uri=None, extras=(), markers=python_version >= '3.7', vcs=None, specifier===2.1.3, pyproject=None, pyproject_requires=None, pyproject_backend=None, ireq=markupsafe==2.1.3)>, _ireq=None), Requirement(_name='pysqlite3-binary', vcs=None, req=NamedRequirement(name='pysqlite3-binary', version='', req=Requirement.parse('pysqlite3-binary; platform_machine == "x86_64"'), extras=[], editable=False, _parsed_line=<Line (editable=False, name=pysqlite3-binary, path=None, uri=None, extras=(), markers=platform_machine == 'x86_64', vcs=None, specifier=None, pyproject=None, pyproject_requires=None, pyproject_backend=None, ireq=pysqlite3-binary)>), markers='platform_machine == "x86_64"', _specifiers='', index=None, editable=False, hashes=frozenset(), extras=(), abstract_dep=None, _line_instance=<Line (editable=False, name=pysqlite3-binary, path=None, uri=None, extras=(), markers=platform_machine == 'x86_64', vcs=None, specifier=None, pyproject=None, pyproject_requires=None, pyproject_backend=None, ireq=pysqlite3-binary)>, _ireq=None), Requirement(_name='python-dateutil', vcs=None, req=NamedRequirement(name='python-dateutil', version='==2.8.2', req=Requirement.parse('python-dateutil==2.8.2; python_version >= "2.7" and python_version not in "3.0, 3.1, 3.2, 3.3"'), extras=[], editable=False, _parsed_line=<Line (editable=False, name=python-dateutil, path=None, uri=None, extras=(), markers=python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3', vcs=None, specifier===2.8.2, pyproject=None, pyproject_requires=None, pyproject_backend=None, ireq=python-dateutil==2.8.2)>), markers='python_version >= "2.7" and python_version not in "3.0, 3.1, 3.2, 3.3"', _specifiers='==2.8.2', index=None, editable=False, hashes=frozenset({'sha256:0123cacc1627ae19ddf3c27a5de5bd67ee4586fbdd6440d9748f8abb483d3e86', 'sha256:961d03dc3453ebbc59dbdea9e4e11c5651520a876d0f4db161e8674aae935da9'}), extras=(), abstract_dep=None, _line_instance=<Line (editable=False, name=python-dateutil, path=None, uri=None, extras=(), markers=python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3', vcs=None, specifier===2.8.2, pyproject=None, pyproject_requires=None, pyproject_backend=None, ireq=python-dateutil==2.8.2)>, _ireq=None), Requirement(_name='pytz', vcs=None, req=NamedRequirement(name='pytz', version='==2023.3', req=Requirement.parse('pytz==2023.3'), extras=[], editable=False, _parsed_line=<Line (editable=False, name=pytz, path=None, uri=None, extras=(), markers=None, vcs=None, specifier===2023.3, pyproject=None, pyproject_requires=None, pyproject_backend=None, ireq=pytz==2023.3)>), markers=None, _specifiers='==2023.3', index='pypi', editable=False, hashes=frozenset({'sha256:1d8ce29db189191fb55338ee6d0387d82ab59f3d00eac103412d64e0ebd0c588', 'sha256:a151b3abb88eda1d4e34a9814df37de2a80e301e68ba0fd856fb9b46bfbbbffb'}), extras=(), abstract_dep=None, _line_instance=<Line (editable=False, name=pytz, path=None, uri=None, extras=(), markers=None, vcs=None, specifier===2023.3, pyproject=None, pyproject_requires=None, pyproject_backend=None, ireq=pytz==2023.3)>, _ireq=None), Requirement(_name='requests', vcs=None, req=NamedRequirement(name='requests', version='==2.31.0', req=Requirement.parse('requests==2.31.0'), extras=[], editable=False, _parsed_line=<Line (editable=False, name=requests, path=None, uri=None, extras=(), markers=None, vcs=None, specifier===2.31.0, pyproject=None, pyproject_requires=None, pyproject_backend=None, ireq=requests==2.31.0)>), markers=None, _specifiers='==2.31.0', index='pypi', editable=False, hashes=frozenset({'sha256:942c5a758f98d790eaed1a29cb6eefc7ffb0d1cf7af05c3d2791656dbd6ad1e1', 'sha256:58cd2187c01e70e6e26505bca751777aa9f2ee0b7f4300988b709f44e013003f'}), extras=(), abstract_dep=None, _line_instance=<Line (editable=False, name=requests, path=None, uri=None, extras=(), markers=None, vcs=None, specifier===2.31.0, pyproject=None, pyproject_requires=None, pyproject_backend=None, ireq=requests==2.31.0)>, _ireq=None), Requirement(_name='s3transfer', vcs=None, req=NamedRequirement(name='s3transfer', version='==0.6.1', req=Requirement.parse('s3transfer==0.6.1; python_version >= "3.7"'), extras=[], editable=False, _parsed_line=<Line (editable=False, name=s3transfer, path=None, uri=None, extras=(), markers=python_version >= '3.7', vcs=None, specifier===0.6.1, pyproject=None, pyproject_requires=None, pyproject_backend=None, ireq=s3transfer==0.6.1)>), markers='python_version >= "3.7"', _specifiers='==0.6.1', index=None, editable=False, hashes=frozenset({'sha256:640bb492711f4c0c0905e1f62b6aaeb771881935ad27884852411f8e9cacbca9', 'sha256:3c0da2d074bf35d6870ef157158641178a4204a6e689e82546083e31e0311346'}), extras=(), abstract_dep=None, _line_instance=<Line (editable=False, name=s3transfer, path=None, uri=None, extras=(), markers=python_version >= '3.7', vcs=None, specifier===0.6.1, pyproject=None, pyproject_requires=None, pyproject_backend=None, ireq=s3transfer==0.6.1)>, _ireq=None), Requirement(_name='six', vcs=None, req=NamedRequirement(name='six', version='==1.16.0', req=Requirement.parse('six==1.16.0; python_version >= "2.7" and python_version not in "3.0, 3.1, 3.2, 3.3"'), extras=[], editable=False, _parsed_line=<Line (editable=False, name=six, path=None, uri=None, extras=(), markers=python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3', vcs=None, specifier===1.16.0, pyproject=None, pyproject_requires=None, pyproject_backend=None, ireq=six==1.16.0)>), markers='python_version >= "2.7" and python_version not in "3.0, 3.1, 3.2, 3.3"', _specifiers='==1.16.0', index=None, editable=False, hashes=frozenset({'sha256:8abb2f1d86890a2dfb989f9a77cfcfd3e47c2a354b01111771326f8aa26e0254', 'sha256:1e61c37477a1626458e36f7b1d82aa5c9b094fa4802892072e49de9c60c4c926'}), extras=(), abstract_dep=None, _line_instance=<Line (editable=False, name=six, path=None, uri=None, extras=(), markers=python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3', vcs=None, specifier===1.16.0, pyproject=None, pyproject_requires=None, pyproject_backend=None, ireq=six==1.16.0)>, _ireq=None), Requirement(_name='urllib3', vcs=None, req=NamedRequirement(name='urllib3', version='==1.26.16', req=Requirement.parse('urllib3==1.26.16; python_version >= "2.7" and python_version not in "3.0, 3.1, 3.2, 3.3, 3.4, 3.5"'), extras=[], editable=False, _parsed_line=<Line (editable=False, name=urllib3, path=None, uri=None, extras=(), markers=python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3, 3.4, 3.5', vcs=None, specifier===1.26.16, pyproject=None, pyproject_requires=None, pyproject_backend=None, ireq=urllib3==1.26.16)>), markers='python_version >= "2.7" and python_version not in "3.0, 3.1, 3.2, 3.3, 3.4, 3.5"', _specifiers='==1.26.16', index=None, editable=False, hashes=frozenset({'sha256:8f135f6502756bde6b2a9b28989df5fbe87c9970cecaa69041edcce7f0589b14', 'sha256:8d36afa7616d8ab714608411b4a3b13e58f463aee519024578e062e141dce20f'}), extras=(), abstract_dep=None, _line_instance=<Line (editable=False, name=urllib3, path=None, uri=None, extras=(), markers=python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3, 3.4, 3.5', vcs=None, specifier===1.26.16, pyproject=None, pyproject_requires=None, pyproject_backend=None, ireq=urllib3==1.26.16)>, _ireq=None)]
  106. Package installation failed...
  107. The command '/bin/sh -c PIPENV_VENV_IN_PROJECT=1 pipenv install --deploy' returned a non-zero code: 1

Any ideas would be appreciated!

答案1

得分: 0

The problem is that I'm developing on an M1 Mac but deploying on a Linux container. Since the Mac ignores the pysqlite3-binary package (wrong platform), the Pipfile.lock contains no hashes for that package. Then, I try to install using the lockfile in the Linux container, and the platform matches but the hashes are missing and so the install fails.

The hint was in the build log:

  1. ERROR: In --require-hashes mode, all requirements must have their versions pinned with ==. These do not:
  2. pysqlite3-binary

It could have been clearer that the problem was the entirely missing hashes!

The solution is to use package categories to restrict the locking to just the sqlite package, like so:

  1. [packages]
  2. requests = "*"
  3. boto3 = "*"
  4. jinja2 = "*"
  5. pytz = "*"
  6. [sqlite]
  7. pysqlite3-binary = { version = "*", platform_machine = "== 'x86_64'" }
  8. [dev-packages]
  9. isort = "*"
  10. black = "*"
  11. flake8 = "*"

I then lock just that category in the Dockerfile, and install both categories:

  1. COPY Pipfile* ./
  2. RUN PIPENV_VENV_IN_PROJECT=1 pipenv lock --categories sqlite
  3. RUN PIPENV_VENV_IN_PROJECT=1 pipenv install --deploy --categories="packages sqlite" --verbose

And a normal pipenv install will ignore all categories which aren't packages or dev-packages, so that still works from the command line for local development.

英文:

The problem is that I'm developing on an M1 Mac but deploying on a Linux container. Since the Mac ignores the pysqlite3-binary package (wrong platform), the Pipfile.lock contains no hashes for that package. Then, I try to install using the lockfile in the Linux container, and the platform matches but the hashes are missing and so the install fails.

The hint was in the build log:

  1. ERROR: In --require-hashes mode, all requirements must have their versions pinned with ==. These do not:
  2. pysqlite3-binary

It could have been clearer that the problem was the entirely missing hashes!

The solution is to use package categories to restrict the locking to just the sqlite package, like so:

  1. [packages]
  2. requests = "*"
  3. boto3 = "*"
  4. jinja2 = "*"
  5. pytz = "*"
  6. [sqlite]
  7. pysqlite3-binary = { version = "*", platform_machine = "== 'x86_64'" }
  8. [dev-packages]
  9. isort = "*"
  10. black = "*"
  11. flake8 = "*"

I then lock just that category in the Dockerfile, and install both categories:

  1. COPY Pipfile* ./
  2. RUN PIPENV_VENV_IN_PROJECT=1 pipenv lock --categories sqlite
  3. RUN PIPENV_VENV_IN_PROJECT=1 pipenv install --deploy --categories="packages sqlite" --verbose

And a normal pipenv install will ignore all categories which aren't packages or dev-packages, so that still works from the command line for local development.

huangapple
  • 本文由 发表于 2023年6月6日 08:12:19
  • 转载请务必保留本文链接:https://go.coder-hub.com/76410688.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定