serverless-python-requirements
serverless-python-requirements copied to clipboard
Can't use exclusion glob patterns in slimPatterns
Currently the strip option runs each pattern through glob-all.glob.sync() separately:
https://github.com/UnitedIncome/serverless-python-requirements/blob/f39e166e8221171ec040ca37fe0f98b6ed89ad75/lib/slim.js#L48-L52
This means we can't make use of the glob-all feature giving you exclude patterns.
Can this be updated to map all patterns to their ${folderPath}/${pattern} form and then pass the whole list as one to glob-all.glob.sync()?
I realise that this requires hoisting up the ! at the start of negation patterns pattern, e.g.
slimPatterns:
- "**/*.dist-info*"
- "!**/specific_package.dist-info*"
needs to be translated (given folderPath = "/foo/bar/") to
patterns = [
"/foo/bar/**/*.dist-info*",
"!/foo/bar/**/specific_package.dist-info*"
]
As far as I understand, I cannot use "!**/specific_package.dist-info*" to exclude that folder right? Is there a workaround currently?
@ptrhck I have found a workaround, sadly it's a bit inconvenient to use 😞 At least it works 👍
slim: true
slimPatternsAppendDefaults: false # we need to overwrite default dist-info
slimPatterns:
# "normal" exclusions:
- '**/tests/*'
# default dist-info with !(lib_name*) - matches only if name is not present:
- "**/!(lib_name*)*.dist-info/*"
# the rest of defaults:
- '**/*.py[c|o]'
- '**/__pycache__*'
If I do "**/!(numpy*)*.dist-info/*", all .dist-info files will be removed except for the numpy package?
Yes, everything in this list will be excluded (ie. matches will be deleted) , So it works like that:
**/- Match any directory! (numpy*)- don't match anything beginning with numpy (for numpy will ignore it here, otherwise goes on)*.dist-info...- Match anything having dist-info (numpy was thrown out previously)
Theoretically you could chain more !(...) to exclude more names, though haven't tested it.
Yes, everything in this list will be excluded (ie. matches will be deleted) , So it works like that:
**/- Match any directory! (numpy*)- don't match anything beginning with numpy (for numpy will ignore it here, otherwise goes on)*.dist-info...- Match anything having dist-info (numpy was thrown out previously)Theoretically you could chain more !(...) to exclude more names, though haven't tested it.
How can you chain to exclude more names? **/!(lib_name1*)!(lib_name1*)*.dist-info/* does not work.
Yes, everything in this list will be excluded (ie. matches will be deleted) , So it works like that:
**/- Match any directory! (numpy*)- don't match anything beginning with numpy (for numpy will ignore it here, otherwise goes on)*.dist-info...- Match anything having dist-info (numpy was thrown out previously)Theoretically you could chain more !(...) to exclude more names, though haven't tested it.
How can you chain to exclude more names?
**/!(lib_name1*)!(lib_name1*)*.dist-info/*does not work.
If you are still wondering you can do this
**/!(lib_name1*|lib_name2*|lib_name3*)*.dist-info/*