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

Proposal Release 5.0.0a #102

Open
wants to merge 16 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
43 changes: 43 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# run test suites

name: Tests
on:
- pull_request
- push
- release
- workflow_dispatch

# cancel the current workflow if another commit was pushed on the same PR or reference
# uses the GitHub workflow name to avoid collision with other workflows running on the same PR/reference
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true

jobs:
tests:
runs-on: ${{ matrix.platform }}
strategy:
matrix:
platform: [ ubuntu-latest, windows-latest ]
python-version: [ '3.7', '3.8', '3.9', '3.10', '3.11', '3.12' ]
steps:
- uses: actions/checkout@v1
- name: Cache .tox directory
uses: actions/cache@v2
with:
path: '.tox'
# -X at the end can be bumped to force by-pass of a cache in case it's broken
# as GitHub actions does not support deletion of caches...
key: ${{ runner.os }}-${{ matrix.python-version }}-${{ hashFiles('*requirements*.txt') }}-X
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install tox tox-gh-actions
- name: Test with tox
run: tox
env:
PLATFORM: ${{ matrix.platform }}
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -48,3 +48,7 @@ docs/_build
coverage.xml
junit.xml
*celerybeat-schedule*

# IDE
.idea
.vscode
5 changes: 5 additions & 0 deletions CHANGES.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
5.0.0a
================
- Add support of Python 3.12
- Add support `celery_config_module` option for alternate location of `celeryconfig.py`

4.0.0
================
- Drop support for celery 3.0
Expand Down
4 changes: 4 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,10 @@ If you want to use the standard **celeryconfig** python file you can set the

[celery]
use_celeryconfig = True
celery_config_module = my.custom.celeryconfig

You may also suppress the **celery_config_module** directive to use the default
`"celeryconfig"`

You can get more information for celeryconfig.py here:

Expand Down
2 changes: 1 addition & 1 deletion pyramid_celery/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ def setup_app(app, root, request, registry, closer, ini_location):
)

if asbool(celery_config.get('use_celeryconfig', False)) is True:
config_path = 'celeryconfig'
config_path = celery_config.get('celery_config_module', 'celeryconfig')
celery_app.config_from_object(config_path)
else:
hijack_key = 'worker_hijack_root_logger'
Expand Down
2 changes: 1 addition & 1 deletion pyramid_celery/loaders.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ def get_route_config(parser, section):


class INILoader(celery.loaders.base.BaseLoader):
ConfigParser = configparser.SafeConfigParser
ConfigParser = configparser.ConfigParser

def __init__(self, app, **kwargs):
self.celery_conf = kwargs.pop('ini_file')
Expand Down
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
pyramid
celery
importlib-metadata<5; python_version <= "3.7"
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ norecursedirs =

addopts =
-rxEfs
--strict
--strict-markers
--doctest-modules
--doctest-glob=\*.rst
--tb=short
Expand Down
70 changes: 37 additions & 33 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import os
import sys
from setuptools import setup, find_packages

here = os.path.abspath(os.path.dirname(__file__))
Expand All @@ -8,36 +7,41 @@

requires = ['pyramid', 'celery']

