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

Add Python 3.12 support in CI (and remove 3.6/3.7/3.8) #41

Open
wants to merge 5 commits into
base: master
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
60 changes: 37 additions & 23 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,18 @@ on:

env:
winfsp_version: "1.12.22339"
python_default_version: "3.12"

jobs:

Quality:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
- uses: pre-commit/[email protected]
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # pin v4.1.7
- uses: actions/setup-python@39cd14951b08e74b54015e9e001cdefcf80e669f # pin v5.1.1
with:
python-version: ${{ env.python_default_version }}
- uses: pre-commit/action@2c7b3805fd2a0fd8c1884dcaebf91fc102a13ecd # pin v3.0.1

Wheels:
name: Wheel for ${{ matrix.python_version }}-${{ matrix.architecture }}
Expand All @@ -23,41 +26,43 @@ jobs:
strategy:
fail-fast: false
matrix:
python_version: [cp36, cp37, cp38, cp39, cp310, cp311]
python_version: [cp39, cp310, cp311, cp312]
architecture: [win32, win_amd64]

steps:
- name: Checkout repository
uses: actions/checkout@v2
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # pin v4.1.7

- name: Install winfsp
run: choco install winfsp -y --version=${{ env.winfsp_version }}

- name: Download winfsp-tests-x86
uses: engineerd/[email protected].6
uses: engineerd/configurator@dc6b312d89ab097f73f3ebbf507a69dd7399c5d0 # pin v0.0.10
with:
name: winfsp-tests-x86.exe
url: https://github.com/winfsp/winfsp/releases/download/v${{ env.winfsp_version }}/winfsp-tests-${{ env.winfsp_version }}.zip
pathInArchive: winfsp-tests-x86.exe

- name: Run cibuildwheel for ${{ matrix.python_version }}-${{ matrix.architecture }}
uses: pypa/[email protected]
timeout-minutes: 10
uses: pypa/cibuildwheel@bd033a44476646b606efccdd5eed92d5ea1d77ad # pin v2.20.0
env:
CIBW_BUILD: ${{ matrix.python_version }}-${{ matrix.architecture }}
CIBW_TEST_COMMAND: pytest --pyargs winfspy --doctest-modules --cov=winfspy --cov-report=xml:{project}/coverage.xml --cov-report=term -vvv --log-level INFO
CIBW_BEFORE_TEST: pip install -r requirements-test.txt

- name: Upload coverage report on codecov
uses: codecov/codecov-action@v1
uses: codecov/codecov-action@e28ff129e5465c2c0dcc6f003fc735cb6ae0c673 # pin v4.5.0
env:
PYTHON_VERSION: ${{ matrix.architecture }}
ARCHITECTURE: ${{ matrix.python_version }}
with:
env_vars: PYTHON_VERSION, ARCHITECTURE

