Skip to content

Commit ba875a6

Browse files
chore(python): use ubuntu 22.04 in docs image (googleapis#454)
Source-Link: googleapis/synthtool@f15cc72 Post-Processor: gcr.io/cloud-devrel-public-resources/owlbot-python:latest@sha256:bc5eed3804aec2f05fad42aacf973821d9500c174015341f721a984a0825b6fd
1 parent 285913a commit ba875a6

File tree

4 files changed

+66
-7
lines changed

4 files changed

+66
-7
lines changed

.github/.OwlBot.lock.yaml

+2-2
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,5 @@
1313
# limitations under the License.
1414
docker:
1515
image: gcr.io/cloud-devrel-public-resources/owlbot-python:latest
16-
digest: sha256:8a5d3f6a2e43ed8293f34e06a2f56931d1e88a2694c3bb11b15df4eb256ad163
17-
# created: 2022-04-06T10:30:21.687684602Z
16+
digest: sha256:bc5eed3804aec2f05fad42aacf973821d9500c174015341f721a984a0825b6fd
17+
# created: 2022-04-21T15:43:16.246106921Z

.kokoro/docker/docs/Dockerfile

+18-2
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
from ubuntu:20.04
15+
from ubuntu:22.04
1616

1717
ENV DEBIAN_FRONTEND noninteractive
1818

@@ -60,8 +60,24 @@ RUN apt-get update \
6060
&& rm -rf /var/lib/apt/lists/* \
6161
&& rm -f /var/cache/apt/archives/*.deb
6262

63+
###################### Install python 3.8.11
64+
65+
# Download python 3.8.11
66+
RUN wget https://www.python.org/ftp/python/3.8.11/Python-3.8.11.tgz
67+
68+
# Extract files
69+
RUN tar -xvf Python-3.8.11.tgz
70+
71+
# Install python 3.8.11
72+
RUN ./Python-3.8.11/configure --enable-optimizations
73+
RUN make altinstall
74+
75+
###################### Install pip
6376
RUN wget -O /tmp/get-pip.py 'https://bootstrap.pypa.io/get-pip.py' \
64-
&& python3.8 /tmp/get-pip.py \
77+
&& python3 /tmp/get-pip.py \
6578
&& rm /tmp/get-pip.py
6679

80+
# Test pip
81+
RUN python3 -m pip
82+
6783
CMD ["python3.8"]

noxfile.py

+24-3
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@
2626
import nox
2727

2828
BLACK_VERSION = "black==22.3.0"
29-
BLACK_PATHS = ["docs", "sqlalchemy_bigquery", "tests", "noxfile.py", "setup.py"]
29+
ISORT_VERSION = "isort==5.10.1"
30+
LINT_PATHS = ["docs", "sqlalchemy_bigquery", "tests", "noxfile.py", "setup.py"]
3031

3132
DEFAULT_PYTHON_VERSION = "3.8"
3233

@@ -109,7 +110,7 @@ def lint(session):
109110
session.run(
110111
"black",
111112
"--check",
112-
*BLACK_PATHS,
113+
*LINT_PATHS,
113114
)
114115
session.run("flake8", "sqlalchemy_bigquery", "tests")
115116

@@ -120,7 +121,27 @@ def blacken(session):
120121
session.install(BLACK_VERSION)
121122
session.run(
122123
"black",
123-
*BLACK_PATHS,
124+
*LINT_PATHS,
125+
)
126+
127+
128+
@nox.session(python=DEFAULT_PYTHON_VERSION)
129+
def format(session):
130+
"""
131+
Run isort to sort imports. Then run black
132+
to format code to uniform standard.
133+
"""
134+
session.install(BLACK_VERSION, ISORT_VERSION)
135+
# Use the --fss option to sort imports using strict alphabetical order.
136+
# See https://pycqa.github.io/isort/docs/configuration/options.html#force-sort-within-sections
137+
session.run(
138+
"isort",
139+
"--fss",
140+
*LINT_PATHS,
141+
)
142+
session.run(
143+
"black",
144+
*LINT_PATHS,
124145
)
125146

126147

samples/snippets/noxfile.py

+22
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
# WARNING - WARNING - WARNING - WARNING - WARNING
3131

3232
BLACK_VERSION = "black==22.3.0"
33+
ISORT_VERSION = "isort==5.10.1"
3334

3435
# Copy `noxfile_config.py` to your directory and modify it instead.
3536

@@ -168,12 +169,33 @@ def lint(session: nox.sessions.Session) -> None:
168169

169170
@nox.session
170171
def blacken(session: nox.sessions.Session) -> None:
172+
"""Run black. Format code to uniform standard."""
171173
session.install(BLACK_VERSION)
172174
python_files = [path for path in os.listdir(".") if path.endswith(".py")]
173175

174176
session.run("black", *python_files)
175177

176178

179+
#
180+
# format = isort + black
181+
#
182+
183+
184+
@nox.session
185+
def format(session: nox.sessions.Session) -> None:
186+
"""
187+
Run isort to sort imports. Then run black
188+
to format code to uniform standard.
189+
"""
190+
session.install(BLACK_VERSION, ISORT_VERSION)
191+
python_files = [path for path in os.listdir(".") if path.endswith(".py")]
192+
193+
# Use the --fss option to sort imports using strict alphabetical order.
194+
# See https://pycqa.github.io/isort/docs/configuration/options.html#force-sort-within-sections
195+
session.run("isort", "--fss", *python_files)
196+
session.run("black", *python_files)
197+
198+
177199
#
178200
# Sample Tests
179201
#

0 commit comments

Comments
 (0)