setup(name='pyramid_celery',
version='4.0.0',
description='Celery integration with pyramid',
long_description=README + "\n" + CHANGES,
classifiers=[
"Development Status :: 5 - Production/Stable",
"Intended Audience :: Developers",
"License :: OSI Approved :: MIT License",
"Operating System :: Unix",
"Operating System :: POSIX",
"Operating System :: Microsoft :: Windows",
"Programming Language :: Python",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.6",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: Implementation :: CPython",
"Programming Language :: Python :: Implementation :: PyPy",
],
author='John Anderson',
author_email='[email protected]',
url='https://github.com/sontek/pyramid_celery',
keywords='paste pyramid celery message queue amqp job task distributed',
license='MIT',
packages=find_packages(),
include_package_data=True,
zip_safe=False,
install_requires=requires,
tests_require=requires + ['pytest'],
python_requires='>=3.6',
test_suite="pyramid_celery",
setup(
name='pyramid_celery',
version='5.0.0a',
description='Celery integration with pyramid',
long_description=README + "\n" + CHANGES,
classifiers=[
"Development Status :: 5 - Production/Stable",
"Intended Audience :: Developers",
"License :: OSI Approved :: MIT License",
"Operating System :: Unix",
"Operating System :: POSIX",
"Operating System :: Microsoft :: Windows",
"Programming Language :: Python",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3 :: Only",
"Programming Language :: Python :: 3.6",
"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",
"Programming Language :: Python :: Implementation :: CPython",
"Programming Language :: Python :: Implementation :: PyPy",
],
author='John Anderson',
author_email='[email protected]',
url='https://github.com/sontek/pyramid_celery',
keywords='paste pyramid celery message queue amqp job task distributed',
license='MIT',
packages=find_packages(),
include_package_data=True,
zip_safe=False,
install_requires=requires,
tests_require=requires + ['pytest'],
python_requires='>=3.6',
test_suite="pyramid_celery",
)
3 changes: 3 additions & 0 deletions tests/configs/custom_useceleryconfig.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[celery]
use_celeryconfig = true
celery_config_module = custom_celeryconfig.config
Empty file.
1 change: 1 addition & 0 deletions tests/custom_celeryconfig/config.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
BROKER_URL = "redis://localhost:1337/1"
24 changes: 20 additions & 4 deletions tests/test_celery.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,22 @@ def test_includeme_use_celeryconfig():
assert celery_app.conf['broker_url'] == 'redis://localhost:1337/0'


@pytest.mark.unit
def test_includeme_use_custom_celeryconfig():
from pyramid_celery import includeme
from pyramid_celery import celery_app
from pyramid import testing
from pyramid.registry import Registry
config = testing.setUp()
config.registry = Registry()
config.registry.settings = {}

includeme(config)
config.configure_celery('tests/configs/custom_useceleryconfig.ini')

assert celery_app.conf['broker_url'] == 'redis://localhost:1337/1'


@pytest.mark.unit
def test_preload_no_ini():
from pyramid_celery import on_preload_parsed
Expand All @@ -74,7 +90,7 @@ def test_preload_ini():

with mock.patch('pyramid_celery.bootstrap') as boot:
on_preload_parsed(options)
assert boot.called_with('dev.ini')
boot.assert_called_with(options['ini'])


@pytest.mark.unit
Expand Down Expand Up @@ -105,8 +121,8 @@ def test_preload_with_ini_vars():

with mock.patch('pyramid_celery.bootstrap') as boot:
on_preload_parsed(options)
expected_vars = {'database': 'foo', 'password': 'bar'}
assert boot.called_with('dev.ini', expected_vars)
expected_vars = {'database': 'foo', 'password': 'bar'}
boot.assert_called_with(options['ini'], options=expected_vars)


@pytest.mark.unit
Expand All @@ -127,7 +143,7 @@ def test_ini_logging():
format='', colorize=False,
)

assert setup_logging.called_with('tests/configs/dev.ini')
setup_logging.assert_called_with('tests/configs/dev.ini')


@pytest.mark.unit
Expand Down
20 changes: 18 additions & 2 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
[tox]
skipsdist = True
envlist = py36, py37, py38, py39, pypy3, flake8, celery4, celery5
envlist = py{36,37,38,39,310,py3}-{celery4,celery5}, py{311,312}-celery5, flake8

[base]
commands =
{envpython} -m pip install -e . -r test-requirements.txt
{envpython} -m pip install -e . -r requirements.txt -r test-requirements.txt

[testenv]
pip_pre=False
Expand Down Expand Up @@ -33,3 +33,19 @@ commands =
{[base]commands}
{envpython} -m pip install -U 'celery>3,<5'
{envpython} -m pytest {posargs}

[gh-actions]
python =
3.6: py36-{celery4,celery5}
3.7: py37-{celery4,celery5}
3.8: py38-{celery4,celery5}
3.9: py39-{celery4,celery5}
3.10: py310-{celery4,celery5}, flake8
3.11: py311-celery5
3.12: py312-celery5

[gh-actions:env]
PLATFORM =
ubuntu-latest: linux
macos-latest: macos
windows-latest: windows