1{ stdenv
2, lib
3, buildPythonPackage
4, fetchFromGitHub
5, fetchpatch
6, appdirs
7, dungeon-eos
8, explorerscript
9, ndspy
10, pillow
11, setuptools
12, skytemple-rust
13, tilequant
14, pyyaml
15, pmdsky-debug-py
16, typing-extensions
17, pythonOlder
18, # optional dependancies for SpriteCollab
19 aiohttp
20, lru-dict
21, graphql-core
22, gql
23, armips
24 # tests
25, pytestCheckHook
26, parameterized
27, xmldiff
28}:
29
30buildPythonPackage rec {
31 pname = "skytemple-files";
32 version = "1.5.5";
33
34 src = fetchFromGitHub {
35 owner = "SkyTemple";
36 repo = pname;
37 rev = version;
38 hash = "sha256-PVHI3SuXXH+XpSaBhtSUT5I6wYK3WmwW67nJmPLKdg4=";
39 fetchSubmodules = true;
40 };
41
42 patches = [
43 # Necessary for skytemple-files to work with Pillow 10.1.0.
44 # https://github.com/SkyTemple/skytemple-files/issues/449
45 (fetchpatch {
46 url = "https://github.com/SkyTemple/skytemple-files/commit/5dc6477d5411b43b80ba79cdaf3521d75d924233.patch";
47 hash = "sha256-0511IRjOcQikhnbu3FkXn92mLAkO+kV9J94Z3f7EBcU=";
48 includes = ["skytemple_files/graphics/kao/_model.py"];
49 })
50 (fetchpatch {
51 url = "https://github.com/SkyTemple/skytemple-files/commit/9548f7cf3b1d834555b41497cfc0bddab10fd3f6.patch";
52 hash = "sha256-a3GeR5IxXRIKY7I6rhKbOcQnoKxtH7Xf3Wx/BRFQHSc=";
53 })
54 ];
55
56 postPatch = ''
57 substituteInPlace skytemple_files/patch/arm_patcher.py skytemple_files/data/data_cd/armips_importer.py \
58 --replace "exec_name = os.getenv(\"SKYTEMPLE_ARMIPS_EXEC\", f\"{prefix}armips\")" "exec_name = \"${armips}/bin/armips\""
59 '';
60
61 buildInputs = [ armips ];
62
63 propagatedBuildInputs = [
64 appdirs
65 dungeon-eos
66 explorerscript
67 ndspy
68 pillow
69 setuptools
70 skytemple-rust
71 tilequant
72 pyyaml
73 pmdsky-debug-py
74 ] ++ lib.optionals (pythonOlder "3.9") [
75 typing-extensions
76 ];
77
78 passthru.optional-dependencies = {
79 spritecollab = [
80 aiohttp
81 gql
82 graphql-core
83 lru-dict
84 ] ++ gql.optional-dependencies.aiohttp;
85 };
86
87 checkInputs = [ pytestCheckHook parameterized xmldiff ] ++ passthru.optional-dependencies.spritecollab;
88 pytestFlagsArray = [ "test/" ];
89 disabledTestPaths = [
90 "test/skytemple_files_test/common/spritecollab/sc_online_test.py"
91 "test/skytemple_files_test/compression_container/atupx/atupx_test.py" # Particularly long test
92 ];
93
94 pythonImportsCheck = [ "skytemple_files" ];
95
96 meta = with lib; {
97 homepage = "https://github.com/SkyTemple/skytemple-files";
98 description = "Python library to edit the ROM of Pokémon Mystery Dungeon Explorers of Sky";
99 license = licenses.gpl3Plus;
100 maintainers = with maintainers; [ xfix marius851000 ];
101 broken = stdenv.isDarwin; # pyobjc is missing
102 };
103}