diff --git a/images/dupeguru.icns b/images/dupeguru.icns new file mode 100755 index 00000000..6641a6b4 Binary files /dev/null and b/images/dupeguru.icns differ diff --git a/macos.md b/macos.md new file mode 100644 index 00000000..871cbb70 --- /dev/null +++ b/macos.md @@ -0,0 +1,53 @@ +## How to build dupeGuru for macos + +### Prerequisites + +- [Python 3.6+][python] +- [Xcode 12.3][xcode] or just Xcode command line tools (older versions can be used if not interested in arm macs) +- [Homebrew][homebrew] +- [qt5](https://www.qt.io/) + +#### Prerequisite setup +1. Install Xcode if desired +2. Install [Homebrew][homebrew], if not on the path after install (arm based Macs) create `~/.zshrc` +with `export PATH="/opt/homebrew/bin:$PATH"`. Will need to reload terminal or source the file to take +affect. +3. Install qt5 with `brew`. If you are using a version of macos without system python 3.6+ then you will +also need to install that via brew or with pyenv. + + $ brew install qt5 + + NOTE: Using `brew` to install qt5 is to allow pyqt5 to build without a native wheel + available. If you are using an intel based mac you can probably skip this step. + +4. May need to launch a new terminal to have everything working. + +### With build.py +OSX comes with a version of python 3 by default in newer versions of OSX. To produce universal +builds either the 3.8 version shipped in macos or 3.9.1 or newer needs to be used. If needing to +build pyqt5 from source then the first line below is needed, else it may be omitted. (Path shown is +for an arm mac.) + + $ export PATH="/opt/homebrew/opt/qt/bin:$PATH" + $ cd + $ python3 -m venv ./env + $ source ./env/bin/activate + $ pip install -r requirements.txt + $ python build.py + $ python run.py + +### Generate OSX Packages +The extra requirements need to be installed to run packaging: `pip install -r requirements-extra.txt`. +Run the following in the respective virtual environment. + + $ python package.py + +This will produce a dupeGuru.app in the dist folder. + +### Running tests +The complete test suite can be run with tox just like on linux. NOTE: The extra requirements need to +be installed to run unit tests: `pip install -r requirements-extra.txt`. + +[python]: http://www.python.org/ +[homebrew]: https://brew.sh/ +[xcode]: https://developer.apple.com/xcode/ \ No newline at end of file diff --git a/package.py b/package.py index aa876b36..867bd6a7 100644 --- a/package.py +++ b/package.py @@ -210,6 +210,31 @@ def package_windows(): ) print_and_do(cmd.format(version_array[0], version_array[1], version_array[2], bits)) +def package_macos(): + # include locale files if they are built otherwise exit as it will break + # the localization + if not op.exists("build/locale"): + print("Locale files are missing. Have you run \"build.py --loc\"? Exiting...") + return + # include help files if they are built otherwise exit as they should be included? + if not op.exists("build/help"): + print("Help files are missing. Have you run \"build.py --doc\"? Exiting...") + return + # run pyinstaller from here: + import PyInstaller.__main__ + + PyInstaller.__main__.run( + [ + "--name=dupeguru", + "--windowed", + "--noconfirm", + "--icon=images/dupeguru.icns", + "--osx-bundle-identifier=com.hardcoded-software.dupeguru", + "--add-data=build/locale:locale", + "--add-data=build/help:help", + "run.py", + ] + ) def main(): args = parse_args() @@ -220,6 +245,8 @@ def main(): print("Packaging dupeGuru with UI qt") if sys.platform == "win32": package_windows() + elif sys.platform == "darwin": + package_macos() else: if not args.arch_pkg: distname = distro.id() diff --git a/requirements-extra.txt b/requirements-extra.txt index c7eedf21..85a0240e 100644 --- a/requirements-extra.txt +++ b/requirements-extra.txt @@ -2,4 +2,4 @@ pytest>=5,<6 flake8 tox-travis black -pyinstaller>=4.0,<5.0; sys_platform == 'win32' \ No newline at end of file +pyinstaller>=4.0,<5.0; sys_platform != 'linux' \ No newline at end of file diff --git a/requirements.txt b/requirements.txt index ad9a4f74..0d1b8c10 100644 --- a/requirements.txt +++ b/requirements.txt @@ -3,5 +3,5 @@ sphinx>=1.2.2 polib>=1.0.4 hsaudiotag3k>=1.1.3* distro>=1.5.0 -PyQt5 >=5.4,<6.0; sys_platform == 'win32' +PyQt5 >=5.4,<6.0; sys_platform != 'linux' pywin32>=200; sys_platform == 'win32' \ No newline at end of file