英文:
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
FROM public.ecr.aws/lambda/python:3.10 AS base
# Set up environment
ENV LANG C.UTF-8
ENV LC_ALL C.UTF-8
ENV PYTHONDONTWRITEBYTECODE 1
ENV PYTHONFAULTHANDLER 1
FROM base AS python-deps
RUN pip install pipenv
COPY Pipfile* ./
RUN PIPENV_VENV_IN_PROJECT=1 pipenv install --deploy
FROM base as runtime
COPY --from=python-deps ${LAMBDA_TASK_ROOT}/.venv/lib/python*/site-packages ./
COPY app app
# Set the CMD to your handler (could also be done as a parameter override outside of the Dockerfile)
CMD [ "app.app.handler" ]
Pipfile
[[source]]
url = "https://pypi.org/simple"
verify_ssl = true
name = "pypi"
[packages]
requests = "*"
boto3 = "*"
jinja2 = "*"
pytz = "*"
pysqlite3-binary = { version = "*", platform_machine = "== 'x86_64'" }
[dev-packages]
isort = "*"
black = "*"
flake8 = "*"
[requires]
python_version = "3.10"
When I make a change to the repo, the container gets re-built on GH and fails with this error:
Status: Downloaded newer image for public.ecr.aws/lambda/python:3.10
---> ecba6236d1f5
Step 2/13 : ENV LANG C.UTF-8
---> Running in bd0cb33a39b7
Removing intermediate container bd0cb33a39b7
---> 5d5aafca5928
...
...
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
FROM public.ecr.aws/lambda/python:3.10 AS base
# Set up environment
ENV LANG C.UTF-8
ENV LC_ALL C.UTF-8
ENV PYTHONDONTWRITEBYTECODE 1
ENV PYTHONFAULTHANDLER 1
FROM base AS python-deps
RUN pip install pipenv
COPY Pipfile* ./
RUN PIPENV_VENV_IN_PROJECT=1 pipenv install --deploy
FROM base as runtime
COPY --from=python-deps ${LAMBDA_TASK_ROOT}/.venv/lib/python*/site-packages ./
COPY app app
# Set the CMD to your handler (could also be done as a parameter override outside of the Dockerfile)
CMD [ "app.app.handler" ]
Pipfile
[[source]]
url = "https://pypi.org/simple"
verify_ssl = true
name = "pypi"
[packages]
requests = "*"
boto3 = "*"
jinja2 = "*"
pytz = "*"
pysqlite3-binary = { version = "*", platform_machine = "== 'x86_64'" }
[dev-packages]
isort = "*"
black = "*"
flake8 = "*"
[requires]
python_version = "3.10"
When I make a change to the repo, the container gets re-built on GH and fails with this error:
Status: Downloaded newer image for public.ecr.aws/lambda/python:3.10
---> ecba6236d1f5
Step 2/13 : ENV LANG C.UTF-8
---> Running in bd0cb33a39b7
Removing intermediate container bd0cb33a39b7
---> 5d5aafca5928
Step 3/13 : ENV LC_ALL C.UTF-8
---> Running in 13dfbc245a61
Removing intermediate container 13dfbc245a61
---> 7e8a6fd1ec61
Step 4/13 : ENV PYTHONDONTWRITEBYTECODE 1
---> Running in 900f2dff8a5d
Removing intermediate container 900f2dff8a5d
---> 73f224622e4b
Step 5/13 : ENV PYTHONFAULTHANDLER 1
---> Running in 3d811c817fa7
Removing intermediate container 3d811c817fa7
---> 927e8c0bdb65
Step 6/13 : FROM base AS python-deps
---> 927e8c0bdb65
Step 7/13 : RUN pip install pipenv
---> Running in 20c336e3f13d
Collecting pipenv
Downloading pipenv-2023.6.2-py3-none-any.whl (2.9 MB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 2.9/2.9 MB 50.8 MB/s eta 0:00:00
Collecting virtualenv-clone>=0.2.5
Downloading virtualenv_clone-0.5.7-py3-none-any.whl (6.6 kB)
Collecting virtualenv>=20.17.1
Downloading virtualenv-20.23.0-py3-none-any.whl (3.3 MB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 3.3/3.3 MB 120.7 MB/s eta 0:00:00
Collecting certifi
Downloading certifi-2023.5.7-py3-none-any.whl (156 kB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 157.0/157.0 kB 47.2 MB/s eta 0:00:00
Collecting setuptools>=67.0.0
Downloading setuptools-67.8.0-py3-none-any.whl (1.1 MB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 1.1/1.1 MB 107.9 MB/s eta 0:00:00
Collecting distlib<1,>=0.3.6
Downloading distlib-0.3.6-py2.py3-none-any.whl (468 kB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 468.5/468.5 kB 84.2 MB/s eta 0:00:00
Collecting filelock<4,>=3.11
Downloading filelock-3.12.0-py3-none-any.whl (10 kB)
Collecting platformdirs<4,>=3.2
Downloading platformdirs-3.5.1-py3-none-any.whl (15 kB)
Installing collected packages: distlib, virtualenv-clone, setuptools, platformdirs, filelock, certifi, virtualenv, pipenv
Attempting uninstall: setuptools
Found existing installation: setuptools 65.5.1
Uninstalling setuptools-65.5.1:
Successfully uninstalled setuptools-65.5.1
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
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
Notice: A new release of pip is available: 23.0.1 -> 23.1.2
Notice: To update, run: pip install --upgrade pip
Removing intermediate container 20c336e3f13d
---> 2b3608b3c998
Step 8/13 : COPY Pipfile* ./
---> c00128bf188c
Step 9/13 : RUN PIPENV_VENV_IN_PROJECT=1 pipenv install --deploy
---> Running in 28e5ca31efea
Creating a virtualenv for this project...
Pipfile: /var/task/Pipfile
Using /var/lang/bin/python3 (3.10.11) to create virtualenv...
created virtual environment CPython3.10.11.final.0-64 in 712ms
creator CPython3Posix(dest=/var/task/.venv, clear=False, no_vcs_ignore=False, global=False)
seeder FromAppData(download=False, pip=bundle, setuptools=bundle, wheel=bundle, via=copy, app_data_dir=/root/.local/share/virtualenv)
added seed packages: pip==23.1.2, setuptools==67.7.2, wheel==0.40.0
activators BashActivator,CShellActivator,FishActivator,NushellActivator,PowerShellActivator,PythonActivator
✔ Successfully created virtual environment!
Virtualenv location: /var/task/.venv
Installing dependencies from Pipfile.lock (fe6451)...
An error occurred while installing boto3==1.26.147 --hash=sha256:45ed158defbf554d051c4f3eae9a1ca3c1039dd29a528e884f47a06ad0ac17a1 --hash=sha256:ccfbdb6e9ebdf943e222c88c9a8f161a8a607f3dbdbf3b1b0eed25c1d8cb215e! Will try again.
An error occurred while installing botocore==1.29.147 ; python_version >= '3.7' --hash=sha256:67a7ce69fc6d44a881b01964a76edb00b4e87723a8cc596339d306d8eb321fec --hash=sha256:f7433bcce5ef7baad2fdd29f97c9fdcf8de4ec1cf577ae308901caf778ed48c2! Will try again.
An error occurred while installing certifi==2023.5.7 ; python_version >= '3.6' --hash=sha256:0f0d56dc5a6ad56fd4ba36484d6cc34451e1c6548c61daad8c320169f91eddc7 --hash=sha256:c6c2e98f5c7869efca1f8916fed228dd91539f9f1b444c314c06eef02980c716! Will try again.
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.
An error occurred while installing idna==3.4 ; python_version >= '3.5' --hash=sha256:814f528e8dead7d329833b91c5faa87d60bf71824cd12a7530b5526063d02cb4 --hash=sha256:90b77e79eaa3eba6de819a0c442c0b4ceefc341a7a2ab77d7562bf49f425c5c2! Will try again.
An error occurred while installing jinja2==3.1.2 --hash=sha256:31351a702a408a9e7595a8fc6150fc3f43bb6bf7e319770cbc0db9df9437e852 --hash=sha256:6088930bfe239f0e6710546ab9c19c9ef35e29792895fed6e6e31a023a182a61! Will try again.
An error occurred while installing jmespath==1.0.1 ; python_version >= '3.7' --hash=sha256:02e2e4cc71b5bcab88332eebf907519190dd9e6e82107fa7f83b1003a6252980 --hash=sha256:90261b206d6defd58fdd5e85f478bf633a2901798906be2ad389150c5c60edbe! Will try again.
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.
An error occurred while installing pysqlite3-binary ; platform_machine == 'x86_64'! Will try again.
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.
An error occurred while installing pytz==2023.3 --hash=sha256:1d8ce29db189191fb55338ee6d0387d82ab59f3d00eac103412d64e0ebd0c588 --hash=sha256:a151b3abb88eda1d4e34a9814df37de2a80e301e68ba0fd856fb9b46bfbbbffb! Will try again.
An error occurred while installing requests==2.31.0 --hash=sha256:58cd2187c01e70e6e26505bca751777aa9f2ee0b7f4300988b709f44e013003f --hash=sha256:942c5a758f98d790eaed1a29cb6eefc7ffb0d1cf7af05c3d2791656dbd6ad1e1! Will try again.
An error occurred while installing s3transfer==0.6.1 ; python_version >= '3.7' --hash=sha256:3c0da2d074bf35d6870ef157158641178a4204a6e689e82546083e31e0311346 --hash=sha256:640bb492711f4c0c0905e1f62b6aaeb771881935ad27884852411f8e9cacbca9! Will try again.
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.
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.
Installing initially failed dependencies...
[pipenv.exceptions.InstallError]: Collecting boto3==1.26.147 (from -r /tmp/pipenv-lco3dh4l-requirements/pipenv-0jwjkrl4-hashed-reqs.txt (line 1))
[pipenv.exceptions.InstallError]: Using cached boto3-1.26.147-py3-none-any.whl (135 kB)
[pipenv.exceptions.InstallError]: Collecting botocore==1.29.147 (from -r /tmp/pipenv-lco3dh4l-requirements/pipenv-0jwjkrl4-hashed-reqs.txt (line 2))
[pipenv.exceptions.InstallError]: Using cached botocore-1.29.147-py3-none-any.whl (10.8 MB)
[pipenv.exceptions.InstallError]: Collecting certifi==2023.5.7 (from -r /tmp/pipenv-lco3dh4l-requirements/pipenv-0jwjkrl4-hashed-reqs.txt (line 3))
[pipenv.exceptions.InstallError]: Using cached certifi-2023.5.7-py3-none-any.whl (156 kB)
[pipenv.exceptions.InstallError]: Collecting charset-normalizer==3.1.0 (from -r /tmp/pipenv-lco3dh4l-requirements/pipenv-0jwjkrl4-hashed-reqs.txt (line 4))
[pipenv.exceptions.InstallError]: Using cached charset_normalizer-3.1.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (199 kB)
[pipenv.exceptions.InstallError]: Collecting idna==3.4 (from -r /tmp/pipenv-lco3dh4l-requirements/pipenv-0jwjkrl4-hashed-reqs.txt (line 5))
[pipenv.exceptions.InstallError]: Using cached idna-3.4-py3-none-any.whl (61 kB)
[pipenv.exceptions.InstallError]: Collecting jinja2==3.1.2 (from -r /tmp/pipenv-lco3dh4l-requirements/pipenv-0jwjkrl4-hashed-reqs.txt (line 6))
[pipenv.exceptions.InstallError]: Using cached Jinja2-3.1.2-py3-none-any.whl (133 kB)
[pipenv.exceptions.InstallError]: Collecting jmespath==1.0.1 (from -r /tmp/pipenv-lco3dh4l-requirements/pipenv-0jwjkrl4-hashed-reqs.txt (line 7))
[pipenv.exceptions.InstallError]: Using cached jmespath-1.0.1-py3-none-any.whl (20 kB)
[pipenv.exceptions.InstallError]: Collecting markupsafe==2.1.3 (from -r /tmp/pipenv-lco3dh4l-requirements/pipenv-0jwjkrl4-hashed-reqs.txt (line 8))
[pipenv.exceptions.InstallError]: Using cached MarkupSafe-2.1.3-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (25 kB)
[pipenv.exceptions.InstallError]: Collecting pysqlite3-binary (from -r /tmp/pipenv-lco3dh4l-requirements/pipenv-0jwjkrl4-hashed-reqs.txt (line 9))
[pipenv.exceptions.InstallError]: ERROR: In --require-hashes mode, all requirements must have their versions pinned with ==. These do not:
[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))
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)]
Package installation failed...
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:
ERROR: In --require-hashes mode, all requirements must have their versions pinned with ==. These do not:
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:
[packages]
requests = "*"
boto3 = "*"
jinja2 = "*"
pytz = "*"
[sqlite]
pysqlite3-binary = { version = "*", platform_machine = "== 'x86_64'" }
[dev-packages]
isort = "*"
black = "*"
flake8 = "*"
I then lock just that category in the Dockerfile, and install both categories:
COPY Pipfile* ./
RUN PIPENV_VENV_IN_PROJECT=1 pipenv lock --categories sqlite
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:
ERROR: In --require-hashes mode, all requirements must have their versions pinned with ==. These do not:
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:
[packages]
requests = "*"
boto3 = "*"
jinja2 = "*"
pytz = "*"
[sqlite]
pysqlite3-binary = { version = "*", platform_machine = "== 'x86_64'" }
[dev-packages]
isort = "*"
black = "*"
flake8 = "*"
I then lock just that category in the Dockerfile, and install both categories:
COPY Pipfile* ./
RUN PIPENV_VENV_IN_PROJECT=1 pipenv lock --categories sqlite
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.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论