Skip to content

Commit

Permalink
Merge branch 'release/4.0.0rc2'
Browse files Browse the repository at this point in the history
* release/4.0.0rc2:
  Preparing release 4.0.0rc2
  Bump version: 4.0.0rc1 → 4.0.0rc2
  Enhance event loop handling and improve test configuration. Refactor Makefile and update dependencies
  Update Windows event loop policy to use winloop.EventLoopPolicy for improved compatibility
  Refactor Makefile and setup for improved build process; update requirements and add event loop handling for Windows compatibility
  Set Windows-specific event loop for compatibility in web server startup
  Refactor CLI and event loop handling for improved readability and Windows compatibility
  Refactor ruff configuration and improve event loop handling on Windows
  Fix typo in coverage command by changing 'py.test' to 'pytest'
  Update Python version and linting tool in CI workflow
  • Loading branch information
javipalanca committed Dec 5, 2024
2 parents 075aafc + 40bb387 commit aa2d9be
Show file tree
Hide file tree
Showing 20 changed files with 173 additions and 85 deletions.
48 changes: 38 additions & 10 deletions .github/workflows/python-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@ jobs:
- uses: actions/checkout@v2
- uses: actions/setup-python@v1
with:
python-version: "3.10"
python-version: "3.12"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install tox virtualenv flake8
pip install tox virtualenv ruff
- name: Lint
run: "tox -e flake8"
run: "tox -e lint"

test:
runs-on: ${{ matrix.os }}
Expand All @@ -37,14 +37,20 @@ jobs:
- "ubuntu-py38"
- "ubuntu-py39"
- "ubuntu-py310"
- "ubuntu-py311"
- "ubuntu-py312"

- "macos-py38"
- "macos-py39"
- "macos-py310"
- "macos-py311"
- "macos-py312"

- "windows-py38"
- "windows-py39"
- "windows-py310"
- "windows-py311"
- "windows-py312"

include:
- name: "ubuntu-py38"
Expand All @@ -59,6 +65,14 @@ jobs:
python: "3.10"
os: ubuntu-latest
tox_env: "py310"
- name: "ubuntu-py311"
python: "3.11"
os: ubuntu-latest
tox_env: "py311"
- name: "ubuntu-py312"
python: "3.12"
os: ubuntu-latest
tox_env: "py312"

- name: "macos-py38"
python: "3.8"
Expand All @@ -72,6 +86,14 @@ jobs:
python: "3.10"
os: macos-latest
tox_env: "py310"
- name: "macos-py311"
python: "3.11"
os: macos-latest
tox_env: "py311"
- name: "macos-py312"
python: "3.12"
os: macos-latest
tox_env: "py312"

- name: "windows-py38"
python: "3.8"
Expand All @@ -85,6 +107,14 @@ jobs:
python: "3.10"
os: windows-latest
tox_env: "py310"
- name: "windows-py311"
python: "3.11"
os: windows-latest
tox_env: "py311"
- name: "windows-py312"
python: "3.12"
os: windows-latest
tox_env: "py312"

steps:
- uses: actions/checkout@v2
Expand All @@ -97,12 +127,10 @@ jobs:
python -m pip install --upgrade pip
python -m pip install -r requirements_dev.txt
python -m pip install -r requirements.txt
- name: Lint with flake8
- name: Lint with ruff
run: |
# stop the build if there are Python syntax errors or undefined names
flake8 spade --count --ignore=E501 --show-source --statistics
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
flake8 spade --count --exit-zero --max-complexity=10 --ignore=E501 --statistics
# ruff lint
ruff check spade
- name: Test with pytest
run: |
pytest
Expand All @@ -112,7 +140,7 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: ["3.8", "3.9", "3.10"]
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
Expand All @@ -127,7 +155,7 @@ jobs:
- name: Run coverage
run: |
coverage erase
coverage run --source=spade -m py.test
coverage run --source=spade -m pytest
- name: Coveralls
uses: javipalanca/coveralls-python-action@develop
with:
Expand Down
8 changes: 5 additions & 3 deletions HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,15 @@ History
=======


