Skip to content

Commit efe4824

Browse files
committed
toml
1 parent 4d190c3 commit efe4824

4 files changed

Lines changed: 62 additions & 237 deletions

File tree

build.py

Lines changed: 0 additions & 45 deletions
This file was deleted.

codecov.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
ignore:
2+
- "build_package.py"
23
- "docs/*.py"
34
- "pygame_menu/__pyinstaller/*py"
45
- "pygame_menu/examples/*.py"

pygame_menu/__init__.py

Lines changed: 61 additions & 99 deletions
Original file line numberDiff line numberDiff line change
@@ -6,89 +6,42 @@
66
A menu for pygame. Simple, and easy to use.
77
"""
88

9-
from __future__ import annotations
10-
11-
__all__ = [
12-
# Common classes
13-
"BaseImage",
14-
"Menu",
15-
"Sound",
16-
"Theme",
17-
]
18-
19-
# Check if pygame exists, if not maybe the module is being used by setup.py
20-
__pygame_version__ = None
21-
try:
22-
from pygame import version as __pygame_version__
23-
24-
__pygame_version__ = __pygame_version__.vernum
25-
except (ModuleNotFoundError, ImportError):
26-
pass
27-
28-
# Import modules that require pygame
29-
if __pygame_version__ is not None:
30-
"""
31-
BaseImage: Provides basic image loading and manipulation with pygame
32-
"""
33-
import pygame_menu.baseimage
34-
from pygame_menu.baseimage import BaseImage
35-
36-
"""
37-
Controls: Default controls of menu object and key definition
38-
"""
39-
import pygame_menu.controls
40-
41-
"""
42-
Events: Menu events definition and locals
43-
"""
44-
import pygame_menu.events
45-
46-
"""
47-
Fonts: Menu fonts
48-
"""
49-
import pygame_menu.font
50-
51-
"""
52-
Locals: Local constants
53-
"""
54-
import pygame_menu.locals
55-
56-
"""
57-
Menu: Menu class
58-
"""
59-
from pygame_menu.menu import Menu
60-
61-
"""
62-
ScrollArea: Scrollarea class
63-
"""
64-
import pygame_menu._scrollarea
65-
66-
"""
67-
Sound: Sound class
68-
"""
69-
import pygame_menu.sound
70-
from pygame_menu.sound import Sound
9+
import logging
10+
import os
11+
from datetime import datetime
12+
from importlib.metadata import PackageNotFoundError, metadata
7113

72-
"""
73-
Themes: Menu themes
74-
"""
75-
import pygame_menu.themes
76-
from pygame_menu.themes import Theme
14+
logger = logging.getLogger(__name__)
7715

78-
"""
79-
Widgets: Menu widgets
80-
"""
81-
import pygame_menu.widgets
16+
__all__ = ["BaseImage", "Menu", "Sound", "Theme"]
8217

83-
"""
84-
Version: Library version
85-
"""
86-
import pygame_menu.version
18+
# Metadata
19+
try:
20+
_meta = metadata("pygame-menu")
21+
__version__ = _meta.get("Version")
22+
__author__ = _meta.get("Author")
23+
__email__ = _meta.get("Author-email")
24+
__description__ = _meta.get("Summary")
25+
__license__ = _meta.get("License")
26+
__url__ = _meta.get("Home-page")
27+
__module_name__ = _meta.get("Name")
28+
except PackageNotFoundError:
29+
# Local fallback
30+
__version__ = "4.4.3"
31+
__author__ = "Pablo Pizarro R."
32+
__email__ = "pablo@ppizarror.com"
33+
__description__ = "A menu for pygame. Simple, and easy to use"
34+
__license__ = "MIT"
35+
__url__ = "https://pygame-menu.readthedocs.io"
36+
__module_name__ = "pygame-menu"
37+
38+
# Extra metadata not provided by importlib
39+
__url_documentation__ = "https://pygame-menu.readthedocs.io"
40+
__url_source_code__ = "https://github.com/ppizarror/pygame-menu"
41+
__url_bug_tracker__ = "https://github.com/ppizarror/pygame-menu/issues"
42+
__keywords__ = "pygame menu menus gui widget input button pygame-menu image sound ui"
43+
__copyright__ = f"Copyright 2017-{datetime.now().year} Pablo Pizarro R."
8744

88-
"""
89-
Metadata: Information about the project
90-
"""
91-
__author__ = "Pablo Pizarro R."
9245
__contributors__ = [
9346
# Author
9447
"ppizarror",
@@ -116,31 +69,40 @@
11669
"werdeil",
11770
"zPaw",
11871
]
119-
__copyright__ = "Copyright 2017 Pablo Pizarro R. @ppizarror"
120-
__description__ = "A menu for pygame. Simple, and easy to use"
121-
__email__ = "pablo@ppizarror.com"
122-
__keywords__ = "pygame menu menus gui widget input button pygame-menu image sound ui"
123-
__license__ = "MIT"
124-
__module_name__ = "pygame-menu"
125-
__url__ = "https://pygame-menu.readthedocs.io"
126-
__url_bug_tracker__ = "https://github.com/ppizarror/pygame-menu/issues"
127-
__url_documentation__ = "https://pygame-menu.readthedocs.io"
128-
__url_source_code__ = "https://github.com/ppizarror/pygame-menu"
129-
__version__ = pygame_menu.version.ver
13072

131-
"""
132-
Print pygame-menu version.
133-
"""
134-
import logging
135-
import os
73+
# Pygame check
74+
__pygame_version__ = None
75+
try:
76+
from pygame import version as __pv
13677

137-
logger = logging.getLogger(__name__)
78+
__pygame_version__ = __pv.vernum
79+
except (ModuleNotFoundError, ImportError):
80+
# Pygame is not installed; skip pygame-dependent imports
81+
pass
13882

83+
# Conditional imports
84+
if __pygame_version__ is not None:
85+
from pygame_menu import (
86+
baseimage,
87+
menu,
88+
sound,
89+
themes,
90+
_scrollarea,
91+
controls,
92+
events,
93+
font,
94+
locals,
95+
widgets,
96+
)
97+
98+
BaseImage = baseimage.BaseImage
99+
Menu = menu.Menu
100+
Sound = sound.Sound
101+
Theme = themes.Theme
102+
103+
# Version print
139104
if (
140105
"PYGAME_MENU_HIDE_VERSION" not in os.environ
141106
and "PYGAME_HIDE_SUPPORT_PROMPT" not in os.environ
142107
):
143108
logger.info(f"{__module_name__} {__version__}")
144-
145-
# Cleanup namespace
146-
del os

setup.py

Lines changed: 0 additions & 93 deletions
This file was deleted.

0 commit comments

Comments
 (0)