- name: Upload wheel as an artifact
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@834a144ee995460fba8ed112a2fc961b36a5ec5a # pin v4.3.6
with:
name: artifact-wheel-${{ matrix.runs-on }}-${{ matrix.python_version }}-${{ matrix.architecture }}
path: ./wheelhouse/*.whl

Source:
Expand All @@ -66,22 +71,25 @@ jobs:

steps:
- name: Checkout repository
uses: actions/checkout@v2
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # pin v4.1.7

- name: Install winfsp
run: choco install winfsp -y --version=${{ env.winfsp_version }}

- name: Set up Python
uses: actions/setup-python@v2
uses: actions/setup-python@39cd14951b08e74b54015e9e001cdefcf80e669f # pin v5.1.1
with:
python-version: 3.8
python-version: ${{ env.python_default_version }}

- name: Build source distribution
run: python setup.py sdist
run: |
python -m pip install build
python -m build --sdist

- name: Upload wheel as an artifact
uses: actions/upload-artifact@v2
- name: Upload source distribution as an artifact
uses: actions/upload-artifact@834a144ee995460fba8ed112a2fc961b36a5ec5a # pin v4.3.6
with:
name: artifact-sdist
path: ./dist/*.tar.gz

Release:
Expand All @@ -91,13 +99,19 @@ jobs:

steps:
- name: Download wheels and source distribution
uses: actions/download-artifact@v2
uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # pin v4.1.8
with:
name: artifact
pattern: artifact-*
path: dist

- name: Publish on PyPI
uses: pypa/gh-action-pypi-publish@master
with:
user: __token__
password: ${{ secrets.pypi_password }}
merge-multiple: true

- name: SHOW ME WHAT YOU GOT
run: |
ls -lh
ls -lh dist

# - name: Publish on PyPI
# uses: pypa/gh-action-pypi-publish@ec4db0b4ddc65acdf4bff5fa45ac92d78b56bdf0 # pin v1.9.0
# with:
# user: __token__
# password: ${{ secrets.pypi_password }}
20 changes: 8 additions & 12 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,17 +1,13 @@
repos:
- repo: https://github.com/ambv/black
rev: 22.12.0
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.5.6 # Ruff version.
hooks:
- id: black
args:
- "--line-length=100"
language_version: python3
- repo: https://github.com/pycqa/flake8
rev: 3.7.9
hooks:
- id: flake8
exclude: .*\.t
- repo: https://github.com/pre-commit/pre-commit-hooks
# Run the linter.
- id: ruff
args: [ --fix ]
# Run the formatter.
- id: ruff-format
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v2.4.0 # Use the ref you want to point at
hooks:
- id: mixed-line-ending
Expand Down
3 changes: 3 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[build-system]
requires = ["setuptools>=61.0"]
build-backend = "setuptools.build_meta"
4 changes: 0 additions & 4 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
[flake8]
max-line-length = 100
ignore = E203,E266,E501,W503

[coverage:run]
source = winfspy

Expand Down
12 changes: 3 additions & 9 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,8 @@
#!/usr/bin/env python

import os
import sys

from setuptools import setup, find_packages


os.chdir(os.path.dirname(sys.argv[0]) or ".")


# Awesome hack to load `__version__`
__version__ = None
exec(open("src/winfspy/_version.py", encoding="utf-8").read())
Expand All @@ -30,13 +24,13 @@
author="Emmanuel Leblond",
author_email="[email protected]",
classifiers=[
"Development Status :: 4 - Beta",
"Development Status :: 5 - Production/Stable",
"Operating System :: Microsoft :: Windows",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"License :: OSI Approved :: BSD License",
],
package_dir={"": "src"},
Expand Down
28 changes: 22 additions & 6 deletions src/winfspy/file_system.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,13 @@
import time
import errno

from .plumbing import ffi, lib, cook_ntstatus, nt_success, file_system_interface_trampoline_factory
from .plumbing import (
ffi,
lib,
cook_ntstatus,
nt_success,
file_system_interface_trampoline_factory,
)
from .plumbing import WinFSPyError, FileSystemAlreadyStarted, FileSystemNotStarted
from .operations import BaseFileSystemOperations

Expand Down Expand Up @@ -110,7 +116,9 @@ class FileSystem:
def __init__(self, mountpoint, operations, debug=False, **volume_params):
self.started = False
if not isinstance(operations, BaseFileSystemOperations):
raise ValueError(f"`operations` must be a `BaseFileSystemOperations` instance.")
raise ValueError(
"`operations` must be a `BaseFileSystemOperations` instance."
)

self.debug = debug
self.volume_params = volume_params
Expand Down Expand Up @@ -160,7 +168,9 @@ def _create_file_system(self):
self._file_system_ptr,
)
if not nt_success(result):
raise WinFSPyError(f"Cannot create file system: {cook_ntstatus(result).name}")
raise WinFSPyError(
f"Cannot create file system: {cook_ntstatus(result).name}"
)

# Avoid GC on the handle
self._operations_handle = ffi.new_handle(self.operations)
Expand All @@ -174,12 +184,18 @@ def start(self):
raise FileSystemAlreadyStarted()
self.started = True

result = lib.FspFileSystemSetMountPoint(self._file_system_ptr[0], self.mountpoint)
result = lib.FspFileSystemSetMountPoint(
self._file_system_ptr[0], self.mountpoint
)
if not nt_success(result):
raise WinFSPyError(f"Cannot mount file system: {cook_ntstatus(result).name}")
raise WinFSPyError(
f"Cannot mount file system: {cook_ntstatus(result).name}"
)
result = lib.FspFileSystemStartDispatcher(self._file_system_ptr[0], 0)
if not nt_success(result):
raise WinFSPyError(f"Cannot start file system dispatcher: {cook_ntstatus(result).name}")
raise WinFSPyError(
f"Cannot start file system dispatcher: {cook_ntstatus(result).name}"
)
# Since winfsp 1.12.22301 (2022-2), the file system might not be reachable as soon as the dispatcher is started.
# Instead a request might fail with the following error:
# [WinError 995] The I/O operation has been aborted because of either a thread exit or an application request
Expand Down
12 changes: 8 additions & 4 deletions src/winfspy/memfs.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,6 @@ def __repr__(self):


class FileObj(BaseFileObj):

allocation_unit = 4096

def __init__(self, path, attributes, security_descriptor, allocation_size=0):
Expand Down Expand Up @@ -185,7 +184,9 @@ def __init__(self, volume_label, read_only=False):
self._root_obj = FolderObj(
self._root_path,
FILE_ATTRIBUTE.FILE_ATTRIBUTE_DIRECTORY,
SecurityDescriptor.from_string("O:BAG:BAD:P(A;;FA;;;SY)(A;;FA;;;BA)(A;;FA;;;WD)"),
SecurityDescriptor.from_string(
"O:BAG:BAD:P(A;;FA;;;SY)(A;;FA;;;BA)(A;;FA;;;WD)"
),
)
self._entries = {self._root_path: self._root_obj}
self._thread_lock = threading.Lock()
Expand Down Expand Up @@ -488,7 +489,6 @@ def cleanup(self, file_context, file_name, flags) -> None:

# Delete
if flags & FspCleanupDelete:

# Check for non-empty direcory
if any(key.parent == file_obj.path for key in self._entries):
return
Expand Down Expand Up @@ -521,7 +521,11 @@ def cleanup(self, file_context, file_name, flags) -> None:

@operation
def overwrite(
self, file_context, file_attributes, replace_file_attributes: bool, allocation_size: int
self,
file_context,
file_attributes,
replace_file_attributes: bool,
allocation_size: int,
) -> None:
if self.read_only:
raise NTStatusMediaWriteProtected()
Expand Down
Loading
Loading