Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Flask3 example doesn't work with additional dependencies #872

Open
okonet opened this issue Feb 23, 2024 · 0 comments
Open

Flask3 example doesn't work with additional dependencies #872

okonet opened this issue Feb 23, 2024 · 0 comments

Comments

@okonet
Copy link

okonet commented Feb 23, 2024

I've tried to run the example with an additional dependency PyGithub but it fails to run using vercel dev:

> Built @vercel/python@latest:api/index.py [6s]
ModuleNotFoundError: No module named '_cffi_backend'
thread '<unnamed>' panicked at /Users/runner/.cargo/registry/src/index.crates.io-6f17d22bba15001f/pyo3-0.20.2/src/err/mod.rs:788:5:
Python API call failed
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
Traceback (most recent call last):
  File "/Users/okonet/Library/Caches/com.vercel.fun/runtimes/python3/../python/bootstrap.py", line 147, in <module>
    lambda_runtime_main()
  File "/Users/okonet/Library/Caches/com.vercel.fun/runtimes/python3/../python/bootstrap.py", line 127, in lambda_runtime_main
    fn = lambda_runtime_get_handler()
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/okonet/Library/Caches/com.vercel.fun/runtimes/python3/../python/bootstrap.py", line 113, in lambda_runtime_get_handler
    mod = importlib.import_module(module_name)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/[email protected]/3.11.2_1/Frameworks/Python.framework/Versions/3.11/lib/python3.11/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "<frozen importlib._bootstrap>", line 1206, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1178, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1149, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 690, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 940, in exec_module
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
  File "/var/folders/8z/jnh1lm1j6_vbhbc66cyrp3zw0000gn/T/zeit-fun-00bcf47e5b271/vc__handler__python.py", line 13, in <module>
    __vc_spec.loader.exec_module(__vc_module)
  File "<frozen importlib._bootstrap_external>", line 940, in exec_module
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
  File "/private/var/folders/8z/jnh1lm1j6_vbhbc66cyrp3zw0000gn/T/zeit-fun-00bcf47e5b271/./api/index.py", line 2, in <module>
    from github import Github
  File "/var/folders/8z/jnh1lm1j6_vbhbc66cyrp3zw0000gn/T/zeit-fun-00bcf47e5b271/github/__init__.py", line 51, in <module>
    from . import Auth
  File "/var/folders/8z/jnh1lm1j6_vbhbc66cyrp3zw0000gn/T/zeit-fun-00bcf47e5b271/github/Auth.py", line 33, in <module>
    import jwt
  File "/var/folders/8z/jnh1lm1j6_vbhbc66cyrp3zw0000gn/T/zeit-fun-00bcf47e5b271/jwt/__init__.py", line 1, in <module>
    from .api_jwk import PyJWK, PyJWKSet
  File "/var/folders/8z/jnh1lm1j6_vbhbc66cyrp3zw0000gn/T/zeit-fun-00bcf47e5b271/jwt/api_jwk.py", line 7, in <module>
    from .algorithms import get_default_algorithms, has_crypto, requires_cryptography
  File "/var/folders/8z/jnh1lm1j6_vbhbc66cyrp3zw0000gn/T/zeit-fun-00bcf47e5b271/jwt/algorithms.py", line 12, in <module>
    from .utils import (
  File "/var/folders/8z/jnh1lm1j6_vbhbc66cyrp3zw0000gn/T/zeit-fun-00bcf47e5b271/jwt/utils.py", line 7, in <module>
    from cryptography.hazmat.primitives.asymmetric.ec import EllipticCurve
  File "/var/folders/8z/jnh1lm1j6_vbhbc66cyrp3zw0000gn/T/zeit-fun-00bcf47e5b271/cryptography/hazmat/primitives/asymmetric/ec.py", line 11, in <module>
    from cryptography.hazmat._oid import ObjectIdentifier
  File "/var/folders/8z/jnh1lm1j6_vbhbc66cyrp3zw0000gn/T/zeit-fun-00bcf47e5b271/cryptography/hazmat/_oid.py", line 7, in <module>
    from cryptography.hazmat.bindings._rust import (
pyo3_runtime.PanicException: Python API call failed
LambdaError: RequestId: 7bc5e915-4323-4dbe-8726-59ec09ba52ea Process exited before completing request
    at Lambda.<anonymous> (/Users/okonet/.fnm/node-versions/v18.18.2/installation/lib/node_modules/vercel/node_modules/@vercel/fun/dist/src/index.js:110:27)
    at Generator.next (<anonymous>)
    at fulfilled (/Users/okonet/.fnm/node-versions/v18.18.2/installation/lib/node_modules/vercel/node_modules/@vercel/fun/dist/src/index.js:24:58)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)

To reproduce, use this path:

diff --git a/python/flask3/api/index.py b/python/flask3/api/index.py
index 20726e5e..d3bfc045 100644
--- a/python/flask3/api/index.py
+++ b/python/flask3/api/index.py
@@ -1,4 +1,5 @@
 from flask import Flask
+from github import Github
 
 app = Flask(__name__)
 
@@ -8,4 +9,4 @@ def home():
 
 @app.route('/about')
 def about():
-    return 'About'
\ No newline at end of file
+    return 'About'
diff --git a/python/flask3/requirements.txt b/python/flask3/requirements.txt
index 047e9501..396a6068 100644
--- a/python/flask3/requirements.txt
+++ b/python/flask3/requirements.txt
@@ -1 +1,2 @@
 Flask==3.0.0
+PyGithub==2.2.0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant