Skip to content

Commit

Permalink
Bump dependencies and Python minimum (#175)
Browse files Browse the repository at this point in the history
Bump the Python minimum to Python 3.8 as Python 3.7 is nearing end of
life and 3.8 as a baseline removes a few compatibility hacks. Also bumps
some of the dev dependencies to the latest versions available.
  • Loading branch information
jborean93 authored May 31, 2023
1 parent bfea572 commit 17fe1e2
Show file tree
Hide file tree
Showing 18 changed files with 106 additions and 203 deletions.
14 changes: 4 additions & 10 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,6 @@ on:
types:
- published

schedule:
- cron: 0 9 * * *

jobs:
build:
name: build library
Expand Down Expand Up @@ -54,7 +51,6 @@ jobs:
- ubuntu-latest
- windows-latest
python-version:
- 3.7
- 3.8
- 3.9
- '3.10'
Expand All @@ -66,8 +62,6 @@ jobs:
exclude:
- os: ubuntu-latest
python-arch: x86
- os: windows-latest # lxml has no wheel for win-cp311
python-version: '3.11'

steps:
- uses: actions/checkout@v3
Expand Down Expand Up @@ -141,8 +135,11 @@ jobs:
name: publish
needs:
- test

runs-on: ubuntu-latest
permissions:
# IMPORTANT: this permission is mandatory for trusted publishing
id-token: write

steps:
- uses: actions/download-artifact@v3
with:
Expand All @@ -152,6 +149,3 @@ jobs:
- name: Publish
if: startsWith(github.ref, 'refs/tags/v')
uses: pypa/gh-action-pypi-publish@release/v1
with:
user: __token__
password: ${{ secrets.PYPI_API_TOKEN }}
6 changes: 3 additions & 3 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
repos:
- repo: https://github.com/psf/black
rev: 23.1.0
rev: 23.3.0
hooks:
- id: black

- repo: https://github.com/PyCQA/isort
rev: 5.11.5
rev: 5.12.0
hooks:
- id: isort

- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.0.1
rev: v1.3.0
hooks:
- id: mypy
additional_dependencies:
Expand Down
5 changes: 3 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@

## 1.0.0b2 - TBD

* Bump minimum Python version to 3.8
* Use setuptools with `pyproject.toml` as the project definition
* Ensure the outgoing send buffer won't get too small to fit extra fragments
* Fix up certificate authentication over TLS 1.3 connections - Python 3.8 only
* Bump minimum Python version to 3.7
* Fix up certificate authentication over TLS 1.3 connections
* Cache Kerberos credentials to speed up re-authentication when starting a new WSMan connection on another thread
* Fix deadlock when receiving certain WSManFault errors outside of a close operation
* Fix invalid selector error when connecting to Exchange Online by re-using proper cookies
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ To support Kerberos the `kerberos` extras package must be installed.

See `How to Install` for more details

* CPython 3.7+
* CPython 3.8+
* [cryptography](https://github.com/pyca/cryptography)
* [psrpcore](https://github.com/jborean93/psrpcore)
* [pyspnego](https://github.com/jborean93/pyspnego)
Expand Down
11 changes: 6 additions & 5 deletions build_helpers/lib.sh
Original file line number Diff line number Diff line change
Expand Up @@ -91,13 +91,14 @@ lib::setup::python_requirements() {
DIST_LINK_PATH="${PWD}/dist"
fi

python -m pip install pypsrp \
--no-index \

# Getting the version is important so that pip prioritises our local dist
python -m pip install build
PSRP_VERSION="$( python -c "import build.util; print(build.util.project_wheel_metadata('.').get('Version'))" )"

python -m pip install pypsrp[credssp,kerberos,named_pipe,ssh]=="${PSRP_VERSION}" \
--find-links "file://${DIST_LINK_PATH}" \
--no-build-isolation \
--no-dependencies \
--verbose
python -m pip install pypsrp[credssp,kerberos,named_pipe,socks,ssh]

echo "Installing dev dependencies"
python -m pip install -r requirements-dev.txt
Expand Down
66 changes: 61 additions & 5 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,67 @@
[build-system]
requires = ["setuptools>=42.0.0"]
requires = [
"setuptools >= 61.0.0", # Support for setuptools config in pyproject.toml
]
build-backend = "setuptools.build_meta"

[project]
name = "pypsrp"
version = "1.0.0b2"
description = "PowerShell Remoting Protocol and WinRM for Python"
readme = "README.md"
requires-python = ">=3.8"
license = {file = "LICENSE"}
authors = [
{ name = "Jordan Borean", email = "jborean93@gmail.com" }
]
keywords = ["winrm", "psrp", "winrs", "windows", "powershell"]
classifiers = [
"Development Status :: 4 - Beta",
"License :: OSI Approved :: MIT License",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11"
]
dependencies = [
"cryptography",
"httpcore < 1.0.0",
"httpx < 1.0.0",
"psrpcore >= 0.1.2",
"pyspnego >= 0.7.0, < 1.0.0",
"requests >= 2.9.1" # Old pypsrp namespace
]

[project.urls]
homepage = "https://github.com/jborean93/pypsrp"

[project.optional-dependencies]
credssp = [
"requests-credssp >= 2.0.0"
]
kerberos = [
"pyspnego[kerberos]"
]
named_pipe = [
"psutil"
]
ssh = [
"asyncssh"
]

[tool.setuptools]
include-package-data = true

[tool.setuptools.packages.find]
where = ["src"]

[tool.setuptools.package-data]
psrp = ["py.typed"]
"psrp._pwsh" = ["*.ps1"]
pypsrp = ["py.typed"]
"pypsrp.pwsh_scripts" = ["*.ps1"]

[tool.black]
line-length = 120
include = '\.pyi?$'
Expand Down Expand Up @@ -43,10 +103,6 @@ check_untyped_defs = true
warn_return_any = true
warn_unreachable = true

[[tool.mypy.overrides]]
module = "psrp._compat"
warn_unused_ignores = false

[[tool.mypy.overrides]]
module = "psrp._connection.named_pipe"
warn_unused_ignores = false
Expand Down
8 changes: 3 additions & 5 deletions requirements-dev.txt
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
asyncssh
black == 23.1.0
black == 23.3.0
build
gssapi ; sys_platform != 'win32'
krb5 ; sys_platform != 'win32'
httpx[socks]
isort == 5.11.5
mypy == 1.0.1
isort == 5.12.0
mypy == 1.3.0
pre-commit
psutil
pytest
Expand All @@ -16,9 +16,7 @@ PyYAML
requests-credssp
tox
types-cryptography
types-dataclasses ; python_version < "3.7"
types-requests
types-psutil
types-PyYAML
typing_extensions ; python_version < "3.8"
xmldiff
61 changes: 0 additions & 61 deletions setup.cfg

This file was deleted.

5 changes: 2 additions & 3 deletions src/psrp/_async.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@
WarningRecord,
)

from ._compat import SupportsIndex, iscoroutinefunction
from ._connection.connection import AsyncConnection, ConnectionInfo
from ._exceptions import (
PipelineFailed,
Expand Down Expand Up @@ -156,7 +155,7 @@ async def complete(self) -> None:

def insert(
self,
index: SupportsIndex,
index: t.SupportsIndex,
value: T,
) -> None:
if self.completed:
Expand Down Expand Up @@ -848,7 +847,7 @@ async def _invoke_host_call(

error_record = None
try:
if iscoroutinefunction(func):
if asyncio.iscoroutinefunction(func):
return_value = await func()
else:
return_value = func()
Expand Down
31 changes: 0 additions & 31 deletions src/psrp/_compat.py

This file was deleted.

14 changes: 1 addition & 13 deletions src/psrp/_connection/named_pipe.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,15 +92,6 @@ class NamedPipeInfo(ConnectionInfo):
an integer for the name it will be configured to connect to the PowerShell
host pipe of that process rather than an explicit pipe/socket name.
When using Python 3.6 or 3.7 on Windows the ``ProactorEventLoop`` event
loop must be used to create an asyncio pipe connection. This can be done by
setting.
Example:
To set the ``ProactorEventLoop`` event loop on Windows do::
asycnio.set_event_loop_policy(asyncio.ProactorEventLoop())
Args:
name: The pipe name or PowerShell process id to connect to.
"""
Expand Down Expand Up @@ -188,7 +179,4 @@ async def write(
async def stop(self) -> None:
log.debug("Stopping Named Pipe connection")
self._writer.close()
# FUTURE: Call directly once 3.7 is the minimum.
wait_closed = getattr(self._writer, "wait_closed", None)
if wait_closed: # pragma: no cover
await wait_closed()
await self._writer.wait_closed()
9 changes: 0 additions & 9 deletions src/psrp/_connection/process.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,6 @@ class ProcessInfo(ConnectionInfo):
`-Version` entry is cruical to not running in version 2.0 compatibility
mode.
When using Python 3.6 or 3.7 on Windows the ``ProactorEventLoop`` event
loop must be used to create an asyncio subprocess. This can be done by
settings.
Example:
To set the ``ProactorEventLoop`` event loop on Windows do::
asycnio.set_event_loop_policy(asyncio.ProactorEventLoop())
Args:
executable: The executable to run, defaults to `pwsh`.
arguments: A list of arguments to run, when the executable is `pwsh`
Expand Down
Loading

0 comments on commit 17fe1e2

Please sign in to comment.