Skip to content

Commit

Permalink
Merge pull request #61 from OpenNTI/native-ns-pkg
Browse files Browse the repository at this point in the history
Drop support for < 3.10; use native namespace packages.
  • Loading branch information
jamadden authored Nov 8, 2024
2 parents 8d99aa4 + 171da8c commit 3dc1c5d
Show file tree
Hide file tree
Showing 20 changed files with 161 additions and 200 deletions.
4 changes: 3 additions & 1 deletion .coveragerc
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[run]
source = nti.transactions
source_pkgs = nti.transactions
# New in 5.0; required for the GHA coveralls submission.
relative_files = True

Expand All @@ -15,6 +15,8 @@ exclude_lines =
if sys.platform == 'win32':
if mswindows:
if is_windows:
fail_under = 98.0
precision = 2

# Local Variables:
# mode: conf
Expand Down
13 changes: 13 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Keep GitHub Actions up to date with GitHub's Dependabot...
# https://docs.github.com/en/code-security/dependabot/working-with-dependabot/keeping-your-actions-up-to-date-with-dependabot
# https://docs.github.com/en/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file#package-ecosystem
version: 2
updates:
- package-ecosystem: github-actions
directory: /
groups:
github-actions:
patterns:
- "*" # Group all Actions updates into a single larger pull request
schedule:
interval: monthly
102 changes: 62 additions & 40 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -1,57 +1,79 @@
# Generated from:
# https://github.com/zopefoundation/meta/tree/master/config/pure-python
name: tests

on:
push:
pull_request:
schedule:
- cron: '0 12 * * 0' # run once a week on Sunday
# Allow to run this workflow manually from the Actions tab
workflow_dispatch:
on: [push, pull_request]

env:
PYTHONHASHSEED: 1042466059
ZOPE_INTERFACE_STRICT_IRO: 1
# To use editable installs of our nti namespace package combined with
# non-editable installs of other packages, you must set this.
# This is because setuptools has become broken thanks to PEP660.
# Adding the pkg_util line to __init__.py is a partial workaround,
# When it is loaded first on the path.
#
# With setuptools 75.3.0, nothing else worked for all the tools: not
# a strict editable_mode, not an empty __init__.py,
#
# See https://github.com/pypa/pip/issues/11587
# And https://github.com/pypa/setuptools/issues/4039
PYTHONPATH: src



jobs:
build:
test:
strategy:
# We want to see all failures:
fail-fast: false
matrix:
os:
- ["ubuntu", "ubuntu-latest"]
config:
# [Python version, tox env]
- ["3.12", "lint"]
- ["3.8", "py38"]
- ["3.9", "py39"]
- ["3.10", "py310"]
- ["3.11", "py311"]
- ["3.12", "py312"]
- ["3.13.0-beta.1", "py313"]
- ["pypy-3.10", "pypy3"]
- ["3.12", "docs"]
- ["3.12", "coverage"]
python-version:
- "pypy-3.10"
- "3.11"
- "3.12"
- "3.13"
extras:
- "[test,docs]"
include:
- python-version: "3.13"
extras: "[test,docs,gevent,pyramid]"

