Skip to content

Commit e968e98

Browse files
authored
Update to python 3.10 (#684)
* Upgrade black to remove need for typed-ast * Simplify workflow and install wheel * Upgrade to python 3.10 * Update documentation
1 parent d4678ef commit e968e98

File tree

13 files changed

+35
-27
lines changed

13 files changed

+35
-27
lines changed

.github/actions/setup/action.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,10 @@ runs:
6767
sudo chown root:root shellcheck
6868
sudo mv shellcheck "$install_dir"
6969
fi
70+
- name: Setup Python
71+
uses: actions/setup-python@v4
72+
with:
73+
python-version: '3.10'
7074
- name: Cache Python environment
7175
uses: actions/cache@v3
7276
id: cache-python
@@ -80,5 +84,6 @@ runs:
8084
run: |
8185
if [[ "$CACHE_HIT" != 'true' ]]; then
8286
python -m pip install --upgrade pip
87+
pip install wheel
8388
pip install -r requirements.txt
8489
fi

.github/workflows/pr.yml

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,6 @@ jobs:
88
steps:
99
- name: Checkout the Git repository
1010
uses: actions/checkout@v3
11-
- name: Setup Python
12-
uses: actions/setup-python@v4
13-
with:
14-
python-version: '3.8'
1511
- name: Setup Toltec dependencies
1612
uses: ./.github/actions/setup
1713
- name: Check formatting
@@ -25,10 +21,6 @@ jobs:
2521
steps:
2622
- name: Checkout the Git repository
2723
uses: actions/checkout@v3
28-
- name: Setup Python
29-
uses: actions/setup-python@v4
30-
with:
31-
python-version: '3.8'
3224
- name: Setup Toltec dependencies
3325
uses: ./.github/actions/setup
3426
- name: Build packages

.github/workflows/stable.yml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,6 @@ jobs:
1010
steps:
1111
- name: Checkout the Git repository
1212
uses: actions/checkout@v3
13-
- name: Setup Python
14-
uses: actions/setup-python@v4
15-
with:
16-
python-version: '3.8'
1713
- name: Setup Toltec dependencies
1814
uses: ./.github/actions/setup
1915
- name: Build packages

.github/workflows/testing.yml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,6 @@ jobs:
1010
steps:
1111
- name: Checkout the Git repository
1212
uses: actions/checkout@v3
13-
- name: Setup Python
14-
uses: actions/setup-python@v4
15-
with:
16-
python-version: '3.8'
1713
- name: Setup Toltec dependencies
1814
uses: ./.github/actions/setup
1915
- name: Build packages

docs/building.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ Before running the build, make sure you have all the required dependencies:
1818

1919
* Docker
2020
* bsdtar
21-
* Python ⩾ 3.8
21+
* Python 3.10
2222

2323
You’ll also need all the Python modules listed in [requirements.txt](../requirements.txt) (install them by running `pip install --user -r requirements.txt` or using a [virtual environment](https://docs.python.org/3/tutorial/venv.html)).
2424

requirements.txt

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
appdirs==1.4.4
2-
astroid==2.4.2
3-
black==20.8b1
2+
astroid==2.15.4
3+
black==23.3.0
44
certifi==2020.12.5
55
chardet==4.0.0
6-
click==7.1.2
6+
click==8.1.3
77
docker==4.4.1
88
idna==2.10
99
isort==5.7.0
@@ -13,16 +13,15 @@ MarkupSafe==1.1.1
1313
mccabe==0.6.1
1414
mypy==0.790
1515
mypy-extensions==0.4.3
16-
pathspec==0.8.1
16+
pathspec==0.11.1
1717
pyelftools==0.27
18-
pylint==2.6.0
18+
pylint==2.17.4
1919
python-dateutil==2.8.1
2020
regex==2020.11.13
2121
requests==2.25.1
2222
six==1.15.0
2323
toml==0.10.2
24-
typed-ast==1.4.2
25-
typing-extensions==3.7.4.3
24+
typing-extensions==4.5.0
2625
urllib3==1.26.2
2726
websocket-client==0.57.0
2827
wrapt==1.12.1

scripts/toltec/bash.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -334,6 +334,7 @@ def run_script(variables: Variables, script: str) -> LogGenerator:
334334
:returns: generator yielding output lines from the script
335335
:raises ScriptError: if the script exits with a non-zero code
336336
"""
337+
# pylint: disable-next=consider-using-with
337338
process = subprocess.Popen(
338339
["/usr/bin/env", "bash"],
339340
stdin=subprocess.PIPE,

scripts/toltec/builder.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ def __init__(self, work_dir: str, repo_dir: str) -> None:
9696
self.context: Dict[str, str] = {}
9797
self.adapter = BuildContextAdapter(logger, self.context)
9898

99+
# pylint: disable-next=unspecified-encoding
99100
with open(install_lib_path, "r") as file:
100101
for line in file:
101102
if not line.strip().startswith("#"):
@@ -201,7 +202,7 @@ def _fetch_sources(
201202
)
202203
else:
203204
# Fetch source file from the network
204-
req = requests.get(source.url)
205+
req = requests.get(source.url, timeout=5)
205206

206207
if req.status_code != 200:
207208
raise BuildError(
@@ -215,7 +216,7 @@ def _fetch_sources(
215216

216217
# Verify checksum
217218
file_sha = util.file_sha256(local_path)
218-
if source.checksum != "SKIP" and file_sha != source.checksum:
219+
if source.checksum not in ("SKIP", source.checksum):
219220
raise BuildError(
220221
f"Invalid checksum for source file {source.url}:\n"
221222
f" expected {source.checksum}\n"
@@ -381,6 +382,7 @@ def _postprocessing(self, recipe: Recipe, src_dir: str) -> None:
381382
script = []
382383
mount_src = "/src"
383384

385+
# pylint: disable-next=unnecessary-lambda-assignment
384386
docker_file_path = lambda file_path: shlex.quote(
385387
os.path.join(mount_src, os.path.relpath(file_path, src_dir))
386388
)

scripts/toltec/graphlib.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,7 @@ def _find_cycle(self) -> Optional[List[_T]]:
225225
seen = set()
226226
node2stacki: MutableMapping[_T, int] = {}
227227

228+
# pylint: disable-next=consider-using-dict-items
228229
for node in n2i:
229230
if node in seen:
230231
continue

scripts/toltec/ipk.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ def _targz_open(fileobj: IO[bytes], epoch: int) -> tarfile.TarFile:
2222
)
2323

2424
try:
25+
# pylint: disable-next=consider-using-with
2526
archive = tarfile.TarFile(
2627
mode="w",
2728
fileobj=gzipobj, # type:ignore

scripts/toltec/recipe.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ def from_file(path: str) -> "GenericRecipe":
4141
:returns: loaded recipe
4242
"""
4343
name = os.path.basename(path)
44+
# pylint: disable-next=unspecified-encoding
4445
with open(os.path.join(path, "package"), "r") as recipe:
4546
return GenericRecipe(name, path, recipe.read())
4647

scripts/toltec/repo.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@
2424
class PackageStatus(Enum):
2525
"""Possible existence statuses of a built package."""
2626

27+
# pylint: disable=invalid-name
28+
2729
# The package already existed in the local filesystem before the build
2830
AlreadyExists = auto()
2931

@@ -33,6 +35,8 @@ class PackageStatus(Enum):
3335
# The package is missing both from the local filesystem and the remote repo
3436
Missing = auto()
3537

38+
# pylint: enable=invalid-name
39+
3640

3741
GroupedPackages = Dict[PackageStatus, Dict[str, Dict[str, List[Package]]]]
3842

@@ -132,7 +136,7 @@ def fetch_package(
132136

133137
remote_path = os.path.join(remote, filename)
134138

135-
req = requests.get(remote_path)
139+
req = requests.get(remote_path, timeout=5)
136140

137141
if req.status_code != 200:
138142
return PackageStatus.Missing
@@ -208,6 +212,7 @@ def make_index(self) -> None:
208212
index_path = os.path.join(arch_dir, "Packages")
209213
index_gzip_path = os.path.join(arch_dir, "Packages.gz")
210214

215+
# pylint: disable-next=unspecified-encoding
211216
with open(index_path, "w") as index_file:
212217
with gzip.open(index_gzip_path, "wt") as index_gzip_file:
213218
for generic_recipe in self.generic_recipes.values():
@@ -258,5 +263,6 @@ def make_listing(self) -> None:
258263
listing_path = os.path.join(self.repo_dir, "index.html")
259264
template = templating.env.get_template("listing.html")
260265

266+
# pylint: disable-next=unspecified-encoding
261267
with open(listing_path, "w") as listing_file:
262268
listing_file.write(template.render(sections=sections))

scripts/toltec/version.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,16 @@
1616
class VersionComparator(Enum):
1717
"""Operators used to compare two version numbers."""
1818

19+
# pylint: disable=invalid-name
20+
1921
LowerThan = "<<"
2022
LowerThanOrEqual = "<="
2123
Equal = "="
2224
GreaterThanOrEqual = ">="
2325
GreaterThan = ">>"
2426

27+
# pylint: enable=invalid-name
28+
2529

2630
class InvalidVersionError(Exception):
2731
"""Raised when parsing of an invalid version is attempted."""
@@ -100,13 +104,17 @@ def __repr__(self) -> str:
100104
class DependencyKind(Enum):
101105
"""Kinds of dependencies that may be requested by a package."""
102106

107+
# pylint: disable=invalid-name
108+
103109
# Dependency installed in the system used to build a package
104110
# (e.g., a Debian package)
105111
Build = "build"
106112
# Dependency installed alongside a package
107113
# (e.g., another Entware or Toltec package)
108114
Host = "host"
109115

116+
# pylint: enable=invalid-name
117+
110118

111119
class InvalidDependencyError(Exception):
112120
"""Raised when parsing an invalid dependency specification."""

0 commit comments

Comments
 (0)