<#18897 Building Psycopg2 with Pants compatible on...
# github-notifications
c
#18897 Building Psycopg2 with Pants compatible on both - M1 and Linux Issue created by Andreypnfrv Describe the bug I'm building a container and there's a problem of compatibility of platform architectures which I can't find the way to deal with. Will appreciate any ideas how we can fix this. Using new Environments function.
Copy code
Failed to find compatible interpreter on path /usr/local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin.

Examined the following interpreters:
1.) /usr/bin/python3.9 CPython==3.9.2
2.) /usr/local/bin/python3.11 CPython==3.11.3

No interpreter compatible with the requested constraints was found:

  A distribution for psycopg2-binary could not be resolved for /usr/bin/python3.9.
  Found 2 distributions for psycopg2-binary that do not apply:
  1.) The wheel tags for psycopg2-binary 2.9.6 are cp311-cp311-manylinux_2_17_x86_64, cp311-cp311-manylinux2014_x86_64 which do not match the supported tags of /usr/bin/python3.9:
  cp39-cp39-manylinux_2_31_aarch64
  ... 367 more ...
  2.) The wheel tags for psycopg2-binary 2.9.6 are cp39-cp39-manylinux2014_x86_64, cp39-cp39-manylinux_2_17_x86_64 which do not match the supported tags of /usr/bin/python3.9:
  cp39-cp39-manylinux_2_31_aarch64
  ... 367 more ...

  A distribution for psycopg2-binary could not be resolved for /usr/local/bin/python3.11.
  Found 2 distributions for psycopg2-binary that do not apply:
  1.) The wheel tags for psycopg2-binary 2.9.6 are cp311-cp311-manylinux_2_17_x86_64, cp311-cp311-manylinux2014_x86_64 which do not match the supported tags of /usr/local/bin/python3.11:
  cp311-cp311-manylinux_2_31_aarch64
  ... 437 more ...
  2.) The wheel tags for psycopg2-binary 2.9.6 are cp39-cp39-manylinux2014_x86_64, cp39-cp39-manylinux_2_17_x86_64 which do not match the supported tags of /usr/local/bin/python3.11:
  cp311-cp311-manylinux_2_31_aarch64
  ... 437 more ...
Pants version 2.15 OS Mac M1 and going to deploy the packaged Docker container to ECS Fargate, which is Linux amd64 Additional info /helloworld/BUILD
Copy code
python_requirement(
    name="sqlalchemy",
    requirements=[
        "sqlalchemy", 
    ]
)

python_requirement(
    name="psycopg2",
    requirements=[
        "psycopg2-binary",
    ]
)

python_sources(
    name="helloworld",
    dependencies=[
        ":sqlalchemy",
        ":psycopg2"
    ],
)

pex_binary(
    name="helloworld_pex",
    entry_point="helloworld.__init__:main",
    dependencies=[
        ":helloworld"
    ],
    output_path="helloworld.pex",
    environment="linux_docker",
)

docker_image(
    name="helloworld_docker",
    dependencies=[
        ":helloworld_pex",
    ]
)
./BUILD
Copy code
docker_environment(
    name="linux_docker",
    platform="linux_x86_64",
    image="python:3.11"
)
local_environment(
  name="macos_laptop",
  compatible_platforms=["macos_x86_64"],
)
pantsbuild/pants