Skip to content

Commit cc932d4

Browse files
committed
version MacOS
1 parent e374238 commit cc932d4

File tree

8 files changed

+201
-5
lines changed

8 files changed

+201
-5
lines changed

.DS_Store

6 KB
Binary file not shown.

data/Music bot.icns

1.35 MB
Binary file not shown.

lprof/add-one-hover.svg

Lines changed: 32 additions & 0 deletions
Loading

lprof/add-one.svg

Lines changed: 1 addition & 0 deletions
Loading

lprof/refresh.svg

Lines changed: 36 additions & 0 deletions
Loading

main-macos.spec

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
# -*- mode: python ; coding: utf-8 -*-
2+
3+
4+
a = Analysis(
5+
['main.py'],
6+
pathex=[],
7+
binaries=[],
8+
datas=[('data/add-one-hover.svg', 'data'),
9+
('data/add-one.svg', 'data'),
10+
('data/close-one-hover.svg', 'data'),
11+
('data/close-one.svg', 'data'),
12+
('data/Music bot.png','data'),
13+
('data/reduce-one-hover.svg','data'),
14+
('data/reduce-one.svg','data'),
15+
('data/refresh-1.svg','data'),
16+
('data/refresh.svg','data'),
17+
('data/shuffle.svg','data'),
18+
('data/volume-down.svg','data'),
19+
('data/volume-mute.svg','data'),
20+
('data/volume-notice.svg','data'),
21+
('data/volume-up.svg','data'),
22+
('data/edit-add.svg','data'),
23+
('data/edit-clear.svg','data'),
24+
('data/Music bot.icns','data'),
25+
('./.env','.')
26+
],
27+
hiddenimports=[
28+
'PIL', 'PIL.Image'
29+
'pydub', 'PyQt5', 'numpy', 'pygame', 'qasync', 'mutagen', 'pyimgur', 'dotenv', 'pyqtgraph', 'pypresence'
30+
],
31+
hookspath=[],
32+
hooksconfig={},
33+
runtime_hooks=[],
34+
excludes=[],
35+
noarchive=False,
36+
)
37+
pyz = PYZ(a.pure)
38+
39+
exe = EXE(
40+
pyz,
41+
a.scripts,
42+
[],
43+
exclude_binaries=True,
44+
name='BIT_SCRIPTS_-_Musique',
45+
debug=False,
46+
bootloader_ignore_signals=False,
47+
strip=False,
48+
upx=True,
49+
console=False,
50+
disable_windowed_traceback=False,
51+
argv_emulation=False,
52+
target_arch=None,
53+
codesign_identity=None,
54+
entitlements_file=None,
55+
)
56+
coll = COLLECT(
57+
exe,
58+
a.binaries,
59+
a.datas,
60+
strip=False,
61+
upx=True,
62+
upx_exclude=[],
63+
name='BIT_SCRIPTS_-_Musique',
64+
)
65+
app = BUNDLE(
66+
coll,
67+
name='BIT_SCRIPTS_-_Musique.app',
68+
icon='data/Music bot.icns',
69+
bundle_identifier=None,
70+
)
71+
72+
## Make app bundle double-clickable
73+
import plistlib
74+
from pathlib import Path
75+
app_path = Path(app.name)
76+
77+
# read Info.plist
78+
with open(app_path / 'Contents/Info.plist', 'rb') as f:
79+
pl = plistlib.load(f)
80+
81+
# write Info.plist
82+
with open(app_path / 'Contents/Info.plist', 'wb') as f:
83+
pl['CFBundleExecutable'] = 'wrapper'
84+
plistlib.dump(pl, f)
85+
86+
# write new wrapper script
87+
shell_script = """#!/bin/bash
88+
dir=$(dirname $0)
89+
open file://${dir}/%s &> /dev/null &""" % app.appname
90+
with open(app_path / 'Contents/MacOS/wrapper', 'w') as f:
91+
f.write(shell_script)
92+
93+
# make it executable
94+
(app_path / 'Contents/MacOS/wrapper').chmod(0o755)

main.py

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import platform
2-
if platform.system() == 'Linux':
2+
if platform.system() == 'Linux' or platform.system() == 'Darwin':
33
import subprocess
44
elif platform.system() == 'Windows':
55
import psutil
@@ -8,6 +8,7 @@
88
import sys
99
import os
1010
import random
11+
from pathlib import Path
1112
import numpy as np
1213
from pydub import AudioSegment
1314
from PyQt5.QtWidgets import QMainWindow, QApplication, QWidget, QLabel, QPushButton, QVBoxLayout, QSlider, QHBoxLayout, QFileDialog, QListWidget
@@ -31,14 +32,22 @@
3132
from dotenv import load_dotenv
3233

3334
# Charge les variables d'environnement du fichier .env
34-
extDataDir = os.getcwd()
35+
extDataDir = None
3536
if getattr(sys, 'frozen', False):
36-
extDataDir = sys._MEIPASS
37+
# Chemin lorsqu'exécuté en tant que bundle .app avec PyInstaller
38+
if platform.system() == 'Darwin': # macOS
39+
extDataDir = Path(sys.executable).parent.parent / "Resources"
40+
else:
41+
extDataDir = sys._MEIPASS
42+
else:
43+
# Chemin pour le mode de développement
44+
extDataDir = os.getcwd()
45+
3746
load_dotenv(dotenv_path=os.path.join(extDataDir, '.env'))
3847

3948
def is_discord_running():
4049
# Cette fonction vérifie si Discord est en cours d'exécution sur l'ordinateur
41-
if platform.system() == 'Linux':
50+
if platform.system() == 'Linux' or platform.system() == 'Darwin':
4251
try:
4352
# Remplacer par la méthode appropriée pour votre système d'exploitation
4453
process = subprocess.check_output(["pgrep", "Discord"])
@@ -159,7 +168,10 @@ def __init__(self):
159168

160169
if getattr(sys, 'frozen', False):
161170
# Exécuté en mode binaire
162-
self.application_path = sys._MEIPASS
171+
if platform.system() == 'Darwin': # macOS
172+
self.application_path = Path(sys.executable).parent.parent / "Resources"
173+
else:
174+
self.application_path = sys._MEIPASS
163175
else:
164176
# Exécuté en mode script
165177
self.application_path = os.path.dirname(os.path.abspath(__file__))

requirements-mac.txt

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
PyQt5
2+
PyQt5-Qt5
3+
PyQt5-sip
4+
PyQt5-stubs
5+
pyqt5-tools
6+
pyqtgraph
7+
pygame
8+
pydub
9+
mutagen
10+
numpy
11+
pypresence
12+
aiodns
13+
fire
14+
pycares
15+
qasync
16+
asyncio
17+
pyimgur
18+
requests
19+
python-dotenv
20+
psutil
21+
Pillow

0 commit comments

Comments
 (0)