Only download pipenv when needed · ivanmir/python-buildpack@74234cd · GitHub
Skip to content

Commit 74234cd

Browse files
Tyler Phelancf-buildpacks-eng
authored andcommitted
Only download pipenv when needed
- Only needed when there is a Pipfile and no requirements.txt file [#156133859] Signed-off-by: Jackson Feeny <jacksonfeeny@gmail.com>
1 parent 3815c92 commit 74234cd

8 files changed

Lines changed: 300 additions & 18 deletions

File tree

Lines changed: 2 additions & 0 deletions
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
[[source]]
2+
url = "https://pypi.python.org/simple"
3+
verify_ssl = true
4+
5+
[packages]
6+
Flask = "==0.10.1"
7+
gunicorn = "==19.3.0"
8+
itsdangerous = "==0.24"
9+
Jinja2 = "==2.7.2"
10+
MarkupSafe = "==0.21"
11+
Werkzeug = "==0.10.4"
12+
13+
[requires]
14+
python_version='3.5'
15+
16+
[dev-packages]
17+
tox = "*"
18+
coverage = "*"
19+
"flake8" = "*"
20+
flask-testing = "*"

fixtures/pipfile_and_requirements/Pipfile.lock

Lines changed: 207 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
web: gunicorn server:app
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
flask==0.10.1
2+
gunicorn==19.3.0
3+
itsdangerous==0.24
4+
jinja2==2.7.2
5+
markupsafe==0.21
6+
werkzeug==0.10.4
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
from flask import Flask, request
2+
import subprocess
3+
4+
app = Flask(__name__)
5+
6+
@app.route("/")
7+
def hello():
8+
return "Hello, World with no pipenv!"
9+
10+
@app.route('/execute', methods=['POST'])
11+
def execute():
12+
with open('runtime.py', 'w') as f:
13+
f.write(request.values.get('code'))
14+
return subprocess.check_output(["python", "runtime.py"])
15+
16+
app.debug=True

src/python/integration/deploy_python_app_pipenv_test.go

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ var _ = Describe("deploying a flask web app", func() {
2727

2828
It("gets the python version from pipfile.lock and generates a runtime.txt", func() {
2929
Expect(app.Stdout.String()).To(ContainSubstring("Installing python 3.6."))
30+
Expect(app.Stdout.String()).To(ContainSubstring("Installing pipenv"))
3031
Expect(app.GetBody("/")).To(ContainSubstring("Hello, World with pipenv!"))
3132
Expect(app.Stdout.String()).To(ContainSubstring("Dir checksum unchanged"))
3233
})
@@ -51,4 +52,33 @@ var _ = Describe("deploying a flask web app", func() {
5152

5253
AssertNoInternetTraffic("flask_python_3_pipenv_vendored")
5354
})
55+
56+
Context("no Pipfile", func() {
57+
BeforeEach(func() {
58+
app = cutlass.New(filepath.Join(bpDir, "fixtures", "no_deps"))
59+
app.Buildpacks = []string{"python_buildpack"}
60+
app.SetEnv("BP_DEBUG", "1")
61+
})
62+
63+
It("deploys without downloading pipenv", func() {
64+
PushAppAndConfirm(app)
65+
Expect(app.Stdout.String()).NotTo(ContainSubstring("Installing pipenv"))
66+
Expect(app.GetBody("/gg")).To(ContainSubstring("Here is your output for /gg"))
67+
})
68+
})
69+
70+
Context("When there is a requirements.txt and a Pipfile", func() {
71+
BeforeEach(func() {
72+
app = cutlass.New(filepath.Join(bpDir, "fixtures", "pipfile_and_requirements"))
73+
app.Buildpacks = []string{"python_buildpack"}
74+
app.SetEnv("BP_DEBUG", "1")
75+
})
76+
77+
It("deploys without downloading pipenv", func() {
78+
PushAppAndConfirm(app)
79+
Expect(app.Stdout.String()).NotTo(ContainSubstring("Installing pipenv"))
80+
Expect(app.GetBody("/")).To(ContainSubstring("Hello, World with no pipenv!"))
81+
})
82+
})
83+
5484
})

src/python/supply/supply.go

Lines changed: 18 additions & 18 deletions

0 commit comments

Comments
 (0)