Skip to content

Commit

Permalink
version MacOS
Browse files Browse the repository at this point in the history
  • Loading branch information
Paullux committed Jan 21, 2024
1 parent e374238 commit cc932d4
Show file tree
Hide file tree
Showing 8 changed files with 201 additions and 5 deletions.
Binary file added .DS_Store
Binary file not shown.
Binary file added data/Music bot.icns
Binary file not shown.
32 changes: 32 additions & 0 deletions lprof/add-one-hover.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions lprof/add-one.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
36 changes: 36 additions & 0 deletions lprof/refresh.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
94 changes: 94 additions & 0 deletions main-macos.spec
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
# -*- mode: python ; coding: utf-8 -*-


a = Analysis(
['main.py'],
pathex=[],
binaries=[],
datas=[('data/add-one-hover.svg', 'data'),
('data/add-one.svg', 'data'),
('data/close-one-hover.svg', 'data'),
('data/close-one.svg', 'data'),
('data/Music bot.png','data'),
('data/reduce-one-hover.svg','data'),
('data/reduce-one.svg','data'),
('data/refresh-1.svg','data'),
('data/refresh.svg','data'),
('data/shuffle.svg','data'),
('data/volume-down.svg','data'),
('data/volume-mute.svg','data'),
('data/volume-notice.svg','data'),
('data/volume-up.svg','data'),
('data/edit-add.svg','data'),
('data/edit-clear.svg','data'),
('data/Music bot.icns','data'),
('./.env','.')
],
hiddenimports=[
'PIL', 'PIL.Image'
'pydub', 'PyQt5', 'numpy', 'pygame', 'qasync', 'mutagen', 'pyimgur', 'dotenv', 'pyqtgraph', 'pypresence'
],
hookspath=[],
hooksconfig={},
runtime_hooks=[],
excludes=[],
noarchive=False,
)
pyz = PYZ(a.pure)

exe = EXE(
pyz,
a.scripts,
[],
exclude_binaries=True,
name='BIT_SCRIPTS_-_Musique',
debug=False,
bootloader_ignore_signals=False,
strip=False,
upx=True,
console=False,
disable_windowed_traceback=False,
argv_emulation=False,
target_arch=None,
codesign_identity=None,
entitlements_file=None,
)
coll = COLLECT(
exe,
a.binaries,
a.datas,
strip=False,
upx=True,
upx_exclude=[],
name='BIT_SCRIPTS_-_Musique',
)
app = BUNDLE(
coll,
name='BIT_SCRIPTS_-_Musique.app',
icon='data/Music bot.icns',
bundle_identifier=None,
)

## Make app bundle double-clickable
import plistlib
from pathlib import Path
app_path = Path(app.name)

# read Info.plist
with open(app_path / 'Contents/Info.plist', 'rb') as f:
pl = plistlib.load(f)

# write Info.plist
with open(app_path / 'Contents/Info.plist', 'wb') as f:
pl['CFBundleExecutable'] = 'wrapper'
plistlib.dump(pl, f)

# write new wrapper script
shell_script = """#!/bin/bash
dir=$(dirname $0)
open file://${dir}/%s &> /dev/null &""" % app.appname
with open(app_path / 'Contents/MacOS/wrapper', 'w') as f:
f.write(shell_script)

# make it executable
(app_path / 'Contents/MacOS/wrapper').chmod(0o755)
22 changes: 17 additions & 5 deletions main.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import platform
if platform.system() == 'Linux':
if platform.system() == 'Linux' or platform.system() == 'Darwin':
import subprocess
elif platform.system() == 'Windows':
import psutil
Expand All @@ -8,6 +8,7 @@
import sys
import os
import random
from pathlib import Path
import numpy as np
from pydub import AudioSegment
from PyQt5.QtWidgets import QMainWindow, QApplication, QWidget, QLabel, QPushButton, QVBoxLayout, QSlider, QHBoxLayout, QFileDialog, QListWidget
Expand All @@ -31,14 +32,22 @@
from dotenv import load_dotenv

# Charge les variables d'environnement du fichier .env
extDataDir = os.getcwd()
extDataDir = None
if getattr(sys, 'frozen', False):
extDataDir = sys._MEIPASS
# Chemin lorsqu'exécuté en tant que bundle .app avec PyInstaller
if platform.system() == 'Darwin': # macOS
extDataDir = Path(sys.executable).parent.parent / "Resources"
else:
extDataDir = sys._MEIPASS
else:
# Chemin pour le mode de développement
extDataDir = os.getcwd()

load_dotenv(dotenv_path=os.path.join(extDataDir, '.env'))

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

if getattr(sys, 'frozen', False):
# Exécuté en mode binaire
self.application_path = sys._MEIPASS
if platform.system() == 'Darwin': # macOS
self.application_path = Path(sys.executable).parent.parent / "Resources"
else:
self.application_path = sys._MEIPASS
else:
# Exécuté en mode script
self.application_path = os.path.dirname(os.path.abspath(__file__))
Expand Down
21 changes: 21 additions & 0 deletions requirements-mac.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
PyQt5
PyQt5-Qt5
PyQt5-sip
PyQt5-stubs
pyqt5-tools
pyqtgraph
pygame
pydub
mutagen
numpy
pypresence
aiodns
fire
pycares
qasync
asyncio
pyimgur
requests
python-dotenv
psutil
Pillow

0 comments on commit cc932d4

Please sign in to comment.