runs-on: ${{ matrix.os[1] }}
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.event.pull_request.base.repo.full_name
name: ${{ matrix.config[1] }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.config[0] }}
python-version: ${{ matrix.python-version }}
cache: 'pip'
cache-dependency-path: setup.py
cache-dependency-path: 'setup.py'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install tox
python -m pip install -U pip setuptools wheel
python -m pip install -U coverage
python -m pip install -v -U -e ".${{ matrix.extras }}" --config-settings editable_mode=compat
python -c 'from nti import transactions; print(transactions)'
ls -l /opt/hostedtoolcache/Py*/*/*/lib/*/site-packages/nti
cat /opt/hostedtoolcache/Py*/*/*/lib/*/site-packages/nti/*py
cat /opt/hostedtoolcache/Py*/*/*/lib/*/site-packages/*.pth
- name: Test
run: tox -e ${{ matrix.config[1] }}
- name: Coverage
if: matrix.config[1] == 'coverage'
run: |
pip install coveralls coverage-python-version
coveralls --service=github
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
python -m coverage run -m zope.testrunner --test-path=src --auto-color --auto-progress
coverage run -a -m sphinx -b doctest -d docs/_build/doctrees docs docs/_build/doctests
coverage combine || true
coverage report -i || true
- name: Lint
if: matrix.python-version == '3.12'
run: |
python -m pip install -U pylint
pylint nti.transactions
- name: Submit to Coveralls
uses: coverallsapp/github-action@v2
with:
parallel: true

coveralls_finish:
needs: test
runs-on: ubuntu-latest
steps:
- name: Coveralls Finished
uses: coverallsapp/github-action@v2
with:
parallel-finished: true
43 changes: 22 additions & 21 deletions .pylintrc
Original file line number Diff line number Diff line change
@@ -1,31 +1,22 @@
[MASTER]
load-plugins=pylint.extensions.bad_builtin,
pylint.extensions.check_elif,
pylint.extensions.code_style,
pylint.extensions.dict_init_mutate,
pylint.extensions.docstyle,
pylint.extensions.dunder,
pylint.extensions.emptystring,
pylint.extensions.comparetozero,
pylint.extensions.comparison_placement,
pylint.extensions.confusing_elif,
pylint.extensions.for_any_all,
pylint.extensions.consider_refactoring_into_while_condition,
pylint.extensions.mccabe,
pylint.extensions.check_elif,
pylint.extensions.eq_without_hash,
pylint.extensions.redefined_variable_type,
pylint.extensions.overlapping_exceptions,

# Requires you to have parameters docemented with types.
# This is a good thing! But there are a bunch of cases that don't
# have it here, and right now I don't want to add them.
# pylint.extensions.docparams,

# Prevents you from doing::
#
# stmts = [make_part(p) for p in stuff]
# stmts = ''.join(stmts)
#
# We use that pattern a lot here.
# pylint.extensions.redefined_variable_type,
pylint.extensions.docparams,
pylint.extensions.private_import,
pylint.extensions.set_membership,
pylint.extensions.typing,

# magic_value wants you to not use arbitrary strings and numbers
# inline in the code. But it's overzealous and has way too many false
Expand Down Expand Up @@ -66,6 +57,7 @@ load-plugins=pylint.extensions.bad_builtin,
init-hook =
import astroid.bases
astroid.bases.POSSIBLE_PROPERTIES.add('Lazy')
astroid.bases.POSSIBLE_PROPERTIES.add('LazyOnClass')
astroid.bases.POSSIBLE_PROPERTIES.add('readproperty')
astroid.bases.POSSIBLE_PROPERTIES.add('non_overridable')
import os
Expand Down Expand Up @@ -128,8 +120,13 @@ init-hook =
# Into ``if (foo := get_foo()):``
# But there are a *lot* of those. Trust people to do the right, most
# readable, thing
# raise-missing-from: Py2 compatibility
# super-with-arguments: Py2
#
# docstring-first-line-empty: That's actually our standard, based on Django.
# XXX: unclear on the docstring warnings, missing-type-doc, missing-param-doc,
# differing-param-doc, differing-type-doc (are the last two replacements for the first two?)
#
# They should be addressed, in general they are a good thing, but sometimes they are
# unnecessary.
disable=wrong-import-position,
wrong-import-order,
missing-docstring,
Expand All @@ -147,9 +144,12 @@ disable=wrong-import-position,
consider-using-f-string,
consider-using-assignment-expr,
use-dict-literal,
raise-missing-from,
super-with-arguments,
redundant-u-string-prefix
missing-type-doc,
missing-param-doc,
differing-param-doc,
differing-type-doc,
compare-to-zero,
docstring-first-line-empty,

enable=consider-using-augmented-assign

Expand Down Expand Up @@ -193,6 +193,7 @@ generated-members=REQUEST,acl_users,aq_parent,providedBy
# and thus existing member attributes cannot be deduced by static analysis. It
# supports qualified module names, as well as Unix pattern matching.
#ignored-modules=gevent._corecffi,gevent.os,os,greenlet,threading,gevent.libev.corecffi,gevent.socket,gevent.core,gevent.testing.support
ignored-modules=psycopg2.errors

[DESIGN]
max-attributes=12
Expand Down
5 changes: 3 additions & 2 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@
Changes
=========

5.0.1 (unreleased)
5.1.0 (unreleased)
==================

- Nothing changed yet.
- Drop support for anything earlier than Python 3.10.
- Use native namespace packages.


5.0.0 (2024-06-11)
Expand Down
Empty file removed TODO
Empty file.
7 changes: 0 additions & 7 deletions babel.cfg

This file was deleted.

20 changes: 0 additions & 20 deletions nose2.cfg

This file was deleted.

5 changes: 5 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[build-system]
requires = [
"wheel",
"setuptools>=75.3",
]
8 changes: 0 additions & 8 deletions setup.cfg

This file was deleted.

12 changes: 4 additions & 8 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import codecs
from setuptools import setup, find_packages
from setuptools import setup
from setuptools import find_namespace_packages

version = '5.0.1.dev0'

Expand Down Expand Up @@ -41,8 +42,6 @@ def _read(fname):
'License :: OSI Approved :: Apache Software License',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3 :: Only',
'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',
Expand All @@ -51,16 +50,13 @@ def _read(fname):
'Programming Language :: Python :: Implementation :: PyPy',
'Framework :: ZODB',
],
python_requires=">=3.8",
packages=find_packages('src'),
python_requires=">=3.10",
packages=find_namespace_packages(where='src'),
package_dir={'': 'src'},
include_package_data=True,
namespace_packages=['nti'],
tests_require=TESTS_REQUIRE,
install_requires=[
'six',
'perfmetrics',
'setuptools',
'transaction >= 3.0.0',
'zope.cachedescriptors',
'zope.exceptions',
Expand Down
2 changes: 1 addition & 1 deletion src/nti/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__import__('pkg_resources').declare_namespace(__name__) # pragma: no cover
from pkgutil import extend_path; __path__ = extend_path(__path__, __name__) # pylint:disable=multiple-statements
12 changes: 6 additions & 6 deletions src/nti/transactions/__init__.py
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
.. $Id$
nti.transactions module.
Performs monkey patches when imported.
"""

from __future__ import print_function, absolute_import, division
__docformat__ = "restructuredtext en"

logger = __import__('logging').getLogger(__name__)

DEFAULT_LONG_RUNNING_COMMIT_IN_SECS = 6
from perfmetrics import Metric
from zope import interface

DEFAULT_LONG_RUNNING_COMMIT_IN_SECS = 6

###
# Monkey-patches
###

# By default, it wants to create a different logger
# for each and every thread or greenlet. We go through
# lots of greenlets, so that's lots of loggers
from transaction import _transaction
from transaction import _transaction # pylint:disable=import-private-name
# pylint:disable-next=protected-access
_transaction._LOGGER = __import__('logging').getLogger('txn.GLOBAL')

Expand Down
8 changes: 3 additions & 5 deletions src/nti/transactions/_httpexceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,12 @@
See :mod:`pyramid.httpexceptions`
"""
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function

class HTTPException(Exception):
"Placeholder if pyramid is not installed."
"""Placeholder if pyramid is not installed."""

class HTTPBadRequest(HTTPException):
"Placeholder if pyramid is not installed."
"""Placeholder if pyramid is not installed."""

try:
from pyramid import httpexceptions
Expand Down
Loading

0 comments on commit 3dc1c5d

Please sign in to comment.