-
Notifications
You must be signed in to change notification settings - Fork 144
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added support for vendored pip dependencies in python buildpack via b…
…uild envvar GOOGLE_VENDOR_PIP_DEPENDENCIES. PiperOrigin-RevId: 568612289 Change-Id: Id6871f3b30a13ae1a7a5e2fcb15b23a9fac4f32f
- Loading branch information
1 parent
0563174
commit df4a28b
Showing
13 changed files
with
113 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
builders/testdata/python/generic/pip_vendored_dependencies/Procfile
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
web: python3 main.py |
52 changes: 52 additions & 0 deletions
52
builders/testdata/python/generic/pip_vendored_dependencies/main.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
# Copyright 2020 Google LLC | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
"""Simple web server used to validate that pip vendored deps are installed. | ||
""" | ||
from http.server import BaseHTTPRequestHandler, HTTPServer | ||
from sample_pip_dependency import sample | ||
|
||
|
||
""" Simple web server to respond to HTTP GET. | ||
""" | ||
class MyServer(BaseHTTPRequestHandler): | ||
def _set_headers(self): | ||
self.send_response(200) | ||
self.send_header("Content-type", "text/html") | ||
self.end_headers() | ||
|
||
def _html(self, message): | ||
"""This just generates an HTML document that includes `message` | ||
in the body. | ||
""" | ||
content = f"{message}" | ||
return content.encode("utf8") # NOTE: must return a bytes object! | ||
|
||
def do_GET(self): | ||
self._set_headers() | ||
message = sample.helloworld() | ||
if message == "hello world - from pip dependency": | ||
self.wfile.write(self._html("PASS")) | ||
else: | ||
self.wfile.write(self._html("FAIL")) | ||
|
||
if __name__ == "__main__": | ||
webServer = HTTPServer(("0.0.0.0", 8080), MyServer) | ||
|
||
try: | ||
webServer.serve_forever() | ||
except KeyboardInterrupt: | ||
pass | ||
|
||
webServer.server_close() |
Binary file added
BIN
+1.77 KB
...on/generic/pip_vendored_dependencies/package/sample_pip_dependency-0.0.1-py3-none-any.whl
Binary file not shown.
10 changes: 10 additions & 0 deletions
10
...ders/testdata/python/generic/pip_vendored_dependencies/python-package/README.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
# SAMPLE-PIP-DEPENDENCY | ||
|
||
This is a simple package to test pip vendored deps. | ||
|
||
# Generate distribution package | ||
Use "python3 -m build" in python-package to generate .whl binary. pyproject.toml has all details to create distribution package. | ||
Leave tests/ and __init__.py empty - these are merely required to generate distribtuion package. | ||
|
||
# Usage | ||
Import this as "from sample_pip_dependency import sample" and use as sample.helloworld() to test. |
22 changes: 22 additions & 0 deletions
22
builders/testdata/python/generic/pip_vendored_dependencies/python-package/pyproject.toml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
[build-system] | ||
requires = ["setuptools>=61.0"] | ||
build-backend = "setuptools.build_meta" | ||
|
||
[project] | ||
name = "sample_pip_dependency" | ||
version = "0.0.1" | ||
authors = [ | ||
{ name="Kritka Sahni", email="[email protected]" }, | ||
] | ||
description = "A small example package to test pip vendored deps" | ||
readme = "README.md" | ||
requires-python = ">=3.7" | ||
classifiers = [ | ||
"Programming Language :: Python :: 3", | ||
"License :: OSI Approved :: MIT License", | ||
"Operating System :: OS Independent", | ||
] | ||
|
||
[project.urls] | ||
"Homepage" = "https://github.com/pypa/sampleproject" | ||
"Bug Tracker" = "https://github.com/pypa/sampleproject/issues" |
Empty file.
2 changes: 2 additions & 0 deletions
2
...thon/generic/pip_vendored_dependencies/python-package/src/sample_pip_dependency/sample.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
def helloworld(): | ||
return "hello world - from pip dependency" |
4 changes: 4 additions & 0 deletions
4
...estdata/python/generic/pip_vendored_dependencies/python-package/tests/README.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# SAMPLE-PIP-DEPENDENCY | ||
# Generate distribution package | ||
Leave tests/ empty - it is merely required to generate distribution package. | ||
|
1 change: 1 addition & 0 deletions
1
builders/testdata/python/generic/pip_vendored_dependencies/requirements.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
sample-pip-dependency==0.0.1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters