general,ci: fix python 3.10 issues, add to CI (#242)
This commit is contained in:
parent
64a4782f0e
commit
76a497f2bb
2 changed files with 22 additions and 19 deletions
11
.github/workflows/main.yml
vendored
11
.github/workflows/main.yml
vendored
|
@ -17,17 +17,18 @@ jobs:
|
||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
platform: [ubuntu-latest, macos-latest, windows-latest]
|
platform: [ubuntu-latest, macos-latest, windows-latest]
|
||||||
python-version: ['3.7', '3.8', '3.9']
|
python-version: ['3.7', '3.8', '3.9', '3.10']
|
||||||
exclude: [
|
exclude: [
|
||||||
# windows runners are pretty scarce, so let's only run one of them..
|
# windows runners are pretty scarce, so let's only run one of them..
|
||||||
{platform: windows-latest, python-version: '3.7'},
|
{platform: windows-latest, python-version: '3.7' },
|
||||||
{platform: windows-latest, python-version: '3.9'},
|
{platform: windows-latest, python-version: '3.9' },
|
||||||
|
{platform: windows-latest, python-version: '3.10'},
|
||||||
]
|
]
|
||||||
|
|
||||||
runs-on: ${{ matrix.platform }}
|
runs-on: ${{ matrix.platform }}
|
||||||
|
|
||||||
# TODO let's at least start running windows for now, will fix later
|
# useful for 'optional' pipelines
|
||||||
continue-on-error: ${{ matrix.platform == 'windows-latest' }}
|
# continue-on-error: ${{ matrix.platform == 'windows-latest' }}
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
# ugh https://github.com/actions/toolkit/blob/main/docs/commands.md#path-manipulation
|
# ugh https://github.com/actions/toolkit/blob/main/docs/commands.md#path-manipulation
|
||||||
|
|
|
@ -124,20 +124,20 @@ def kexists(path: PathIsh, subpath: str) -> bool:
|
||||||
import zipfile
|
import zipfile
|
||||||
if sys.version_info[:2] >= (3, 8):
|
if sys.version_info[:2] >= (3, 8):
|
||||||
# meh... zipfile.Path is not available on 3.7
|
# meh... zipfile.Path is not available on 3.7
|
||||||
ZipPathBase = zipfile.Path
|
zipfile_Path = zipfile.Path
|
||||||
else:
|
else:
|
||||||
if typing.TYPE_CHECKING:
|
if typing.TYPE_CHECKING:
|
||||||
ZipPathBase = Any
|
zipfile_Path = Any
|
||||||
else:
|
else:
|
||||||
ZipPathBase = object
|
zipfile_Path = object
|
||||||
|
|
||||||
|
|
||||||
class ZipPath(ZipPathBase):
|
class ZipPath(zipfile_Path):
|
||||||
# NOTE: is_dir/is_file might not behave as expected, the base class checks it only based on the slash in path
|
# NOTE: is_dir/is_file might not behave as expected, the base class checks it only based on the slash in path
|
||||||
|
|
||||||
# seems that at/root are not exposed in the docs, so might be an implementation detail
|
# seems that root/at are not exposed in the docs, so might be an implementation detail
|
||||||
at: str
|
|
||||||
root: zipfile.ZipFile
|
root: zipfile.ZipFile
|
||||||
|
at: str
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def filepath(self) -> Path:
|
def filepath(self) -> Path:
|
||||||
|
@ -156,7 +156,11 @@ class ZipPath(ZipPathBase):
|
||||||
if self.at == '':
|
if self.at == '':
|
||||||
# special case, the base class returns False in this case for some reason
|
# special case, the base class returns False in this case for some reason
|
||||||
return self.filepath.exists()
|
return self.filepath.exists()
|
||||||
return super().exists()
|
return super().exists() or self._as_dir().exists()
|
||||||
|
|
||||||
|
def _as_dir(self) -> zipfile_Path:
|
||||||
|
# note: seems that zip always uses forward slash, regardless OS?
|
||||||
|
return zipfile_Path(self.root, self.at + '/')
|
||||||
|
|
||||||
def rglob(self, glob: str) -> Sequence[ZipPath]:
|
def rglob(self, glob: str) -> Sequence[ZipPath]:
|
||||||
# note: not 100% sure about the correctness, but seem fine?
|
# note: not 100% sure about the correctness, but seem fine?
|
||||||
|
@ -166,7 +170,7 @@ class ZipPath(ZipPathBase):
|
||||||
return [ZipPath(self.root, p) for p in rpaths]
|
return [ZipPath(self.root, p) for p in rpaths]
|
||||||
|
|
||||||
def relative_to(self, other: ZipPath) -> Path:
|
def relative_to(self, other: ZipPath) -> Path:
|
||||||
assert self.root == other.root, (self.root, other.root)
|
assert self.filepath == other.filepath, (self.filepath, other.filepath)
|
||||||
return self.subpath.relative_to(other.subpath)
|
return self.subpath.relative_to(other.subpath)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
@ -176,11 +180,11 @@ class ZipPath(ZipPathBase):
|
||||||
|
|
||||||
def __truediv__(self, key) -> ZipPath:
|
def __truediv__(self, key) -> ZipPath:
|
||||||
# need to implement it so the return type is not zipfile.Path
|
# need to implement it so the return type is not zipfile.Path
|
||||||
s = super().__truediv__(key)
|
tmp = zipfile_Path(self.root) / self.at / key
|
||||||
return ZipPath(s.root, s.at) # type: ignore[attr-defined]
|
return ZipPath(self.root, tmp.at) # type: ignore[attr-defined]
|
||||||
|
|
||||||
def iterdir(self) -> Iterator[ZipPath]:
|
def iterdir(self) -> Iterator[ZipPath]:
|
||||||
for s in super().iterdir():
|
for s in self._as_dir().iterdir():
|
||||||
yield ZipPath(s.root, s.at) # type: ignore[attr-defined]
|
yield ZipPath(s.root, s.at) # type: ignore[attr-defined]
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
@ -203,9 +207,7 @@ class ZipPath(ZipPathBase):
|
||||||
def stat(self) -> os.stat_result:
|
def stat(self) -> os.stat_result:
|
||||||
# NOTE: zip datetimes have no notion of time zone, usually they just keep local time?
|
# NOTE: zip datetimes have no notion of time zone, usually they just keep local time?
|
||||||
# see https://en.wikipedia.org/wiki/ZIP_(file_format)#Structure
|
# see https://en.wikipedia.org/wiki/ZIP_(file_format)#Structure
|
||||||
# note: seems that zip always uses forward slash, regardless OS?
|
dt = datetime(*self.root.getinfo(self.at).date_time)
|
||||||
zip_subpath = '/'.join(self.subpath.parts)
|
|
||||||
dt = datetime(*self.root.getinfo(zip_subpath).date_time)
|
|
||||||
ts = int(dt.timestamp())
|
ts = int(dt.timestamp())
|
||||||
params = dict(
|
params = dict(
|
||||||
st_mode=0,
|
st_mode=0,
|
||||||
|
|
Loading…
Add table
Reference in a new issue