diff --git a/.clang-format b/.clang-format index f58c56af97..9767e004cf 100644 --- a/.clang-format +++ b/.clang-format @@ -1,7 +1,6 @@ # A clang-format style that approximates Python's PEP 7 # Useful for IDE integration BasedOnStyle: Google -AlwaysBreakAfterReturnType: All AllowShortIfStatementsOnASingleLine: false AlignAfterOpenBracket: Align BreakBeforeBraces: Stroustrup diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000000..e6c2225313 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,19 @@ +root = true + +[*] +# TODO: Activate and run in a different PR. Lots of files affected +# trim_trailing_whitespace = true +# insert_final_newline = true +# end_of_line = crlf +indent_style = space +indent_size = 4 +max_line_length = 120 # Same as .clang-format + +[*.py] +max_line_length = 88 # Same as Black + +[*.md] +trim_trailing_whitespace = false + +[*.{yaml,yml}] +indent_size = 2 diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index 45b77ff6e5..68382491fa 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -4,68 +4,68 @@ on: create: tags: # https://docs.github.com/en/actions/learn-github-actions/workflow-syntax-for-github-actions#filter-pattern-cheat-sheet - - b[0-9][0-9][0-9] - - publish-docs* + - b[0-9][0-9][0-9] + - publish-docs* push: branches: - - main + - main jobs: decompile: runs-on: windows-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v3 - - name: Set up Python - uses: actions/setup-python@v4 - with: - python-version: '3.9' + - name: Set up Python + uses: actions/setup-python@v4 + with: + python-version: '3.9' - - name: Install latest release - run: pip install --user --upgrade pywin32 + - name: Install latest release + run: pip install --user --upgrade pywin32 - - name: Set Python user site directory - run: python -c "import os,site;open(os.environ['GITHUB_ENV'], 'a').write(f'USER_DIR={site.USER_SITE}\n')" + - name: Set Python user site directory + run: python -c "import os,site;open(os.environ['GITHUB_ENV'], 'a').write(f'USER_DIR={site.USER_SITE}\n')" - - name: Decompile shipped help file - run: hh -decompile site ${env:USER_DIR}\PyWin32.chm + - name: Decompile shipped help file + run: hh -decompile site ${env:USER_DIR}\PyWin32.chm - - name: Rename root HTML file - run: mv site\PyWin32.HTML site\index.html + - name: Rename root HTML file + run: mv site\PyWin32.HTML site\index.html # Compress first to avoid slowly uploading thousands of individual files - - name: Create archive - run: python -m zipfile -c site.zip site + - name: Create archive + run: python -m zipfile -c site.zip site - - uses: actions/upload-artifact@v3 - with: - name: documentation - path: site.zip + - uses: actions/upload-artifact@v3 + with: + name: documentation + path: site.zip publish: runs-on: ubuntu-latest needs: - - decompile + - decompile # Only publish tags if: github.event_name == 'create' && github.event.ref_type == 'tag' steps: - - uses: actions/download-artifact@v3 - with: - name: documentation + - uses: actions/download-artifact@v3 + with: + name: documentation - - name: Unpack archive - run: python -m zipfile -e site.zip . + - name: Unpack archive + run: python -m zipfile -e site.zip . - - uses: peaceiris/actions-gh-pages@v3 - with: - github_token: ${{ secrets.GITHUB_TOKEN }} - publish_dir: site - commit_message: ${{ github.event.head_commit.message }} + - uses: peaceiris/actions-gh-pages@v3 + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + publish_dir: site + commit_message: ${{ github.event.head_commit.message }} # Write .nojekyll at the root, see: # https://help.github.com/en/github/working-with-github-pages/about-github-pages#static-site-generators - enable_jekyll: false + enable_jekyll: false # Only deploy if there were changes - allow_empty_commit: false + allow_empty_commit: false diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index a0583c3a9a..f861a1e9a6 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -4,7 +4,7 @@ on: push: pull_request: branches: - - main + - main concurrency: group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} @@ -21,40 +21,40 @@ jobs: architecture: ['x64', 'x86'] steps: - - uses: actions/checkout@v3 - - - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v4 - with: - python-version: ${{ matrix.python-version }} - architecture: ${{ matrix.architecture }} - - - name: Setup environment - run: | - python --version - pip --version - pip install --upgrade setuptools wheel - - - name: Build and install - run: | - python setup.py --skip-verstamp install --user - - - name: Run tests - # Run the tests directly from the source dir so support files (eg, .wav files etc) - # can be found - they aren't installed into the Python tree. - run: python pywin32_testall.py -v -skip-adodbapi - - - name: Build wheels - run: | - python setup.py bdist_wheel --skip-build - - - uses: actions/upload-artifact@v3 - if: ${{ always() }} - with: - name: artifacts - path: | - dist/*.whl - dist/*.exe + - uses: actions/checkout@v3 + + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v4 + with: + python-version: ${{ matrix.python-version }} + architecture: ${{ matrix.architecture }} + + - name: Setup environment + run: | + python --version + pip --version + pip install --upgrade setuptools wheel + + - name: Build and install + run: | + python setup.py --skip-verstamp install --user + + - name: Run tests + # Run the tests directly from the source dir so support files (eg, .wav files etc) + # can be found - they aren't installed into the Python tree. + run: python pywin32_testall.py -v -skip-adodbapi + + - name: Build wheels + run: | + python setup.py bdist_wheel --skip-build + + - uses: actions/upload-artifact@v3 + if: ${{ always() }} + with: + name: artifacts + path: | + dist/*.whl + dist/*.exe # We cannot build and test on ARM64, so we cross-compile. # Later, when available, we can add tests using this wheel on ARM64 VMs @@ -67,35 +67,35 @@ jobs: python-version: ['3.10', '3.11', '3.12-dev'] steps: - - uses: actions/checkout@v3 - - - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v4 - with: - python-version: ${{ matrix.python-version }} - architecture: 'x64' - - - name: Setup Environment - run: | - python --version - pip --version - pip install --upgrade setuptools wheel - - - name: Obtain ARM64 library files - run: | - python .github\workflows\download-arm64-libs.py .\arm64libs - - - name: Build wheels - run: python setup.py --skip-verstamp build_ext -L .\arm64libs --plat-name win-arm64 build --plat-name win-arm64 bdist_wheel --plat-name win-arm64 - - - uses: actions/upload-artifact@v3 - if: ${{ always() }} - with: - name: artifacts - path: | - dist/*.whl - - # This job can be run locally with the `format_all.bat` script + - uses: actions/checkout@v3 + + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v4 + with: + python-version: ${{ matrix.python-version }} + architecture: 'x64' + + - name: Setup Environment + run: | + python --version + pip --version + pip install --upgrade setuptools wheel + + - name: Obtain ARM64 library files + run: | + python .github\workflows\download-arm64-libs.py .\arm64libs + + - name: Build wheels + run: python setup.py --skip-verstamp build_ext -L .\arm64libs --plat-name win-arm64 build --plat-name win-arm64 bdist_wheel --plat-name win-arm64 + + - uses: actions/upload-artifact@v3 + if: ${{ always() }} + with: + name: artifacts + path: |- + dist/*.whl + + # This job can be run locally by running `pre-commit run` checkers: runs-on: windows-2019 steps: @@ -143,4 +143,3 @@ jobs: with: python-version: ${{ matrix.python-version }} annotate: errors - diff --git a/.isort.cfg b/.isort.cfg index b0ab5c40e5..706a5ecafb 100644 --- a/.isort.cfg +++ b/.isort.cfg @@ -1,5 +1,5 @@ [isort] -py_version=37 +py_version = 37 profile = black combine_as_imports = true skip = setup.py diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000000..09831791e9 --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,43 @@ +# You can run this locally with `pre-commit run [--all]` +repos: + - repo: https://github.com/pre-commit/pre-commit-hooks + rev: v4.5.0 + hooks: + # TODO: Activate and run in a different PR. Lots of files affected + # - id: trailing-whitespace + # args: [--markdown-linebreak-ext=md] + # - id: end-of-file-fixer + - id: mixed-line-ending + args: [--fix=crlf] + # Vendored + exclude: ^com/win32comext/mapi/src/mapi_headers/.*$ + - id: check-case-conflict + - repo: https://github.com/macisamuele/language-formatters-pre-commit-hooks + rev: v2.12.0 + hooks: + - id: pretty-format-toml + args: [--autofix, --trailing-commas] + - id: pretty-format-yaml + args: [--autofix, --indent, "2", --offset, "2", --preserve-quotes] + - id: pretty-format-ini + args: [--autofix] + - repo: https://github.com/hadialqattan/pycln + rev: v2.4.0 + hooks: + - id: pycln + args: [--config=pycln.toml] + verbose: true + - repo: https://github.com/pycqa/isort + rev: 5.13.2 + hooks: + - id: isort + name: isort (python) + verbose: true + - repo: https://github.com/psf/black-pre-commit-mirror + rev: 24.2.0 + hooks: + - id: black + verbose: true + +ci: + autoupdate_schedule: quarterly diff --git a/format_all.bat b/format_all.bat deleted file mode 100644 index 10b8aeddbd..0000000000 --- a/format_all.bat +++ /dev/null @@ -1,3 +0,0 @@ -pycln . --config=pycln.toml -isort . -black . diff --git a/win32/Demos/service/install/perf_install.ini b/win32/Demos/service/install/perf_install.ini index ac16750454..59c8b59adb 100644 --- a/win32/Demos/service/install/perf_install.ini +++ b/win32/Demos/service/install/perf_install.ini @@ -1,18 +1,18 @@ [info] -drivername=PipeServicePerf -symbolfile=perf_install.h +drivername = PipeServicePerf +symbolfile = perf_install.h [languages] -009=English +009 = English [text] -SERVICE_009_NAME=Python Demo Service -SERVICE_009_HELP=Shows performance statistics for the sample Python service -HEARTBEAT_009_NAME=Heartbeat pulse -HEARTBEAT_009_HELP=Regular counter to indicate the service is alive. Useful so system monitors can detect health even under low loads. -READ_009_NAME=Bytes read/sec -READ_009_HELP=Number of bytes read in total -WRITE_009_NAME=Bytes written/sec -WRITE_009_HELP=Number of bytes written in total -THREADS_009_NAME=Number of threads -THREADS_009_HELP=Number of threads currently servicing client connections +SERVICE_009_NAME = Python Demo Service +SERVICE_009_HELP = Shows performance statistics for the sample Python service +HEARTBEAT_009_NAME = Heartbeat pulse +HEARTBEAT_009_HELP = Regular counter to indicate the service is alive. Useful so system monitors can detect health even under low loads. +READ_009_NAME = Bytes read/sec +READ_009_HELP = Number of bytes read in total +WRITE_009_NAME = Bytes written/sec +WRITE_009_HELP = Number of bytes written in total +THREADS_009_NAME = Number of threads +THREADS_009_HELP = Number of threads currently servicing client connections