-
-
Notifications
You must be signed in to change notification settings - Fork 650
Description
🐞 bug report
Affected Rule
requirement
pip_parse
Is this a regression?
No
Description
With AWS CDK 2.51.0, they have split out a number of sub-packages. Not sure why as they are required dependencies, but nonetheless, if you depend on aws-cdk-lib, you also now depend on:
aws-cdk.asset-awscli-v1
aws-cdk.asset-kubectl-v20
aws-cdk.asset-node-proxy-agent-v5
This seems to break tests in my monorepo. I am not sure exactly why, but my theory is that there are now multiple aws-cdk/__init__.py's in my PYTHONPATH due to rules_python's PYTHONPATH-based solution for handling pip dependencies.
🔬 Minimal Reproduction
I have made a minimal example here: https://github.com/psalvaggio-dl/bazel-cdk-repro
In order to reproduce, the bazel test //py:test can be run.
🔥 Exception or Error
My pytest test prints out the following error:
ImportError while importing test module '/home/ubuntu/.cache/bazel/_bazel_ubuntu/f5bb56bb935f39261247d94ebd292fdf/sandbox/linux-sandbox/5/execroot/bazel-cdk-repro/bazel-out/k8-fastbuild/bin/py/test.runfiles/bazel-cdk-repro/py/test.py'.
Hint: make sure your test modules/packages have valid Python names.
Traceback:
py/test.py:1: in
from aws_cdk import Aws
E ImportError: cannot import name 'Aws' from 'aws_cdk' (/home/ubuntu/.cache/bazel/_bazel_ubuntu/f5bb56bb935f39261247d94ebd292fdf/sandbox/linux-sandbox/5/execroot/bazel-cdk-repro/bazel-out/k8-fastbuild/bin/py/test.runfiles/pip_aws_cdk_asset_awscli_v1/site-packages/aws_cdk/__init__.py)
=========================== short test summary I
Aws we can see in the error, it seems to thing that the aws_cdk/__init__.py in pip_aws_cdk_asset_awscli_v1 is the right one, which is why I feel like having multiples in the PYTHONPATH is the issue.
🌍 Your Environment
Operating System:
Ubuntu 22.04
Output of bazel version:
bazel 5.3.2
Rules_python version:
0.15.1
Anything else relevant?