Skip to content

Commit

Permalink
Merge branch 'master' into release
Browse files Browse the repository at this point in the history
  • Loading branch information
theCapypara committed Mar 17, 2024
2 parents 12d7217 + 9f5249c commit 57fd93d
Show file tree
Hide file tree
Showing 12 changed files with 109 additions and 43 deletions.
14 changes: 7 additions & 7 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
steps:
# For tags we assume the version in setup.py is correct!
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
submodules: 'recursive'
- name: Rewrite version for dev if not tag
Expand All @@ -22,18 +22,18 @@ jobs:
run: |
echo "PACKAGE_VERSION=$(python3 -- ./setup.py --version)" >> $GITHUB_ENV
- name: Set up Python 3.8
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: 3.8
- name: Upgrade pip
run: |
python -m pip install --upgrade pip
- name: Build Python wheels
uses: RalfG/python-wheels-manylinux-build@v0.3.4-manylinux2010_x86_64
uses: RalfG/python-wheels-manylinux-build@v0.5.0-manylinux2014_x86_64
with:
python-versions: 'cp36-cp36m cp37-cp37m cp38-cp38 cp39-cp39 cp310-cp310'
python-versions: 'cp36-cp36m cp37-cp37m cp38-cp38 cp39-cp39 cp310-cp310 cp311-cp311 cp312-cp312'
- name: Upload wheels
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: wheels
path: dist/*.whl
Expand All @@ -44,11 +44,11 @@ jobs:
name: Deploy wheels to PyPI
steps:
- name: Download wheels
uses: actions/download-artifact@v3
uses: actions/download-artifact@v4
with:
name: wheels
- name: Set up Python 3.8
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: 3.8
- name: Upgrade pip
Expand Down
14 changes: 7 additions & 7 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
schema==0.7.5
pyyaml==6.0
configcrunch==1.0.4
pyyaml==6.0.1
configcrunch==1.0.5
appdirs==1.4.4
janus==1.0.0
psutil==5.9.5
GitPython==3.1.32
pywinpty==2.0.11; sys_platform == 'win32'
python-hosts==1.0.3
python-dotenv==1.0.0
psutil==5.9.8
GitPython==3.1.42
pywinpty==2.0.12; sys_platform == 'win32'
python-hosts==1.0.5
python-dotenv==1.0.1
19 changes: 17 additions & 2 deletions riptide/config/files.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,17 @@
Also provides some utility file-related functions.
"""
import os
import pkg_resources
import atexit
import re
import sys

if sys.version_info < (3, 11):
import pkg_resources
else:
import importlib.resources

from appdirs import user_config_dir
from contextlib import ExitStack

# Expected name of the project files during auto-discovery
from typing import Optional
Expand Down Expand Up @@ -52,7 +60,14 @@ def discover_project_file() -> Optional[str]:

def riptide_assets_dir() -> str:
""" Path to the assets directory of riptide_lib. """
return pkg_resources.resource_filename('riptide', 'assets')
if sys.version_info < (3, 11):
return pkg_resources.resource_filename('riptide', 'assets')
else:
file_manager = ExitStack()
atexit.register(file_manager.close)
ref = importlib.resources.files('riptide') / 'assets'
path = file_manager.enter_context(importlib.resources.as_file(ref))
return path


def riptide_main_config_file() -> str:
Expand Down
21 changes: 16 additions & 5 deletions riptide/db/driver/db_driver_for_service.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
"""Module to resolve database drivers for services"""
import sys
from typing import Union, TYPE_CHECKING, Optional

import pkg_resources
if sys.version_info < (3, 10):
import pkg_resources
else:
from importlib.metadata import entry_points

from riptide.db.driver.abstract import AbstractDbDriver
if TYPE_CHECKING:
Expand All @@ -16,10 +20,17 @@ def get(service_data: Union['Service', dict], service: Optional['Service'] = Non
# Look up package entrypoints for db drivers
if service is None:
service = service_data
drivers = {
entry_point.name:
entry_point.load() for entry_point in pkg_resources.iter_entry_points(DB_DRIVER_ENTRYPOINT_KEY)
}

if sys.version_info < (3, 10):
drivers = {
entry_point.name:
entry_point.load() for entry_point in pkg_resources.iter_entry_points(DB_DRIVER_ENTRYPOINT_KEY)
}
else:
drivers = {
entry_point.name:
entry_point.load() for entry_point in entry_points().select(group=DB_DRIVER_ENTRYPOINT_KEY)
}

if service_data["driver"]["name"] in drivers:
return drivers[service_data["driver"]["name"]](service)
Expand Down
22 changes: 17 additions & 5 deletions riptide/engine/loader.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
import pkg_resources
import sys

if sys.version_info < (3, 10):
import pkg_resources
else:
from importlib.metadata import entry_points

from riptide.plugin.loader import load_plugins

Expand All @@ -8,10 +13,17 @@
def load_engine(engine_name):
"""Load the engine by the given name. Propagates loaded engine to all projects."""
# Look up package entrypoints for engines
engines = {
entry_point.name:
entry_point.load() for entry_point in pkg_resources.iter_entry_points(ENGINE_ENTRYPOINT_KEY)
}
if sys.version_info < (3, 10):
engines = {
entry_point.name:
entry_point.load() for entry_point in pkg_resources.iter_entry_points(ENGINE_ENTRYPOINT_KEY)
}
else:
engines = {
entry_point.name:
entry_point.load() for entry_point in entry_points().select(group=ENGINE_ENTRYPOINT_KEY)
}

if engine_name in engines:
instance = engines[engine_name]()
for plugin in load_plugins().values():
Expand Down
21 changes: 16 additions & 5 deletions riptide/plugin/loader.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
import sys
from typing import Dict, Union, TYPE_CHECKING

import pkg_resources
if sys.version_info < (3, 10):
import pkg_resources
else:
from importlib.metadata import entry_points

from riptide.engine.abstract import AbstractEngine
from riptide.plugin.abstract import AbstractPlugin
Expand All @@ -22,10 +26,17 @@ def load_plugins() -> Dict[str, AbstractPlugin]:
global loaded_plugins
if not loaded_plugins:
# Look up package entrypoints for engines
plugins = {
entry_point.name:
entry_point.load()() for entry_point in pkg_resources.iter_entry_points(PLUGIN_ENTRYPOINT_KEY)
}
if sys.version_info < (3, 10):
plugins = {
entry_point.name:
entry_point.load()() for entry_point in pkg_resources.iter_entry_points(PLUGIN_ENTRYPOINT_KEY)
}
else:
plugins = {
entry_point.name:
entry_point.load()() for entry_point in entry_points().select(group=PLUGIN_ENTRYPOINT_KEY)
}

for name, plugin in plugins.items():
if not isinstance(plugin, AbstractPlugin):
raise ValueError(f"The Riptide plugin {name} does not correctly implement AbstractPlugin.")
Expand Down
26 changes: 20 additions & 6 deletions riptide/tests/integration/engine/engine_loader.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
import sys
from typing import Generator, Tuple

import pkg_resources
if sys.version_info < (3, 10):
import pkg_resources
else:
from importlib.metadata import entry_points

from riptide.engine.abstract import AbstractEngine
from riptide.engine.loader import ENGINE_ENTRYPOINT_KEY
Expand All @@ -13,13 +17,23 @@ def load_engines() -> Generator[Tuple[str, AbstractEngine, AbstractEngineTester]
"""Generator that returns tuples of (name, engine, engine_tester)"""

# Collect testers
engine_testers = {
entry_point.name:
entry_point.load() for entry_point in pkg_resources.iter_entry_points(ENGINE_TESTER_ENTRYPOINT_KEY)
}
if sys.version_info < (3, 10):
engine_testers = {
entry_point.name:
entry_point.load() for entry_point in pkg_resources.iter_entry_points(ENGINE_TESTER_ENTRYPOINT_KEY)
}
engines = pkg_resources.iter_entry_points(ENGINE_ENTRYPOINT_KEY)
else:
engine_testers = {
entry_point.name:
entry_point.load() for entry_point in entry_points().select(
group=ENGINE_TESTER_ENTRYPOINT_KEY
)
}
engines = entry_points().select(group=ENGINE_ENTRYPOINT_KEY)

# Iterate engines
for engine_entry_point in pkg_resources.iter_entry_points(ENGINE_ENTRYPOINT_KEY):
for engine_entry_point in engines:
if engine_entry_point.name not in engine_testers:
print(f"WARNING: No engine tester found for {engine_entry_point.name}. Was not tested.")
continue
Expand Down
4 changes: 2 additions & 2 deletions riptide/tests/unit/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,12 @@ def test_get_riptide_version(self):
]
i = 0
for version, expected in versions:
with mock.patch('pkg_resources.get_distribution') as gd_mock:
with mock.patch('importlib.metadata.version') as gd_mock:
version_mock = Mock()
version_mock.version = version
gd_mock.return_value = version_mock

self.assertEqual(expected, get_riptide_version(), f'for entry {i:d}')

gd_mock.assert_called_with('riptide_lib')
gd_mock.assert_called_with('riptide-lib')
i += 1
4 changes: 2 additions & 2 deletions riptide/util.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"""Various utility functions"""
import pkg_resources
from importlib.metadata import version


class SystemFlag:
Expand Down Expand Up @@ -34,4 +34,4 @@ def get_riptide_version():


def get_riptide_version_raw():
return pkg_resources.get_distribution("riptide_lib").version
return version("riptide-lib")
3 changes: 2 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
__version__ = '0.8.0'
__version__ = '0.8.1'
from setuptools import setup, find_packages

# README read-in
Expand Down Expand Up @@ -38,5 +38,6 @@
'Programming Language :: Python :: 3.9',
'Programming Language :: Python :: 3.10',
'Programming Language :: Python :: 3.11',
'Programming Language :: Python :: 3.12',
],
)
2 changes: 2 additions & 0 deletions test_assets/riptide-docker-tox/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,13 @@ RUN export DEBIAN_FRONTEND=noninteractive \
python3.9 python3.9-dev libpython3.9-dev libpython3.9-stdlib python3.9-distutils \
python3.10 python3.10-dev libpython3.10-dev libpython3.10-stdlib python3.10-distutils \
python3.11 python3.11-dev libpython3.11-dev libpython3.11-stdlib python3.11-distutils \
python3.12 python3.12-dev libpython3.12-dev libpython3.12-stdlib python3.12-distutils \
&& curl -fSL "https://bootstrap.pypa.io/get-pip.py" -o get-pip.py \
&& python3.8 get-pip.py \
&& python3.9 get-pip.py \
&& python3.10 get-pip.py \
&& python3.11 get-pip.py \
&& python3.12 get-pip.py \
&& rm get-pip.py \
&& rm -rf /var/lib/apt/lists/*

Expand Down
2 changes: 1 addition & 1 deletion tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# test suite on all supported python versions. To use it, "pip install tox"
# and then run "tox" from this directory.
[tox]
envlist = py38,py39,py310,py311
envlist = py38,py39,py310,py311,py312
[testenv]
commands =
pytest -rfs --junitxml test_reports/all.xml riptide/tests
Expand Down

0 comments on commit 57fd93d

Please sign in to comment.