4.0.0rc (2024-11-28)
4.0.0 (2024-12-05)
--------------------

* Added XMPP server as cli.
* Added custom XMPP server as cli.
* Migrated to pyproject.
* Migrated to ruff.
* Migrated linter to ruff.
* Improved presence management API.
* Agents can now select the XMPP port.
* Use uvloop or winloop if available.

3.3.3 (2024-09-05)
------------------
Expand Down
28 changes: 15 additions & 13 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# Variables
PYTHON = python
BUILD_DIR = dist

.PHONY: clean clean-test clean-pyc clean-build docs help
.DEFAULT_GOAL := help
define BROWSER_PYSCRIPT
Expand Down Expand Up @@ -34,21 +38,21 @@ clean-build: ## remove build artifacts
rm -fr dist/
rm -fr .eggs/
find . -name '*.egg-info' -exec rm -fr {} +
find . -name '*.egg' -exec rm -f {} +
find . -name '*.egg' -exec rm -fr {} +

clean-pyc: ## remove Python file artifacts
find . -name '*.pyc' -exec rm -f {} +
find . -name '*.pyo' -exec rm -f {} +
find . -name '*~' -exec rm -f {} +
find . -name '__pycache__' -exec rm -fr {} +
find . -name '*.pyc' -not -path "./.tox/*" -exec rm -f {} +
find . -name '*.pyo' -not -path "./.tox/*" -exec rm -f {} +
find . -name '*~' -not -path "./.tox/*" -exec rm -f {} +
find . -name '__pycache__' -not -path "./.tox/*" -exec rm -fr {} +

clean-test: ## remove test and coverage artifacts
rm -fr .tox/
rm -f .coverage
rm -fr htmlcov/

lint: ## check style with flake8
flake8 spade tests
ruff check spade tests

test: ## run tests quickly with the default Python
pytest
Expand All @@ -74,14 +78,12 @@ servedocs: docs ## compile the docs watching for changes
watchmedo shell-command -p '*.rst' -c '$(MAKE) -C docs html' -R -D .

