Skip to content

Commit 16da49a

Browse files
authored
Merge pull request #109 from fnproject/add-python3.8.5
Add Python 3.8.5 images
2 parents b13078f + b65a664 commit 16da49a

17 files changed

Lines changed: 76 additions & 29 deletions

File tree

.circleci/config.yml

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ orbs:
44
jobs:
55
"test":
66
docker:
7-
- image: circleci/python:3.7.0
7+
- image: circleci/python:3.8.5
88
working_directory: ~/fdk-python
99
steps:
1010
- checkout
@@ -31,10 +31,10 @@ jobs:
3131
- run:
3232
command: |
3333
. venv/bin/activate
34-
tox -epy3.7
34+
tox -epy3.8
3535
"deploy":
3636
docker:
37-
- image: circleci/python:3.7.0
37+
- image: circleci/python:3.8.5
3838
working_directory: ~/fdk-python
3939
steps:
4040
- checkout
@@ -56,6 +56,7 @@ jobs:
5656
5757
./build-images.sh 3.6
5858
./build-images.sh 3.7.1
59+
./build-images.sh 3.8.5
5960
./release.sh
6061
./release_images.sh
6162
fi
@@ -98,6 +99,25 @@ jobs:
9899
policy_bundle_file_path: .circleci/.anchore/policy_bundle.json
99100
- anchore/parse_reports
100101

102+
"python385_security_check":
103+
executor: anchore/anchore_engine
104+
working_directory: ~/fdk-python
105+
steps:
106+
- setup_remote_docker:
107+
docker_layer_caching: false
108+
- checkout
109+
- run:
110+
name: Python 3.8.5 build
111+
command: |
112+
apk add bash
113+
./build-images.sh 3.8.5
114+
- anchore/analyze_local_image:
115+
image_name: "fnproject/python:3.8.5-dev fnproject/python:3.8.5"
116+
timeout: '500'
117+
policy_failure: true
118+
policy_bundle_file_path: .circleci/.anchore/policy_bundle.json
119+
- anchore/parse_reports
120+
101121
workflows:
102122
version: 2
103123
build:
@@ -118,3 +138,4 @@ workflows:
118138
jobs:
119139
- "python36_security_check"
120140
- "python371_security_check"
141+
- "python385_security_check"

README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Function development kit for Python
2-
The python FDK lets you write functions in python 3.6/3.7
2+
The python FDK lets you write functions in python 3.6/3.7/3.8
33

44
## Simplest possible function
55

@@ -306,12 +306,12 @@ Then just do:
306306

307307
First of all create a test function:
308308
```bash
309-
fn init --runtime python3.7.1 test-function
309+
fn init --runtime python3.8.5 test-function
310310
```
311311

