serverless-python-requirements icon indicating copy to clipboard operation
serverless-python-requirements copied to clipboard

slimPatterns with botocore

Open revmischa opened this issue 5 years ago • 3 comments

I'm trying to tell SLSPR to not package up parts of botocore because I don't need to make calls to the services. I tried:

  pythonRequirements:
    dockerizePip: false
    slim: true
    slimPatterns:
      # we don't need to call these services so let's not include the botocore metadata
      # it takes up a lot of space
      - "**/botocore/data/ec2/**"
      - "data/cloudfront/**"
      - "**/data/rds/**"

But ec2, cloudfront, and rds are all present in the package. What am I doing wrong? Using latest plugin/serverless.

revmischa avatar Feb 03 '20 16:02 revmischa

Yeah, unfortunately, file globs in SPR are as horribly broken as every other tool I've seen that uses globs. I always have to hunt down the code running the glob and put print statements in.

Looking at my slim patterns file... You should drop the trailing /** because it will match directories correctly.

You shouldn't need to match **/botocore either, botocore should be at the root of your package. My slim patterns simply have entires like:

    - botocore/data/ec2

**/*.ext works, though, as does path/*/dir.

(FWIW, I stuck them in a separate file because I banned a ton of crap. A lot of python modules carry tests with them, for instance.)

bsamuel-ui avatar Feb 18 '20 19:02 bsamuel-ui

I have exactly this

  pythonRequirements:
    dockerizePip: false
    slim: true
    slimPatterns:
      - botocore/data/ec2
      - botocore/data/cloudfront
      - botocore/data/rds
      - botocore/data/iam
      - botocore/data/s3

but I still see all of them except ec2 in the package :(

revmischa avatar Feb 19 '20 17:02 revmischa

This also wasn't working for me until I added useStaticCache: false so that the dependencies could be rebuilt:

pythonRequirements:
    useStaticCache: false
    dockerizePip: true
    slim: true
    slimPatterns:
      - botocore/data/ec2

chehodgins avatar Nov 04 '21 13:11 chehodgins