Skip to content

Commit 47ddad0

Browse files
committed
Add pyproject.toml
1 parent aaa49ef commit 47ddad0

File tree

4 files changed

+97
-60
lines changed

4 files changed

+97
-60
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ src/m64py.egg-info/
44

55
# Files
66
dist/*.egg
7+
dist/*.tar.gz
78

89
# Byte-compiled / optimized / DLL files
910
__pycache__/

README.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ PyPi
4646

4747
To install just the Python dependencies:
4848

49-
``pip install -r requirements.txt --user``
49+
``python -m pip install -r requirements.txt --user``
5050

5151
.. note::
5252

@@ -59,13 +59,13 @@ To install just the Python dependencies:
5959
Install
6060
=======
6161

62-
First, run ``python setup.py build`` followed by ``python setup.py install``
62+
First, run ``python setup.py build`` followed by ``python -m pip install .``
6363
to install
6464

6565
.. code::
6666
6767
python setup.py build
68-
python setup.py install --user
68+
python -m pip install . --user
6969
7070
.. note::
7171

pyproject.toml

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
[build-system]
2+
requires = ["setuptools"]
3+
build-backend = "setuptools.build_meta"
4+
5+
[project]
6+
name = "m64py"
7+
description = "A frontend for Mupen64Plus"
8+
dynamic = ["version"]
9+
readme = "README.rst"
10+
license = {text = "GNU GPLv3"}
11+
requires-python = ">=3.9"
12+
keywords = ["emulator", "nintendo64"]
13+
authors = [{name = "Milan Nikolic", email = "gen2brain@gmail.com"}]
14+
dependencies = ["PyQt6", "PySDL2"]
15+
classifiers = [
16+
"Development Status :: 4 - Beta",
17+
"Programming Language :: Python :: 3",
18+
"License :: OSI Approved :: GNU General Public License v3 (GPLv3)",
19+
"Topic :: Games/Entertainment",
20+
"Intended Audience :: End Users/Desktop",
21+
"Operating System :: Microsoft :: Windows",
22+
"Operating System :: MacOS :: MacOS X",
23+
"Operating System :: POSIX :: Linux"
24+
]
25+
26+
[project.urls]
27+
Homepage = "https://m64py.sourceforge.net"
28+
Repository = "https://github.com/mupen64plus/mupen64plus-ui-python"
29+
Issues = "https://github.com/mupen64plus/mupen64plus-ui-python/issues"
30+
Changelog = "https://raw.githubusercontent.com/mupen64plus/mupen64plus-ui-python/refs/heads/master/CHANGELOG"
31+
32+
[tool.setuptools]
33+
script-files = ["bin/m64py"]
34+
package-dir = {"" = "src"}
35+
36+
[tool.setuptools.packages.find]
37+
where = ["src"]
38+
39+
[tool.setuptools.data-files]
40+
"share/icons/hicolor/96x96/apps" = ["xdg/net.sourceforge.m64py.M64Py.png"]
41+
"share/applications" = ["xdg/net.sourceforge.m64py.M64Py.desktop"]
42+
43+
[tool.setuptools.dynamic]
44+
version = {attr = "m64py.core.defs.FRONTEND_VERSION"}

setup.py

Lines changed: 49 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,27 @@
11
#!/usr/bin/env python
22

3-
import fnmatch
4-
import glob
53
import os
4+
import re
5+
import io
6+
import sys
7+
import glob
68
import shutil
9+
import fnmatch
710
import subprocess
8-
import sys
911
import fileinput
1012

1113
import setuptools
14+
from setuptools.command.build import build
1215

13-
try:
14-
from setuptools.modified import newer
15-
except ImportError:
16-
from distutils.dep_util import newer
17-
18-
# Add the src folder to the path
19-
sys.path.insert(0, os.path.realpath("src"))
20-
21-
from m64py.core.defs import FRONTEND_VERSION
2216

2317
BASE_DIR = os.path.dirname(os.path.realpath(__file__))
18+
FRONTEND_VERSION = re.search(r'FRONTEND_VERSION\s*=\s*[\'"]([^\'"]*)[\'"]',
19+
io.open(os.path.join(BASE_DIR, "src", "m64py", "core", "defs.py")).read()).group(1)
2420

2521

2622
class BuildQt(setuptools.Command):
2723

28-
description = "Build the Qt interface"
24+
description = "Build the Qt user interface"
2925

3026
boolean_options = []
3127
user_options = []
@@ -36,15 +32,18 @@ def initialize_options(self):
3632
def finalize_options(self):
3733
pass
3834

35+
def newer(self, source, target):
36+
return not os.path.exists(target) or (os.path.getmtime(source) > os.path.getmtime(target))
37+
3938
def compile_rc(self, qrc_file):
4039
py_file = os.path.splitext(qrc_file)[0] + "_rc.py"
41-
if not newer(qrc_file, py_file):
40+
if not self.newer(qrc_file, py_file):
4241
return
4342
rcc_exe = self.find_executable("rcc")
4443
if rcc_exe is None:
4544
self.warn("Unable to find Qt Resource Compiler (rcc)")
4645
sys.exit(1)
47-
if subprocess.call(["rcc", "-g", "python", qrc_file, "-o", py_file]) > 0:
46+
if subprocess.call([rcc_exe, "-g", "python", qrc_file, "-o", py_file]) > 0:
4847
self.warn("Unable to compile resource file {}".format(qrc_file))
4948
if not os.path.exists(py_file):
5049
sys.exit(1)
@@ -54,16 +53,21 @@ def compile_rc(self, qrc_file):
5453
sys.stdout.write(line)
5554

5655
def compile_ui(self, ui_file):
57-
from PyQt6 import uic
5856
py_file = os.path.splitext(ui_file)[0] + "_ui.py"
59-
if not newer(ui_file, py_file):
57+
if not self.newer(ui_file, py_file):
6058
return
61-
with open(py_file, "w") as a_file:
62-
uic.compileUi(ui_file, a_file)
59+
uic_exe = self.find_executable("pyuic6")
60+
if uic_exe is None:
61+
self.warn("Unable to find Qt User Interface Compiler (pyuic6)")
62+
sys.exit(1)
63+
if subprocess.call([uic_exe, "-o", py_file, ui_file]) > 0:
64+
self.warn("Unable to compile ui file {}".format(ui_file))
65+
if not os.path.exists(py_file):
66+
sys.exit(1)
6367

6468
def compile_ts(self, ts_file):
6569
qm_file = os.path.splitext(ts_file)[0] + ".qm"
66-
if not newer(ts_file, qm_file):
70+
if not self.newer(ts_file, qm_file):
6771
return
6872
lr_exe = self.find_executable("lrelease")
6973
if lr_exe is None:
@@ -75,26 +79,11 @@ def compile_ts(self, ts_file):
7579
sys.exit(1)
7680

7781
def find_executable(self, name):
78-
from PyQt6.QtCore import QLibraryInfo
7982
path = os.getenv("PATH").split(os.pathsep)
80-
81-
bin_path = QLibraryInfo.path(QLibraryInfo.LibraryPath.BinariesPath)
82-
path.insert(0, bin_path)
83-
os.environ["PATH"] = os.pathsep.join(path)
84-
exe = shutil.which(name)
85-
if exe:
86-
return exe
87-
88-
libexec_path = QLibraryInfo.path(QLibraryInfo.LibraryPath.LibraryExecutablesPath)
89-
path.insert(0, libexec_path)
90-
os.environ["PATH"] = os.pathsep.join(path)
91-
exe = shutil.which(name)
92-
if exe:
93-
return exe
94-
9583
path.extend(["/usr/lib64/qt6/bin", "/usr/lib64/qt6/libexec",
9684
"/usr/lib/qt6/bin", "/usr/lib/qt6/libexec",
9785
"/usr/lib/x86_64-linux-gnu/qt6/bin", "/usr/lib/x86_64-linux-gnu/qt6/libexec"])
86+
9887
os.environ["PATH"] = os.pathsep.join(path)
9988
exe = shutil.which(name)
10089
if exe:
@@ -334,8 +323,8 @@ class CleanLocal(setuptools.Command):
334323

335324
description = "Clean the local project directory"
336325

337-
wildcards = ['*.py[co]', '*_ui.py', '*_rc.py', '__pycache__', '*.qm']
338-
excludedirs = ['.git', 'build', 'dist']
326+
wildcards = ['*.py[co]', '*_ui.py', '*_rc.py', '__pycache__', '*.qm', "build", "*.egg-info"]
327+
excludedirs = ['.git', 'dist']
339328
user_options = []
340329

341330
def initialize_options(self):
@@ -367,30 +356,33 @@ def run(self):
367356
os.remove(a_path)
368357

369358

359+
class BuildCustom(build):
360+
sub_commands = [('build_qt', None)] + build.sub_commands
361+
362+
370363
setuptools.setup(
371-
name="m64py",
372-
version=FRONTEND_VERSION,
373-
description="A frontend for Mupen64Plus",
374-
long_description="A Qt6 front-end (GUI) for Mupen64Plus, a cross-platform plugin-based Nintendo 64 emulator.",
375-
author="Milan Nikolic",
376-
author_email="gen2brain@gmail.com",
377-
license="GNU GPLv3",
378-
url="https://m64py.sourceforge.net",
379-
package_dir={'': "src"},
380-
packages=["m64py", "m64py.core", "m64py.frontend", "m64py.ui"],
381-
scripts=["bin/m64py"],
382-
requires=["PyQt6", "PySDL2"],
383-
platforms=["Linux", "Windows", "Darwin"],
384-
cmdclass={
385-
'build': BuildQt,
364+
name = "m64py",
365+
version = FRONTEND_VERSION,
366+
description = "A frontend for Mupen64Plus",
367+
long_description = "A Qt6 front-end (GUI) for Mupen64Plus, a cross-platform plugin-based Nintendo 64 emulator.",
368+
author = "Milan Nikolic",
369+
author_email = "gen2brain@gmail.com",
370+
license = "GNU GPLv3",
371+
url = "https://m64py.sourceforge.net",
372+
package_dir = {"": "src"},
373+
packages = setuptools.find_namespace_packages(where="src"),
374+
scripts = ["bin/m64py"],
375+
requires = ["PyQt6", "PySDL2"],
376+
cmdclass = {
377+
'build': BuildCustom,
378+
'build_qt': BuildQt,
386379
'build_dmg': BuildDmg,
387380
'build_exe': BuildExe,
388-
'build_qt': BuildQt,
389381
'build_zip': BuildZip,
390382
'clean': CleanLocal
391383
},
392-
data_files=[
393-
("share/pixmaps", ["xdg/m64py.png"]),
394-
("share/applications", ["xdg/m64py.desktop"]),
384+
data_files = [
385+
("share/icons/hicolor/96x96/apps", ["xdg/net.sourceforge.m64py.M64Py.png"]),
386+
("share/applications", ["xdg/net.sourceforge.m64py.M64Py.desktop"]),
395387
]
396388
)

0 commit comments

Comments
 (0)