312312
Create a Dockerfile in a function's folder:
313313
```dockerfile
314-
FROM fnproject/python:3.7.1-dev as build-stage
314+
FROM fnproject/python:3.8.5-dev as build-stage
315315

316316
ADD . /function
317317
WORKDIR /function
@@ -320,7 +320,7 @@ RUN pip3 install --target /python/ --no-cache --no-cache-dir fdk-test-py3-none-
320320

321321
RUN rm -fr ~/.cache/pip /tmp* requirements.txt func.yaml Dockerfile .venv
322322

323-
FROM fnproject/python:3.7.1
323+
FROM fnproject/python:3.8.5
324324

325325
COPY --from=build-stage /function /function
326326
COPY --from=build-stage /python /python
@@ -398,7 +398,7 @@ If you've been using json lib to turn an incoming data into a dictionary you nee
398398
### Dockerfile
399399
If you've been using CLI to build function without modifying runtime in `func.yaml` to `docker`
400400
instead of `python` then the only thing you need is to update the CLI to the latest version and
401-
pin your Python runtime version to `python` or `python3.7.1`.
401+
pin your Python runtime version to `python`, `python3.7.1`, or `python3.8.5`.
402402

403403
If you've been using custom multi-stage Dockerfile (derived from what Fn CLI generates)
404404
the only thing that is necessary to change is an `ENTRYPOINT` from:

build-images.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
set -xe
44

5-
pyversion=${1:-"3.7.1"}
5+
pyversion=${1:-"3.8.5"}
66

77
pushd images/build-stage/${pyversion} && docker build -t fnproject/python:${pyversion}-dev . && popd
88
pushd images/runtime/${pyversion} && docker build -t fnproject/python:${pyversion} . && popd

fdk/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828

2929
def start(handle_code: customer_code.Function,
3030
uds: str,
31-
loop: asyncio.AbstractEventLoop=None):
31+
loop: asyncio.AbstractEventLoop = None):
3232
"""
3333
Unix domain socket HTTP server entry point
3434
:param handle_code: customer's code

fdk/async_http/response.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ def get_headers(
117117

118118
headers = self._parse_headers()
119119

120-
if self.status is 200:
120+
if self.status == 200:
121121
status = b"OK"
122122
else:
123123
status = STATUS_CODES.get(self.status)
@@ -227,7 +227,7 @@ def output(self, version="1.1", keep_alive=False, keep_alive_timeout=None):
227227

228228
headers = self._parse_headers()
229229

230-
if self.status is 200:
230+
if self.status == 200:
231231
status = b"OK"
232232
else:
233233
status = STATUS_CODES.get(self.status, b"UNKNOWN RESPONSE")

fdk/context.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -118,9 +118,9 @@ def Method(self):
118118
return self._method
119119

120120
def __is_gateway(self):
121-
return (constants.FN_INTENT in self.__headers and
122-
self.__headers.get(constants.FN_INTENT) ==
123-
constants.INTENT_HTTP_REQUEST)
121+
return (constants.FN_INTENT in self.__headers
122+
and self.__headers.get(constants.FN_INTENT)
123+
== constants.INTENT_HTTP_REQUEST)
124124

125125

126126
def context_from_format(format_def: str, **kwargs) -> (

fdk/headers.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,8 @@ def encap_headers(headers, status=None):
6262
k = k.lower()
6363
if k.startswith(constants.FN_HTTP_PREFIX): # by default merge
6464
push_header(new_headers, k, v)
65-
if (k == constants.CONTENT_TYPE or
66-
k == constants.FN_FDK_VERSION): # but don't merge these
65+
if (k == constants.CONTENT_TYPE
66+
or k == constants.FN_FDK_VERSION): # but don't merge these
6767
new_headers[k] = v
6868
else:
6969
push_header(new_headers, constants.FN_HTTP_PREFIX + k, v)

fdk/response.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,10 @@
2020
class Response(object):
2121

2222
def __init__(self, ctx: context.InvokeContext,
23-
response_data: Union[str, bytes]=None,
24-
headers: dict=None,
25-
status_code: int=200,
26-
response_encoding: str="utf-8"):
23+
response_data: Union[str, bytes] = None,
24+
headers: dict = None,
25+
status_code: int = 200,
26+
response_encoding: str = "utf-8"):
2727
"""
2828
Creates an FDK-readable response object
2929
:param ctx: invoke context

fdk/tests/tcp_debug.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
from fdk.async_http import router
2424

2525

26-
def handle(handle_code: customer_code.Function, port: int=5000):
26+
def handle(handle_code: customer_code.Function, port: int = 5000):
2727
"""
2828
FDK entry point
2929
:param handle_code: customer's code

images/README.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,11 @@ pushd build-stage/3.7.1; docker build -t fnproject/python:3.7.1-dev .; popd
1212
pushd runtime/3.7.1; docker build -t fnproject/python:3.7.1 .; popd
1313
```
1414

15+
```sh
16+
pushd build-stage/3.8.5; docker build -t fnproject/python:3.8.5-dev .; popd
17+
pushd runtime/3.8.5; docker build -t fnproject/python:3.8.5 .; popd
18+
```
19+
1520
Then push:
1621

1722
```sh
@@ -23,3 +28,8 @@ docker push fnproject/python:3.6
2328
docker push fnproject/python:3.7.1-dev
2429
docker push fnproject/python:3.7.1
2530
```
31+
32+
```sh
33+
docker push fnproject/python:3.8.5-dev
34+
docker push fnproject/python:3.8.5
35+
```

0 commit comments

Comments
 (0)