Skip to content

Commit

Permalink
Migrate to pyproject.toml (#624)
Browse files Browse the repository at this point in the history
* Migrate to pyproject.toml

* Fix Windows Version replacement

* Windows: yq
  • Loading branch information
theCapypara authored Sep 29, 2023
1 parent 1ebaf8d commit 6b96b4e
Show file tree
Hide file tree
Showing 13 changed files with 116 additions and 163 deletions.
25 changes: 17 additions & 8 deletions .github/workflows/build-test-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,16 +57,19 @@ jobs:
runs-on: ubuntu-latest
name: Build the Python wheel
steps:
# For tags we assume the version in setup.py is correct!
# For tags we assume the version in pyproject.toml is correct!
- name: Checkout
uses: actions/checkout@v4
- name: Rewrite version for dev if not tag
if: "!startsWith(github.ref, 'refs/tags/')"
run: |
perl -i -pe "s/__version__\s*=\s*'(.*?)(\.rc.*|\.a.*|\.post.*)?'/__version__='\1.dev0+${GITHUB_SHA::8}'/" setup.py
perl -i -pe "s/version\s*=\s*\"(.*?)(\.rc.*|\.a.*|\.post.*)?\"/version=\"\1.dev0+${GITHUB_SHA::8}\"/" pyproject.toml
- name: Note version
run: |
echo "PACKAGE_VERSION=$(python3 -- ./setup.py --version)" >> $GITHUB_ENV
echo "PACKAGE_VERSION=$(tomlq '.project.version' pyproject.toml -r)" >> $GITHUB_ENV
- name: Build localization MO files
run: |
installer/generate-mo.sh
- name: Build Python wheels
uses: RalfG/[email protected]_x86_64
with:
Expand Down Expand Up @@ -161,12 +164,16 @@ jobs:
Move-Item "C:\Program Files\Git\notbin" "C:\Program Files\Git\bin"
- name: Rewrite version for dev if not tag
if: "!startsWith(github.ref, 'refs/tags/')"
shell: sh
run: |
perl -i -pe "s/__version__\s*=\s*'(.*?)(\.rc.*|\.a.*|\.post.*)?'/__version__='\1.dev0+$($env:GITHUB_SHA.Substring(0,8))'/" setup.py
echo "IS_DEV_BUILD=1" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
perl -i -pe "s/version\s*=\s*\"(.*?)(\.rc.*|\.a.*|\.post.*)?\"/version=\"\1.dev0+${GITHUB_SHA::8}\"/" pyproject.toml
echo "IS_DEV_BUILD=1" >> $GITHUB_ENV
- name: Note version
run: |
$env:PACKAGE_VERSION = python -- ./setup.py --version
$env:path = "C:\pipx_bin;" + $env:path
pipx install yq
$env:PACKAGE_VERSION = tomlq.exe '.project.version' pyproject.toml -r
echo "PACKAGE_VERSION=$env:PACKAGE_VERSION" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
- name: Install SkyTemple
run: |
Expand Down Expand Up @@ -212,11 +219,11 @@ jobs:
- name: Rewrite version for dev if not tag
if: "!startsWith(github.ref, 'refs/tags/')"
run: |
perl -i -pe "s/__version__\s*=\s*'(.*?)(\.rc.*|\.a.*|\.post.*)?'/__version__='\1.dev0+${GITHUB_SHA::8}'/" setup.py
perl -i -pe "s/version\s*=\s*\"(.*?)(\.rc.*|\.a.*|\.post.*)?\"/version=\"\1.dev0+${GITHUB_SHA::8}\"/" pyproject.toml
echo "IS_DEV_BUILD=1" >> $GITHUB_ENV
- name: Note version
run: |
echo "PACKAGE_VERSION=$(python3 -- ./setup.py --version)" >> $GITHUB_ENV
echo "PACKAGE_VERSION=$(tomlq '.project.version' pyproject.toml -r)" >> $GITHUB_ENV
- name: Install and package
run: |
# git is already installed.
Expand All @@ -231,6 +238,8 @@ jobs:
IS_MACOS=1 installer/install-skytemple-rust.sh x86_64
fi
pip3 install -r requirements-mac-windows.txt
# Generate MO localization files
installer/generate-mo.sh
pip3 install '.[eventserver]'
if [ -n "$IS_DEV_BUILD" ]; then
installer/install-skytemple-components-from-git.sh
Expand Down
26 changes: 0 additions & 26 deletions BUILDING_MACOS.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,29 +83,3 @@ Follow the instructions for end-users, but instead of Step 4, continue with this
# Run ExplorerScript test export/import script (warning, hardcoded to my machine by default. The other packages have similar debug scripts):
python3 -m skytemple_files.script.ssb.dbg.export_explorerscript_test
```


### Building binary dependencies
These are the instructions on how you can compile the binary dependencies of SkyTemple yourself.

#### skytemple_rust
1. Make sure you have a Rust toolchain (nightly) setup.
2. Clone https://github.com/SkyTemple/skytemple-rust.git
3. Run `pip3 install -r dev-requirements.txt `
3. Run `python3 setup.py build_ext`
3. Run `pip3 install -e . `

#### py-desmume
1. Make sure you have the GNU build tools installed (Autoconf, Automake, Libtool) and some additional dependencies:
``brew install coreutils libtool automake sdl``
1. Add the binaries without the ``g`` prefix to the ``PATH``:
```
export PATH="/usr/local/opt/coreutils/libexec/gnubin:$PATH"
# Also for glibtool - You can do this more elegant via an extra directory if you want!
# Just setting LIBTOOL won't work!
sudo ln -s $(which glibtool) /usr/local/opt/coreutils/libexec/gnubin/libtool
```
2. Clone https://github.com/SkyTemple/py-desmume
3. Run `pip3 install -r dev-requirements.txt `
3. Run `python3 setup.py build`
3. Run `pip3 install -e . `
5 changes: 5 additions & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
recursive-include skytemple *.css
recursive-include skytemple *.glade
recursive-include skytemple *.mo
graft skytemple/data
include skytemple/py.typed
3 changes: 1 addition & 2 deletions docs/plugin_dev.rst
Original file line number Diff line number Diff line change
Expand Up @@ -157,8 +157,7 @@ it can be empty. In this example the ``module.py`` contains the module:
def depends_on(cls) -> List[str]:
"""
This returns a list of modules that your plugin needs. This can be another plugin module
or one of the built-in modules, which are listed in SkyTemple's setup.py
(or in the future it's pyproject.toml).
or one of the built-in modules, which are listed in SkyTemple's pyproject.toml.
You can reference these other modules and rely on functionality in them.
"""
Expand Down
3 changes: 3 additions & 0 deletions installer/build-windows.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ pip install --force-reinstall (Resolve-Path C:\gtk-build\build\x64\release\pycai
# Install certifi for cert handling
pip install -U certifi

# Generate MO localization files
bash .\generate-mo.sh

# install SkyTemple
pip install -r ../requirements-mac-windows.txt
pip install '..[eventserver]'
Expand Down
5 changes: 5 additions & 0 deletions installer/generate-mo.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/usr/bin/env bash
set -e
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )

find $SCRIPT_DIR/../skytemple/data/locale -iname "*.po" -exec sh -c 'msgfmt -o "${1%.po}.mo" "$1"' sh {} \;
85 changes: 85 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
[build-system]
requires = ["setuptools"]
build-backend = "setuptools.build_meta"

[project]
name = "skytemple"
version = "1.6.0b1"
authors = [
{name = 'Marco "Capypara" Köpcke', email = "[email protected]"},
# see About dialog or GitHub contributors list for additional people.
]
description = "GUI Application to edit the ROM of Pokémon Mystery Dungeon Explorers of Sky"
readme = "README.rst"
requires-python = ">=3.8"
keywords = ["rom hacking", "game modding", "skytemple", "gtk"]
license = {text = "GPL-3.0-or-later"}
classifiers = [
"Development Status :: 4 - Beta",
"Programming Language :: Python",
"License :: OSI Approved :: GNU General Public License v3 or later (GPLv3+)",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
]
dependencies = [
"ndspy >= 3.0.0",
"skytemple-files[spritecollab] >= 1.6.0b1, < 1.7.0",
"pmdsky-debug-py", # Whatever version skytemple-files requires.
"skytemple-dtef >= 1.6.0a3, < 1.7.0",
"skytemple-icons >= 1.3.2, < 1.7.0",
"range-typed-integers >= 1.0.0",
"pygobject >= 3.26.0",
"pycairo >= 1.16.0",
"natsort >= 7.0.0",
"tilequant >= 1.0.0",
"skytemple-ssb-debugger >= 1.6.0b1, < 1.7.0",
"pygal >= 2.4.0",
"CairoSVG >= 2.4.2",
"gbulb >= 0.6.2",
"psutil >= 5.9.0",
"sentry-sdk >= 1.5",
"packaging",
"wheel",
"importlib_metadata>=4.6; python_version < '3.10'"
]

[project.urls]
Homepage = "https://skytemple.org"
Announcements = "https://blog.skytemple.org"
Documentation = "https://wiki.skytemple.org"
Downloads = "https://download.skytemple.org/skytemple"
Changelog = "https://download.skytemple.org/skytemple"
Repository = "https://github.com/SkyTemple/skytemple.git"
Issues = "https://github.com/SkyTemple/skytemple/issues"
Discord = "https://discord.gg/skytemple"

[project.optional-dependencies]
discord = ["pypresence >= 4.2.1"]
eventserver = ["skytemple-eventserver >= 1.6.0, < 1.7.0"]

[project.scripts]
skytemple = "skytemple.main:main"

[project.entry-points."skytemple.module"]
rom = "skytemple.module.rom.module:RomModule"
bgp = "skytemple.module.bgp.module:BgpModule"
tiled_img = "skytemple.module.tiled_img.module:TiledImgModule"
map_bg = "skytemple.module.map_bg.module:MapBgModule"
script = "skytemple.module.script.module:ScriptModule"
gfxcrunch = "skytemple.module.gfxcrunch.module:GfxcrunchModule"
sprite = "skytemple.module.sprite.module:SpriteModule"
monster = "skytemple.module.monster.module:MonsterModule"
portrait = "skytemple.module.portrait.module:PortraitModule"
patch = "skytemple.module.patch.module:PatchModule"
lists = "skytemple.module.lists.module:ListsModule"
moves_items = "skytemple.module.moves_items.module:MovesItemsModule"
misc_graphics = "skytemple.module.misc_graphics.module:MiscGraphicsModule"
dungeon = "skytemple.module.dungeon.module:DungeonModule"
dungeon_graphics = "skytemple.module.dungeon_graphics.module:DungeonGraphicsModule"
strings = "skytemple.module.strings.module:StringsModule"
spritecollab = "skytemple.module.spritecollab.module:SpritecollabModule"

[tool.setuptools.packages.find]
exclude = ["installer", "docs"]
122 changes: 0 additions & 122 deletions setup.py

This file was deleted.

1 change: 0 additions & 1 deletion skytemple/data/locale/de

This file was deleted.

1 change: 0 additions & 1 deletion skytemple/data/locale/es

This file was deleted.

1 change: 0 additions & 1 deletion skytemple/data/locale/fr

This file was deleted.

1 change: 0 additions & 1 deletion skytemple/data/locale/pt

This file was deleted.

1 change: 0 additions & 1 deletion skytemple/data/locale/zh

This file was deleted.

0 comments on commit 6b96b4e

Please sign in to comment.