vercel / vercel/examples

Flask3 example doesn't work with additional dependencies

Open
#872 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
5.2k
Forks
1.8k
Avg merge
3d 12h
Merged PRs (30d)
6

Description

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/python@3.11/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

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with python/flask3/api/index.py and python/flask3/requirements.txt, then reproduce the reported import failure with vercel dev after adding PyGithub==2.2.0. Trace the dependency-loading behavior shown in the error and verify that the Flask 3 example runs successfully with PyGithub installed.

Written by the indexing model from the issue text.

Assessment

Tech stack
flask, github, python
Domain
backend, cloud
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.