Skip to content

Commit

Permalink
feat: pypi packaging (#119)
Browse files Browse the repository at this point in the history
  • Loading branch information
cheahjs committed Feb 3, 2024
1 parent 0b648c1 commit 01d61e3
Show file tree
Hide file tree
Showing 38 changed files with 288 additions and 45 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/package.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: Package files
on: [push]
jobs:
package:
package-windows-zip:
permissions:
contents: write
runs-on: ubuntu-latest
Expand All @@ -15,8 +15,8 @@ jobs:
mkdir -p dist
cp LICENSE dist/
cp README.md dist/
cp *.py dist/
cp -r lib dist/
cp palworld_save_tools/commands/convert.py dist/
cp -r palworld_save_tools dist/
cp convenience_tools/* dist/
cd dist
zip -r ../palworld-save-tools-windows-${{steps.ghd.outputs.describe}}.zip *
Expand Down
27 changes: 27 additions & 0 deletions .github/workflows/publish.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: Publish
on:
release:
types: [published]

jobs:
publish:
runs-on: ubuntu-latest
permissions:
id-token: write
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: 3.12
- name: Install dependencies
run: |
pip install -r requirements-dev.txt
pip install hatch
- name: Build package
run: hatch build
- name: Test package
run: hatch run test:run
- name: Publish package to PyPi
uses: pypa/gh-action-pypi-publish@release/v1
161 changes: 161 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,164 @@ localtest
/legacy
__pycache__
*.prof

# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class

# C extensions
*.so

# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
share/python-wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST

# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
.nox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
*.py,cover
.hypothesis/
.pytest_cache/
cover/

# Translations
*.mo
*.pot

# Django stuff:
*.log
local_settings.py
db.sqlite3
db.sqlite3-journal

# Flask stuff:
instance/
.webassets-cache

# Scrapy stuff:
.scrapy

# Sphinx documentation
docs/_build/

# PyBuilder
.pybuilder/
target/

# Jupyter Notebook
.ipynb_checkpoints

# IPython
profile_default/
ipython_config.py

# pyenv
# For a library or package, you might want to ignore these files since the code is
# intended to run in multiple environments; otherwise, check them in:
# .python-version

# pipenv
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
# However, in case of collaboration, if having platform-specific dependencies or dependencies
# having no cross-platform support, pipenv may install dependencies that don't work, or not
# install all needed dependencies.
#Pipfile.lock

# poetry
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
# This is especially recommended for binary packages to ensure reproducibility, and is more
# commonly ignored for libraries.
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
#poetry.lock

# pdm
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
#pdm.lock
# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
# in version control.
# https://pdm.fming.dev/#use-with-ide
.pdm.toml

# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
__pypackages__/

# Celery stuff
celerybeat-schedule
celerybeat.pid

# SageMath parsed files
*.sage.py

# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/

# Spyder project settings
.spyderproject
.spyproject

# Rope project settings
.ropeproject

# mkdocs documentation
/site

# mypy
.mypy_cache/
.dmypy.json
dmypy.json

# Pyre type checker
.pyre/

# pytype static type analyzer
.pytype/

# Cython debug symbols
cython_debug/

# PyCharm
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
# and can be added to the global gitignore or merged into this file. For a more nuclear
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
#.idea/
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,16 @@ Additional command line arguments:
1. `--minify-json`: Minify output JSON to help speed up processing by other tools consuming JSON
1. `--force`: Overwrite output files if they exist without prompting

## Developers

This library is available on PyPi, and can be installed with

```shell
pip install palworld-save-tools
```

> [!NOTE]
> Due to ongoing rapid development and the potential for breaking changes, the recommendation is to pin to a specific version, and take updates as necessary.
## Roadmap

Expand Down
14 changes: 14 additions & 0 deletions hatch.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
[version]
source = "vcs"

[build.targets.sdist]
exclude = ["/.github", "/convenience_tools"]

[build.targets.wheel]
packages = ["palworld_save_tools"]

[envs.test]
dependencies = ["parameterized"]

[envs.test.scripts]
run = "python -m unittest -v"
File renamed without changes.
File renamed without changes.
File renamed without changes.
8 changes: 4 additions & 4 deletions convert.py → palworld_save_tools/commands/convert.py
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
import json
import os

from lib.gvas import GvasFile
from lib.json_tools import CustomEncoder
from lib.palsav import compress_gvas_to_sav, decompress_sav_to_gvas
from lib.paltypes import PALWORLD_CUSTOM_PROPERTIES, PALWORLD_TYPE_HINTS
from palworld_save_tools.gvas import GvasFile
from palworld_save_tools.json_tools import CustomEncoder
from palworld_save_tools.palsav import compress_gvas_to_sav, decompress_sav_to_gvas
from palworld_save_tools.paltypes import PALWORLD_CUSTOM_PROPERTIES, PALWORLD_TYPE_HINTS


def main():
Expand Down
7 changes: 5 additions & 2 deletions resave_test.py → palworld_save_tools/commands/resave_test.py
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,11 @@
# This scripts takes a .sav file as input, and runs through the sav > JSON > sav process to ensure that the output is the same as the input.
import sys

from convert import convert_json_to_sav, convert_sav_to_json
from lib.palsav import decompress_sav_to_gvas
from palworld_save_tools.commands.convert import (
convert_json_to_sav,
convert_sav_to_json,
)
from palworld_save_tools.palsav import decompress_sav_to_gvas


def main():
Expand Down
2 changes: 1 addition & 1 deletion lib/gvas.py → palworld_save_tools/gvas.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import base64
from typing import Any, Callable

from lib.archive import FArchiveReader, FArchiveWriter
from palworld_save_tools.archive import FArchiveReader, FArchiveWriter


def custom_version_reader(reader: FArchiveReader):
Expand Down
2 changes: 1 addition & 1 deletion lib/json_tools.py → palworld_save_tools/json_tools.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import json
import uuid

from lib.archive import UUID
from palworld_save_tools.archive import UUID


class CustomEncoder(json.JSONEncoder):
Expand Down
File renamed without changes.
4 changes: 2 additions & 2 deletions lib/paltypes.py → palworld_save_tools/paltypes.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from typing import Any, Callable

from lib.archive import FArchiveReader, FArchiveWriter
from lib.rawdata import (
from palworld_save_tools.archive import FArchiveReader, FArchiveWriter
from palworld_save_tools.rawdata import (
base_camp,
build_process,
character,
Expand Down
Empty file.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from typing import Any, Sequence

from lib.archive import *
from palworld_save_tools.archive import *


def decode(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from typing import Any, Sequence

from lib.archive import *
from palworld_save_tools.archive import *

NO_OP_TYPES = [
"EPalBaseCampModuleType::Energy",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from typing import Any, Sequence

from lib.archive import *
from palworld_save_tools.archive import *


def decode(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from typing import Any, Sequence

from lib.archive import *
from palworld_save_tools.archive import *


def decode(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from typing import Any, Sequence

from lib.archive import *
from palworld_save_tools.archive import *


def decode(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from typing import Any, Sequence

from lib.archive import *
from palworld_save_tools.archive import *


def decode(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from typing import Any

from lib.archive import *
from palworld_save_tools.archive import *


def decode(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from typing import Any, Sequence

from lib.archive import *
from palworld_save_tools.archive import *


def decode(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from typing import Any, Sequence

from lib.archive import *
from palworld_save_tools.archive import *


def decode(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from typing import Any, Sequence

from lib.archive import *
from palworld_save_tools.archive import *


def decode(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from typing import Sequence

from lib.archive import *
from palworld_save_tools.archive import *


def decode(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from typing import Any, Sequence

from lib.archive import *
from palworld_save_tools.archive import *


def decode(
Expand Down
Loading

0 comments on commit 01d61e3

Please sign in to comment.