Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Require python 3.8 #378

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/python-app.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
build-baseline:
runs-on: ubuntu-latest
container:
image: python:3.6.0
image: python:3.8.0
steps:
- uses: actions/checkout@v3
- name: Install dependencies
Expand Down
32 changes: 16 additions & 16 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ pipeline {
stages {
stage('Test') {
parallel {
stage('Test Python 3.6.0') {
stage('Test Python 3.8.0') {
agent {
dockerfile {
dir 'src/tests'
filename 'python-360.Dockerfile'
filename 'python-380.Dockerfile'
}
}
steps {
Expand All @@ -20,17 +20,17 @@ pipeline {
dir("tempsrc") { sh 'ls -la' }
// Avoid git chowning .git/index to root which will cause the next build to fail
// Work around old docker version in jenkins that can't change cwd:
sh 'cd tempsrc && ../src/tests/run_jenkins_tests.sh 3.6.0'
sh 'cd tempsrc && ../src/tests/run_jenkins_tests.sh 3.8.0'
dir("tempsrc") { deleteDir() }
}
junit '3.6.0-results.xml'
junit '3.8.0-results.xml'
}
}
stage('Test Python 3.7.0') {
stage('Test Python 3.9.0') {
agent {
dockerfile {
dir 'src/tests'
filename 'python-370.Dockerfile'
filename 'python-390.Dockerfile'
}
}
steps {
Expand All @@ -39,17 +39,17 @@ pipeline {
dir("tempsrc") { sh 'ls -la' }
// Avoid git chowning .git/index to root which will cause the next build to fail
// Work around old docker version in jenkins that can't change cwd:
sh 'cd tempsrc && ../src/tests/run_jenkins_tests.sh 3.7.0'
sh 'cd tempsrc && ../src/tests/run_jenkins_tests.sh 3.9.0'
dir("tempsrc") { deleteDir() }
}
junit '3.7.0-results.xml'
junit '3.9.0-results.xml'
}
}
stage('Test Python 3.8.0') {
stage('Test Python 3.10.0') {
agent {
dockerfile {
dir 'src/tests'
filename 'python-380.Dockerfile'
filename 'python-3100.Dockerfile'
}
}
steps {
Expand All @@ -58,17 +58,17 @@ pipeline {
dir("tempsrc") { sh 'ls -la' }
// Avoid git chowning .git/index to root which will cause the next build to fail
// Work around old docker version in jenkins that can't change cwd:
sh 'cd tempsrc && ../src/tests/run_jenkins_tests.sh 3.8.0'
sh 'cd tempsrc && ../src/tests/run_jenkins_tests.sh 3.10.0'
dir("tempsrc") { deleteDir() }
}
junit '3.8.0-results.xml'
junit '3.10.0-results.xml'
}
}
stage('Test Python 3.9.0') {
stage('Test Python 3.11.0') {
agent {
dockerfile {
dir 'src/tests'
filename 'python-390.Dockerfile'
filename 'python-3110.Dockerfile'
}
}
steps {
Expand All @@ -77,10 +77,10 @@ pipeline {
dir("tempsrc") { sh 'ls -la' }
// Avoid git chowning .git/index to root which will cause the next build to fail
// Work around old docker version in jenkins that can't change cwd:
sh 'cd tempsrc && ../src/tests/run_jenkins_tests.sh 3.9.0'
sh 'cd tempsrc && ../src/tests/run_jenkins_tests.sh 3.11.0'
dir("tempsrc") { deleteDir() }
}
junit '3.9.0-results.xml'
junit '3.11.0-results.xml'
}
}
stage('Test Python RC') {
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# `cheribuild.py` - A script to build CHERI-related software (**requires Python 3.6+**)
# `cheribuild.py` - A script to build CHERI-related software (**requires Python 3.8+**)

This script automates all the steps required to build various [CHERI](http://www.chericpu.com)-related software.
For example `cheribuild.py [options] sdk-riscv64-purecap` will create an SDK that can be
Expand Down
2 changes: 1 addition & 1 deletion pycheribuild/config/chericonfig.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
import shutil
import typing
from enum import Enum
from functools import cached_property
from pathlib import Path
from typing import Optional

Expand All @@ -44,7 +45,6 @@
from ..utils import (
ConfigBase,
DoNotUseInIfStmt,
cached_property,
fatal_error,
have_working_internet_connection,
status_update,
Expand Down
3 changes: 2 additions & 1 deletion pycheribuild/config/compilation_targets.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
import sys
import typing
from abc import ABCMeta, abstractmethod
from functools import cached_property
from pathlib import Path
from typing import Optional

Expand All @@ -50,7 +51,7 @@
TargetInfo,
)
from ..projects.project import Project
from ..utils import cached_property, is_jenkins_build
from ..utils import is_jenkins_build

if typing.TYPE_CHECKING: # no-combine
from ..projects.cross.llvm import BuildLLVMMonoRepoBase # no-combine
Expand Down
3 changes: 2 additions & 1 deletion pycheribuild/config/target_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,14 @@
import typing
from abc import ABC, abstractmethod
from enum import Enum
from functools import cached_property
from pathlib import Path
from typing import ClassVar, Optional

from .chericonfig import AArch64FloatSimdOptions, CheriConfig, MipsFloatAbi
from ..filesystemutils import FileSystemUtils
from ..processutils import CompilerInfo, get_compiler_info
from ..utils import OSInfo, cached_property, fatal_error, final, status_update, warning_message
from ..utils import OSInfo, fatal_error, final, status_update, warning_message

__all__ = ["AbstractProject", "AArch64FloatSimdOptions", "AutoVarInit", "BasicCompilationTargets", # no-combine
"CPUArchitecture", "CrossCompileTarget", "CompilerType", "MipsFloatAbi", "TargetInfo", # no-combine
Expand Down
3 changes: 2 additions & 1 deletion pycheribuild/projects/cross/cheribsd.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
import typing
from collections import OrderedDict
from enum import Enum
from functools import cached_property
from pathlib import Path
from typing import ClassVar, Optional, Union

Expand All @@ -60,7 +61,7 @@
from ...config.target_info import AutoVarInit, CrossCompileTarget
from ...config.target_info import CompilerType as FreeBSDToolchainKind
from ...processutils import latest_system_clang_tool, print_command
from ...utils import OSInfo, ThreadJoiner, cached_property, classproperty, is_jenkins_build
from ...utils import OSInfo, ThreadJoiner, classproperty, is_jenkins_build


def _arch_suffixed_custom_install_dir(prefix: str) -> "ComputedDefaultValue[Path]":
Expand Down
3 changes: 2 additions & 1 deletion pycheribuild/projects/cross/llvm_test_suite.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
# SUCH DAMAGE.
#
import shutil
from functools import cached_property
from pathlib import Path

from .benchmark_mixin import BenchmarkMixin
Expand All @@ -42,7 +43,7 @@
from ..project import ReuseOtherProjectRepository
from ..simple_project import BoolConfigOption
from ...config.compilation_targets import FreeBSDTargetInfo
from ...utils import cached_property, classproperty, is_jenkins_build
from ...utils import classproperty, is_jenkins_build


class BuildLLVMTestSuiteBase(BenchmarkMixin, CrossCompileCMakeProject):
Expand Down
3 changes: 2 additions & 1 deletion pycheribuild/projects/disk_image.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
import sys
import tempfile
from enum import Enum
from functools import cached_property
from pathlib import Path
from typing import Optional

Expand All @@ -53,7 +54,7 @@
from .simple_project import SimpleProject
from ..config.compilation_targets import CompilationTargets
from ..mtree import MtreeFile
from ..utils import AnsiColour, cached_property, classproperty, coloured, include_local_file
from ..utils import AnsiColour, classproperty, coloured, include_local_file

# Notes:
# Mount the filesystem of a BSD VM: guestmount -a /foo/bar.qcow2 -m /dev/sda1:/:ufstype=ufs2:ufs --ro /mnt/foo
Expand Down
2 changes: 1 addition & 1 deletion pycheribuild/projects/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
import typing
from collections import OrderedDict
from enum import Enum
from functools import cached_property
from pathlib import Path
from typing import Callable, Optional, Sequence, Union

Expand Down Expand Up @@ -77,7 +78,6 @@
InstallInstructions,
OSInfo,
ThreadJoiner,
cached_property,
classproperty,
coloured,
remove_duplicates,
Expand Down
3 changes: 2 additions & 1 deletion pycheribuild/projects/run_fvp.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
import subprocess
import tempfile
import typing
from functools import cached_property
from pathlib import Path
from subprocess import CompletedProcess
from typing import Optional
Expand All @@ -43,7 +44,7 @@
from ..config.compilation_targets import CompilationTargets
from ..config.target_info import CrossCompileTarget
from ..processutils import extract_version, popen
from ..utils import AnsiColour, OSInfo, SocketAndPort, cached_property, classproperty, coloured, find_free_port
from ..utils import AnsiColour, OSInfo, SocketAndPort, classproperty, coloured, find_free_port


class InstallMorelloFVP(SimpleProject):
Expand Down
3 changes: 2 additions & 1 deletion pycheribuild/projects/testrig.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import time
import typing
from abc import ABC, abstractmethod
from functools import cached_property
from pathlib import Path
from typing import Optional

Expand All @@ -36,7 +37,7 @@
from .sail import BuildSailCheriRISCV
from .simple_project import BoolConfigOption, IntConfigOption, OptionalIntConfigOption, SimpleProject
from ..processutils import FakePopen, commandline_to_str, popen
from ..utils import cached_property, find_free_port
from ..utils import find_free_port


# This repository contains various implementations and QuickCheckVEngine
Expand Down
61 changes: 5 additions & 56 deletions pycheribuild/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@
import traceback
import typing
from pathlib import Path
from threading import RLock
from typing import Callable, Optional, Union

from .colour import AnsiColour, coloured
Expand All @@ -51,11 +50,11 @@
"SafeDict", "error_message", "ConfigBase", "final", "add_error_context", # no-combine
"default_make_jobs_count", "OSInfo", "is_jenkins_build", "get_global_config", # no-combine
"classproperty", "find_free_port", "have_working_internet_connection", "SocketAndPort", # no-combine
"is_case_sensitive_dir", "replace_one", "cached_property", "remove_prefix", # no-combine
"is_case_sensitive_dir", "replace_one", "remove_prefix", # no-combine
"remove_duplicates", "remove_tuple_duplicates"] # no-combine

if sys.version_info < (3, 6, 0):
sys.exit("This script requires at least Python 3.6.0")
if sys.version_info < (3, 8, 0): # noqa: UP036
sys.exit("This script requires at least Python 3.8.0")

Type_T = typing.TypeVar("Type_T")

Expand Down Expand Up @@ -115,56 +114,6 @@ def get_global_config() -> ConfigBase:
return GlobalConfig


if False and sys.version_info >= (3, 8, 0):
# TODO: once we depend on 3.8 use functools version instead
# from functools import cached_property
pass
else:
# Note: this is a copy of the python 3.8.6 implementation with f-strings removed for python 3.5.2 compat.
_NOT_FOUND: object = object()

# noinspection PyPep8Naming
class cached_property(typing.Generic[Type_T]): # noqa: N801
def __init__(self, func: "Callable[[typing.Any], Type_T]") -> None:
self.func = func
self.attrname = func.__name__ if sys.version_info < (3, 6) else None
self.__doc__ = func.__doc__
self.lock = RLock()

def __set_name__(self, _, name) -> None: # XXX: requires python 3.6
if self.attrname is None:
self.attrname = name
elif name != self.attrname:
raise TypeError("Cannot assign the same cached_property to two different names "
f"({self.attrname} and {name}).")

def __get__(self, instance, owner=None) -> Type_T:
if instance is None:
return self
if self.attrname is None:
raise TypeError("Cannot use cached_property instance without calling __set_name__ on it.")
try:
cache = instance.__dict__
except AttributeError: # not all objects have __dict__ (e.g. class defines slots)
msg = ("No '__dict__' attribute on {} instance to cache {} property.".format(type(instance).__name__,
self.attrname))
raise TypeError(msg) from None
val = cache.get(self.attrname, _NOT_FOUND)
if val is _NOT_FOUND:
with self.lock:
# check if another thread filled cache while we awaited lock
val = cache.get(self.attrname, _NOT_FOUND)
if val is _NOT_FOUND:
val = self.func(instance)
try:
cache[self.attrname] = val
except TypeError:
msg = ("The '__dict__' attribute on {} instance does not support item assignment for"
" caching {} property.".format(type(instance).__name__, self.attrname))
raise TypeError(msg) from None
return val


def is_jenkins_build() -> bool:
return os.getenv("_CHERIBUILD_JENKINS_BUILD") is not None

Expand Down Expand Up @@ -522,12 +471,12 @@ def replace_one(s: str, old, new) -> str:


def remove_duplicates(items: "typing.Iterable[Type_T]") -> "list[Type_T]":
# Convert to a dict to remove duplicates (retains order since python 3.6, which is our minimum)
# Convert to a dict to remove duplicates (retains order since python 3.6, which is older than our minimum)
return list(dict.fromkeys(items))


def remove_tuple_duplicates(items: "typing.Iterable[Type_T]") -> "tuple[Type_T, ...]":
# Convert to a dict to remove duplicates (retains order since python 3.6, which is our minimum)
# Convert to a dict to remove duplicates (retains order since python 3.6, which is older than our minimum)
return tuple(dict.fromkeys(items))


Expand Down
7 changes: 2 additions & 5 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
[tool.ruff]
select = ["E", "F", "I", "N", "W", "U", "COM", "RUF", "PLC", "PLE", "PLW"]
# Ensure suggested fixes are compatible with our minimum supported version
# XXX: Currently this is py36, but the minimum supported by ruff is py37.
target-version = "py37"
target-version = "py38"
ignore = [
"UP037", # Remove quotes from type annotation, not possible until we start using 3.7 as the minimum
"UP036", # 'Version block is outdated for minimum Python version' to be removed when we set the minimum to 3.8
"PLW2901", # `for` loop variable `value` overwritten by assignment target
"RUF012", # Mutable class attributes should be annotated with `typing.ClassVar` (cannot be fixed due to bug)
]
Expand All @@ -22,7 +19,7 @@ line-length = 120

[tool.black]
line-length = 120
target-version = ['py36']
target-version = ['py38']
# 'extend-exclude' excludes files or directories in addition to the defaults
# Currently reformatting pycheribuild/ results in lots of weird formatting, so
# let's restrict this to the other files for now.
Expand Down
3 changes: 1 addition & 2 deletions tests/python-360.Dockerfile → tests/python-3100.Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
FROM python:3.6.0

FROM python:3.10.0
LABEL maintainer="[email protected]"

COPY requirements.txt /tmp/requirements.txt
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM python:3.7.0
FROM python:3.11.0
LABEL maintainer="[email protected]"

COPY requirements.txt /tmp/requirements.txt
Expand Down
Loading