# Package patterns: how do they really work?

**URL:** <https://forum.serverless.com/t/package-patterns-how-do-they-really-work/16371>\
**Category:** Serverless Framework\
**Created:** [December 7, 2021, 10:06am UTC](https://forum.serverless.com/t/package-patterns-how-do-they-really-work/16371 "2021-12-07T10:06:19Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![alanwilter](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.serverless.com/alanwilter/32/6415_2.png) [@alanwilter](https://forum.serverless.com/u/alanwilter)\
**Post date:** [December 7, 2021, 10:06am UTC](https://forum.serverless.com/t/package-patterns-how-do-they-really-work/16371/1 "2021-12-07T10:06:19Z")

</div>

My project is in python, using `poetry`.

So far, my package is too big (\> 300 Mb zipped!) and I went to investigate. I found in my sls zipped package files like:

```auto
skimage/morphology/tests/ __pycache__ / __init__.cpython-38.pyc

```

I’ve added to my `serverless.yml`, so far:

```auto
package:
  patterns:
    - '!node_modules/**' # by try-and-error I know this one work for sure and so others similar
    - '!test/**'
    - '! **/test*/**' # but, this one?
    - '!docs/**'
    - '!dist/**'
    - '!tools/**'
    - '! __pycache__ /**'
    - '! **/ __pycache__ /**'
    - '!.mypy_cache/**'
    - '!integration_test/**'
    - '!my_pkg*/**'
    - '!*pytest_*'
    - '!*.pyc'

```

I really hoped at least ` - '!*.pyc'` could work but, alas, no!

What patterns above do work, should work and definitely won’t work?

Could [Serverless Framework Guide - AWS Lambda Guide - Packaging](https://www.serverless.com/framework/docs/providers/aws/guide/packaging) be improved?

Why not make use of a plain simple `.ignore` file? A property that could be added to the `serverless.yml` that, hopefully, wil work.

Could it be that `package.patterns` don’t work for the `requirements`?

Because I’ve cleaned `$HOME/.cache/serverless-python-requirements/*` and find-and-remove `*.pyc`, ` __pycache__ ` etc. and that seemed to have made a difference in my pkg size which is down to 100 Mb.

Last but not least. Serverless is a **FANTASTIC** stuff take tons out of ours shoulders when dealing with the horrible AWS services.

---

<div class="post-metadata">

**Author:** ![therealscifi](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.serverless.com/therealscifi/32/8035_2.png) [@therealscifi](https://forum.serverless.com/u/therealscifi)\
**Post date:** [August 24, 2024, 11:38pm UTC](https://forum.serverless.com/t/package-patterns-how-do-they-really-work/16371/2 "2024-08-24T23:38:25Z")

</div>

I wish someone had answered this question already, or if anyone knows whether the \*\* prefix works as well, e.g.

`- **/node_modules/** `