release: clean ## package and upload a release
python setup.py sdist
python setup.py bdist_wheel
twine upload dist/*
$(PYTHON) -m build
twine upload $(BUILD_DIR)/*

dist: clean ## builds source and wheel package
python setup.py sdist
python setup.py bdist_wheel
ls -l dist
$(PYTHON) -m build
ls -l $(BUILD_DIR)

install: clean ## install the package to the active Python's site-packages
python setup.py install
$(PYTHON) -m pip install .
12 changes: 8 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
[build-system]
requires = ["setuptools>=61.0"]
requires = [
"setuptools>=61.0",
"wheel",
"build"
]
build-backend = "setuptools.build_meta"

[project]
Expand Down Expand Up @@ -44,8 +48,8 @@ version = {attr = "spade.__version__"}
dependencies = {file = "requirements.txt"}

[tool.ruff]
select = ["E", "F"]
ignore = ["E501"]
lint.select = ["E", "F"]
lint.ignore = ["E501"]
line-length = 88
target-version = "py38"

Expand All @@ -54,5 +58,5 @@ quote-style = "double"
indent-style = "space"
skip-magic-trailing-comma = false

[tool.ruff.isort]
[tool.ruff.lint.isort]
known-first-party = ["spade"]
2 changes: 2 additions & 0 deletions pytest.ini
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
[pytest]
testpaths = tests/
asyncio_default_fixture_loop_scope = function
asyncio_mode = auto
6 changes: 4 additions & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
multidict==5.2.0
pyasn1-modules==0.2.8
pyasn1==0.4.8
#pyasn1-modules==0.4.1
#pyasn1==0.6.1
slixmpp==1.8.5
aiohttp==3.10.5
aiohttp_jinja2==1.6
Expand All @@ -10,6 +10,8 @@ timeago==1.0.16
singletonify==0.2.4
pytz==2022.1
pyjabber==0.1.6
uvloop>=0.21.0; platform_system != "Windows"
winloop>=0.1.7; platform_system == "Windows"


#cryptography==2.8 #3.2
13 changes: 7 additions & 6 deletions requirements_dev.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
build==1.2.2.post1
bump2version==1.0.1
wheel==0.37.1
watchdog==2.1.9
Expand All @@ -7,18 +8,18 @@ coverage==7.2.1
Sphinx==5.1.0
twine==3.8.0 #4.0.1
pyyaml==6.0.2
pytest==8.3.2 #7.0.1 #7.1.2
pytest==8.3.4 #7.0.1 #7.1.2
pytest-runner==5.3.2 #6.0.0
pytest-asyncio==0.16.0 #0.19.0
pytest-asyncio==0.24.0 #0.19.0
pytest-cov==3.0.0
pytest-mock==3.6.1 #3.8.2
#pluggy==0.13.1 #<0.7,>=0.5
python-coveralls==2.9.3
requests==2.27.1 #2.28.1
parsel==1.6.0
requests==2.32.3
parsel==1.9.1
sphinx_rtd_theme==1.0.0
testfixtures==7.0.0
pytest-aiohttp>=0.3.0 #1.0.4
pytest-aiohttp>=1.0.5
factory-boy==3.2.1
click==8.0.3
click==8.1.7
#docutils==0.12
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[bumpversion]
current_version = 4.0.0rc1
current_version = 4.0.0rc2
commit = True
tag = False
parse = (?P<major>\d+)\.(?P<minor>\d+)\.(?P<patch>\d+)((?P<release>[a-z]+)(?P<rc>\d+))?
Expand Down
8 changes: 7 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# -*- coding: utf-8 -*-

"""The setup script."""
import sys
from setuptools import setup, find_packages


Expand All @@ -19,6 +20,11 @@ def parse_requirements(filename):

requirements = parse_requirements("requirements.txt")

if sys.platform.startswith("win32"):
requirements.append("winloop>=0.1.7")
else:
requirements.append("uvloop>=0.21.0")

setup_requirements = [
'pytest-runner',
# put setup requirements (distutils extensions, etc.) here
Expand All @@ -28,7 +34,7 @@ def parse_requirements(filename):

setup(
name='spade',
version='4.0.0rc1',
version='4.0.0rc2',
description="Smart Python Agent Development Environment",
long_description=readme + '\n\n' + history,
author="Javi Palanca",
Expand Down
2 changes: 1 addition & 1 deletion spade/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

__author__ = """Javi Palanca"""
__email__ = "[email protected]"
__version__ = "4.0.0rc1"
__version__ = "4.0.0rc2"

__all__ = ["agent", "behaviour", "message", "template"]

Expand Down
7 changes: 5 additions & 2 deletions spade/agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,9 @@ class DisconnectedException(Exception):


class Agent(object):
def __init__(self, jid: str, password: str, verify_security: bool = False):
def __init__(
self, jid: str, password: str, port: int = 5222, verify_security: bool = False
):
"""
Creates an agent
Expand All @@ -45,6 +47,7 @@ def __init__(self, jid: str, password: str, verify_security: bool = False):
"""
self.jid = JID(jid)
self.password = password
self.xmpp_port = port
self.verify_security = verify_security

self.behaviours = []
Expand Down Expand Up @@ -166,7 +169,7 @@ async def _async_connect(self) -> None: # pragma: no cover
)
self.client.add_event_handler("message", self._message_received)

self.client.connect()
self.client.connect(self.jid.host, self.xmpp_port)

done, pending = await asyncio.wait(
[connected_task, disconnected_task, failed_auth_task],
Expand Down
Loading

0 comments on commit aa2d9be

Please sign in to comment.