2

I am facing an issue with AWS lambda function. I am unable to import pygit2 library into my function. I tried it on 4 different runtime environments and each gives a different error, which makes me think that there is something wrong within the library rather than my code. These are the errors I get: github_pull_source is the name of my function.

Python 2.7 - Unable to import module 'github_pull_source': No module named _pygit2
Python 3.6 - Unable to import module 'github_pull_source': /var/task/_cffi_backend.so: undefined symbol: _Py_ZeroStruct
Python 3.7 - Unable to import module 'github_pull_source': No module named 'pygit2._pygit2'
Python 3.8 - Unable to import module 'github_pull_source': No module named 'pygit2._pygit2'

I import the library like so:

from pygit2 import Keypair, discover_repository, Repository, clone_repository, RemoteCallbacks

Structure of the deployment package

deployment_package.zip
  - source_code.py
  - __init__.py
  - pygit2
  - libgit2-f9f42b17.so.1.0.0
  - libgit2.tar.gz
  - libgit2.so.26
  - _pygit2.so
  - and some other libraries like requests etc

Have anyone experienced anything similar?

Thanks

Marcin
  • 215,873
  • 14
  • 235
  • 294
Lukas
  • 33
  • 4
  • Have you included the library code in your deployment package? – jellycsc Jul 16 '20 at 17:29
  • Hey Lukas, may you share the deployment script(e.g. serveless file) to check how are you generating your package and the code you are using. – Rafael Gorski Jul 16 '20 at 18:37
  • For now, I manually upload zip file through the aws console. I used virtual environment to pull pygit2 library which I then simply added to the deployment_package.zip I will edit the post to reflect the structure of the deployment package. – Lukas Jul 17 '20 at 09:57
  • Still facing this issue? I could attempt to provide working solution if this is still of intrest? – Marcin Oct 09 '20 at 23:26
  • @Marcin Thanks for offering, I've solved the problem now. – Lukas Oct 12 '20 at 11:02
  • @Lukas No problem. If you want, you can answer your own question if you found the solution. – Marcin Oct 12 '20 at 11:04

1 Answers1

0

I have now managed to solve the problem by creating a lambda layer. The problem seems to be with the python packages that are in the lambda container by default.

See details in this issue I raised here.

Hopefully this will help others too.

Lukas
  • 33
  • 4