Code Monkey home page Code Monkey logo

Comments (2)

candlerb avatar candlerb commented on July 17, 2024

Looking at output from strace -s256 -f sls deploy 2>/tmp/strace.out

$ grep execve /tmp/strace.out  | grep -v ENOENT
execve("/usr/bin/sls", ["sls", "deploy"], [/* 22 vars */]) = 0
execve("/usr/bin/node", ["node", "/usr/bin/sls", "deploy"], [/* 22 vars */]) = 0
[pid  7886] execve("/usr/bin/python3", ["python3", "/usr/lib/node_modules/serverless-wsgi/requirements.py", "/usr/lib/node_modules/serverless-wsgi/requirements.txt", "/home/ubuntu/sless/my-service/requirements.txt", "/home/ubuntu/sless/my-service/.requirements"], [/* 22 vars */] <unfinished ...>
[pid  7886] <... execve resumed> )      = 0
[pid  7887] execve("/usr/bin/python2", ["/usr/bin/python2", "/usr/lib/python3/dist-packages/virtualenv.py", "/home/ubuntu/sless/my-service/.requirements/.venv", "--quiet"], [/* 23 vars */] <unfinished ...>
[pid  7887] <... execve resumed> )      = 0
[pid  7888] execve("/home/ubuntu/sless/my-service/.requirements/.venv/bin/python2", ["/home/ubuntu/sless/my-service/.requirements/.venv/bin/python2", "-c", "import sys;out=sys.stdout;getattr(out, \"buffer\", out).write(sys.prefix.encode(\"utf-8\"))"], [/* 23 vars */] <unfinished ...>
[pid  7888] <... execve resumed> )      = 0
[pid  7889] execve("/home/ubuntu/sless/my-service/.requirements/.venv/bin/python2", ["/home/ubuntu/sless/my-service/.requirements/.venv/bin/python2", "-", "setuptools", "pkg_resources", "pip", "wheel"], [/* 30 vars */] <unfinished ...>
[pid  7889] <... execve resumed> )      = 0
[pid  7890] execve("/bin/sh", ["sh", "-c", "LC_ALL=C LANG=C /sbin/ldconfig -p 2>/dev/null"], [/* 30 vars */]) = 0
[pid  7891] execve("/sbin/ldconfig", ["/sbin/ldconfig", "-p"], [/* 31 vars */]) = 0
[pid  7891] execve("/sbin/ldconfig.real", ["/sbin/ldconfig.real", "-p"], [/* 31 vars */]) = 0
[pid  7892] execve("/bin/sh", ["sh", "-c", "uname -p 2> /dev/null"], [/* 30 vars */]) = 0
[pid  7893] execve("/bin/uname", ["uname", "-p"], [/* 30 vars */]) = 0

Note that it's explicitly running /usr/bin/python2

from serverless-wsgi.

candlerb avatar candlerb commented on July 17, 2024

The solution is to add -p <pythonversion> to virtualenv.

I don't know how to get hold of the custom.wsgi.pythonBin setting in requirements.py, but if I hard-code the value I want it works:

--- requirements.py.orig	2017-10-03 11:41:11.433869466 +0000
+++ requirements.py	2017-10-03 11:41:27.806597479 +0000
@@ -41,7 +41,7 @@
         shutil.rmtree(tmp_dir)

     original = sys.argv
-    sys.argv = ['', venv_dir, '--quiet']
+    sys.argv = ['', venv_dir, '--quiet', '-p', 'python3']
     try:
         virtualenv.main()
     finally:

Now the zipfile is 952 KB

$ unzip -v .serverless/my-service.zip
Archive:  .serverless/my-service.zip
 Length   Method    Size  Cmpr    Date    Time   CRC-32   Name
--------  ------  ------- ---- ---------- ----- --------  ----
    6091  Defl:N     2497  59% 1980-01-01 00:00 04039966  wsgi.py
      13  Defl:N       15 -15% 1980-01-01 00:00 a6e25e52  .wsgi_app
    1591  Defl:N      831  48% 1980-01-01 00:00 a3e71e5a  Werkzeug-0.12.2.dist-info/DESCRIPTION.rst
       4  Defl:N        6 -50% 1980-01-01 00:00 c2971fc7  Werkzeug-0.12.2.dist-info/INSTALLER
    1532  Defl:N      816  47% 1980-01-01 00:00 c0421a8f  Werkzeug-0.12.2.dist-info/LICENSE.txt
    2738  Defl:N     1233  55% 1980-01-01 00:00 bde3ac78  Werkzeug-0.12.2.dist-info/METADATA
    1276  Defl:N      593  54% 1980-01-01 00:00 a9fbc245  Werkzeug-0.12.2.dist-info/metadata.json
    6646  Defl:N     2964  55% 1980-01-01 00:00 b70eb044  Werkzeug-0.12.2.dist-info/RECORD
       9  Defl:N       11 -22% 1980-01-01 00:00 d4cd6b6c  Werkzeug-0.12.2.dist-info/top_level.txt
     110  Defl:N       95  14% 1980-01-01 00:00 6f7f3387  Werkzeug-0.12.2.dist-info/WHEEL
   14633  Defl:N     7005  52% 1980-01-01 00:00 c31e127d  __pycache__/xmltodict.cpython-35.pyc
  101373  Defl:N    33527  67% 1980-01-01 00:00 6291aaa7  pkg_resources/__init__.py
  106583  Defl:N    43516  59% 1980-01-01 00:00 988b7b82  pkg_resources/__pycache__/__init__.cpython-35.pyc
     761  Defl:N      468  39% 1980-01-01 00:00 dc457869  pkg_resources/__pycache__/py31compat.cpython-35.pyc
...
   82986  Defl:N    26108  69% 1980-01-01 00:00 acc1e2c0  werkzeug/wrappers.py
   42838  Defl:N    13458  69% 1980-01-01 00:00 7b28fd02  werkzeug/wsgi.py
      10  Defl:N       12 -20% 1980-01-01 00:00 d27f2d5e  xmltodict-0.11.0.dist-info/DESCRIPTION.rst
       4  Defl:N        6 -50% 1980-01-01 00:00 c2971fc7  xmltodict-0.11.0.dist-info/INSTALLER
    1144  Defl:N      372  68% 1980-01-01 00:00 e7c56768  xmltodict-0.11.0.dist-info/METADATA
    1270  Defl:N      518  59% 1980-01-01 00:00 c16b04df  xmltodict-0.11.0.dist-info/metadata.json
     713  Defl:N      429  40% 1980-01-01 00:00 8d51f2ed  xmltodict-0.11.0.dist-info/RECORD
      10  Defl:N       12 -20% 1980-01-01 00:00 06727e3b  xmltodict-0.11.0.dist-info/top_level.txt
     110  Defl:N       95  14% 1980-01-01 00:00 1382dbab  xmltodict-0.11.0.dist-info/WHEEL
   17356  Defl:N     5618  68% 1980-01-01 00:00 65119ad2  xmltodict.py
--------          -------  ---                            -------
 2578966           951253  63%                            145 files

from serverless-wsgi.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.