I am trying to run package goal for python_awslamb...
# general
h
I am trying to run package goal for python_awslambda target which has dependency on img2pdf library and I am getting this error. running the cmd on macOS Big Sur M1.
Copy code
Failed to resolve all requirements for abbreviated platform cp39-cp39-linux_x86_64 from 3rdparty/python/default.lock:

Configured with:
    build: False
    use_wheel: True

Dependency on img2pdf not satisfied, 1 incompatible candidate found:
1.) img2pdf 0.4.4 (via: img2pdf==0.4.4) does not have any compatible artifacts:
    <https://files.pythonhosted.org/packages/95/b5/f933f482a811fb9a7b3707f60e28f2925fed84726e5a6283ba07fdd54f49/img2pdf-0.4.4.tar.gz>
toned down the code for reprod. using the latest version img2pdf==0.4.4 BUILD:
Copy code
python_sources()

python_awslambda(
    name="img2pdf-lambda",
    runtime="python3.9",
    handler="./handler.py:lambda_handler",
)
handler.py
Copy code
import img2pdf

def lambda_handler(event, context):
    print('hello world')
r
Where does this option come from?
```Configured with:
build: False
use_wheel: True```
To me it seems like since pants is not allowing the build and the wheels don’t exist, it fails But I didn’t know you can configure this. EDIT: This is from pants logs
h
Yes, this is from the pants log. And these configuration options are probably default cuz I am not configuring this explicitly.
r
What pants version is this? I have seen in past pants building wheels when it couldn’t find the correct wheel
h
2.12
Copy code
[GLOBAL]
pants_version = "2.12.0"
backend_packages.add = [
  'pants.backend.python',
  "pants.backend.python.mixed_interpreter_constraints",
  "pants.backend.awslambda.python",
  'pants.backend.python.lint.docformatter',
  'pants.backend.python.lint.black',
  'pants.backend.python.lint.flake8',
  'pants.backend.python.lint.isort',
  'pants.backend.python.typecheck.mypy',
]

[anonymous-telemetry]
enabled = false

[source]
root_patterns = ["/", "projects"]

[python]
interpreter_constraints = ["CPython>=3.9"]
enable_resolves = true
lockfile_generator = "pex"

[python-infer]
string_imports = true

[pytest]
lockfile = "3rdparty/python/pytest.txt"
version = "pytest>=7.1.2,<7.2"
extra_requirements.add = [
  "pytest-django>=4.5.2,<5",
]
execution_slot_var = "PANTS_EXECUTION_SLOT" # (controlling (test) parallelism) If a non-empty string, the process execution slot id (an integer) will be exposed to tests under this environment variable name.
args = ["-s"]
e
This is not Pants configuring things evne though it reads like that might be the case:
Copy code
Configured with:
    build: False
    use_wheel: True
That's really just Pex's reaction to pants passing
--platform linux_x86_64-cp-39-cp39
which is what it does to tell Pex - "Hey, I know we're on Mac, but try to build a venv that works on Linux". Since we're on Mac, we cannot build sdists into Linux wheels without cross-building. Pex does not support cross-building and so it only allows pre-built wheels. The resolve fails since there is no pre-built wheel for
img2pdf
. You need to build one for Linux and then make it available in a
--find-links
repo for Pex to find. When using Pants you configure this with `[python-repos] repos = ...`: https://www.pantsbuild.org/docs/reference-python-repos#repos
👍 1
Lots of Toolchain engineers are currently working on bringing support for a form of cross-building by running Pants actions in local Docker containers. That will nicely solve cases like this, but that feature work though is still in progress.
h
Thanks, for the explanation John.