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

Change code #1

Open
wants to merge 41 commits into
base: development
Choose a base branch
from
Open
Changes from 1 commit
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
fb7bfb6
Replace deprecated PdfMerger with PdfWriter (#173)
odkhang Jun 19, 2024
ef7b99c
Update Stripe to more recent version (#167)
lcduong Jun 20, 2024
8c8416a
Upgrade to recent 2.x VueJS (#177)
lcduong Jun 20, 2024
0d68953
Upgrade to Python 3.11 (#184)
lcduong Jun 21, 2024
4d82a91
optimize package import for stripe update (#198)
lcduong Jun 21, 2024
7ecacaa
Add orientation and height fields to Badgelayouts API response (#197)
Sak1012 Jun 21, 2024
100fd79
Merge branch 'master' into development
norbusan Jun 21, 2024
e27f132
Update Stripe to more recent version (#167)
lcduong Jun 20, 2024
ebf5c37
Upgrade to recent 2.x VueJS (#177)
lcduong Jun 20, 2024
703314a
Upgrade to Python 3.11 (#184)
lcduong Jun 21, 2024
f370c39
optimize package import for stripe update (#198)
lcduong Jun 21, 2024
201784c
Add orientation and height fields to Badgelayouts API response (#197)
Sak1012 Jun 21, 2024
146cf9c
Merge branch 'master' into development
norbusan Jun 21, 2024
fea6b17
Stripe plugin - correct template path (#201)
lcduong Jun 22, 2024
f98b9e0
Fix stripe incorrect gettext, update messages etc (#202)
norbusan Jun 22, 2024
569c78b
add support Ukrainan (#210)
lcduong Jun 25, 2024
abbde0c
support html / markdown for question title (#211)
lcduong Jun 25, 2024
c79035e
Merge pull request #212 from fossasia/development
mariobehling Jun 25, 2024
fab0799
Add text field as an option into the question page (#209)
lcduong Jun 26, 2024
8a21ac5
Hot fix Ukrainian language (#214)
lcduong Jun 26, 2024
f34d767
Merge pull request #216 from fossasia/development
mariobehling Jun 26, 2024
b626911
Hot fix Feature 171 (#218)
lcduong Jun 27, 2024
a292acb
Remove mariadb support (#183)
AviGawande Jun 27, 2024
19640c4
Improve flow for required field of Yes-No question (#206)
AviGawande Jul 1, 2024
326c3c2
Dynamic updation of Badge Size (#221)
Sak1012 Jul 2, 2024
e3480f8
Add plugins to autodeployment with docker (#208)
odkhang Jul 2, 2024
f6d88ff
Implement option to add link to privacy policy (#227)
odkhang Jul 3, 2024
7568897
Option to add customizable links to footer (#225)
lcduong Jul 8, 2024
052fa20
Replace pkg_resources (#232)
odkhang Jul 12, 2024
4ecc8f0
Do not repeat questions in form field of ticket form (#235)
odkhang Jul 13, 2024
5b5b64b
Added templates (#229)
Sak1012 Jul 13, 2024
4f81a16
Merge branch 'development'
marcoag Jul 13, 2024
93068bc
Implement customer accounts in system (#223)
odkhang Jul 14, 2024
fd9c2fd
Fix issue when create an event from other event configuration (#239)
odkhang Jul 14, 2024
048a39d
change default color for new organization (#240)
lcduong Jul 15, 2024
4d0b066
Implement Support for Sendgrid on a System and User Level (#195)
lcduong Jul 16, 2024
3558a8b
Use master branch in docker-pr workflow (#243)
norbusan Jul 17, 2024
e25a6e8
fix issue when send mail to invite member (#244)
lcduong Jul 17, 2024
63d245d
Allows tab IDs to be set in the HTML code (#247)
lcduong Jul 20, 2024
dcfd7a6
skip check for empty country (#246)
lcduong Jul 20, 2024
73117a8
change code
it-tma-tri Sep 4, 2024
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
Prev Previous commit
Next Next commit
Replace pkg_resources (fossasia#232)
* Replace pkg_resources with import importlib_metadata
odkhang authored Jul 12, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
commit 052fa2065eef8f77acc692b60e47278251b4c7db
48 changes: 39 additions & 9 deletions src/pretix/base/plugins.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
import os
import sys
import importlib.metadata
import logging

from enum import Enum
from typing import List

from django.apps import AppConfig, apps
from django.conf import settings
from django.core.exceptions import ImproperlyConfigured

logger = logging.getLogger(__name__)

class PluginType(Enum):
"""
@@ -53,12 +57,38 @@ def __init__(self, *args, **kwargs):
raise ImproperlyConfigured("A pretix plugin config should have a PretixPluginMeta inner class.")

if hasattr(self.PretixPluginMeta, 'compatibility') and not os.environ.get("PRETIX_IGNORE_CONFLICTS") == "True":
import pkg_resources
try:
pkg_resources.require(self.PretixPluginMeta.compatibility)
except pkg_resources.VersionConflict as e:
print("Incompatible plugins found!")
print("Plugin {} requires you to have {}, but you installed {}.".format(
self.name, e.req, e.dist
))
sys.exit(1)
self.check_compatibility()

def check_compatibility(self):
"""
Checks for compatibility of the plugin based on specified version requirements.

This method verifies if the currently installed versions of required packages match
the versions specified in the plugin's compatibility requirements. If a version
mismatch is found or a required package is not installed, it prints an error message
and exits the program.

Steps:
1. Iterates over the compatibility requirements specified in `self.PretixPluginMeta.compatibility`.
2. For each requirement, it splits the package name and the required version.
3. Fetches the installed version of the package using `importlib.metadata.version`.
4. Compares the installed version with the required version.
5. If a mismatch is found, prints an error message and exits the program.
6. If a required package is not found, catches the `PackageNotFoundError`, prints an error message,
and exits the program.

Raises:
SystemExit: If a version conflict or missing package is detected, the program exits.
"""
try:
for requirement in self.PretixPluginMeta.compatibility:
package_name, _, required_version = requirement.partition("==")
installed_version = importlib.metadata.version(package_name)
if installed_version != required_version:
logger.error("Incompatible plugins found!")
logger.error("Plugin %s requires you to have %s==%s, but you installed %s==%s",
self.name, package_name, required_version, package_name, installed_version)
sys.exit(1)
except importlib.metadata.PackageNotFoundError as e:
logger.exception(f"Package not found: {e}")
sys.exit(1)
14 changes: 8 additions & 6 deletions src/pretix/settings.py
Original file line number Diff line number Diff line change
@@ -2,13 +2,14 @@
import logging
import os
import sys
import importlib_metadata

from urllib.parse import urlparse
from .settings_helpers import build_db_tls_config, build_redis_tls_config
import django.conf.locale
from django.core.exceptions import ImproperlyConfigured
from django.utils.crypto import get_random_string
from kombu import Queue
from pkg_resources import iter_entry_points
from pycountry import currencies

from . import __version__
@@ -321,11 +322,12 @@
pass

PLUGINS = []
for entry_point in iter_entry_points(group='pretix.plugin', name=None):
if entry_point.module_name in PRETIX_PLUGINS_EXCLUDE:
continue
PLUGINS.append(entry_point.module_name)
INSTALLED_APPS.append(entry_point.module_name)
entry_points = importlib_metadata.entry_points()

for entry_point in entry_points.select(group='pretix.plugin'):
if entry_point.module not in PRETIX_PLUGINS_EXCLUDE:
PLUGINS.append(entry_point.module)
INSTALLED_APPS.append(entry_point.module)

HIJACK_AUTHORIZE_STAFF = True