Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix CoilSnake's build #297

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .git_archival.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
node: $Format:%H$
node-date: $Format:%cI$
describe-name: $Format:%(describe:tags=true,match=*[0-9]*)$
6 changes: 6 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Required to provide version information to setuptools_scm if someone downloads
# CoilSnake's code as an archive, instead of cloning with git. See
# https://setuptools-scm.readthedocs.io/en/stable/usage/#builtin-mechanisms-for-obtaining-version-numbers
# for more details.
.git_archival.txt export-subst

8 changes: 3 additions & 5 deletions .github/workflows/pyinstaller.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,10 @@ jobs:
python-version: '3.8'
cache: 'pip' # caching pip dependencies
architecture: 'x86'
- name: Install requirements
run: pip install -r requirements.txt
- name: Write build Git commit info
run: python set_git_commit.py --write
- name: Build CoilSnake
run: python setup.py install
run: pip install .
- name: Install PyInstaller
run: pip install pyinstaller
- name: Build .exe
run: python setup_exe.py
- name: Rename .exe
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/.idea
/build
/coilsnake_venv
/dist
/*.egg-info
/.coverage
Expand Down
13 changes: 7 additions & 6 deletions CoilSnake.spec
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,11 @@ run_setup('setup.py', ['build_ext'])

debug = False

sys_platform = sys.platform
if sys_platform == 'win32':
sys_platform = sysconfig.get_platform()
# This logic is specific to setuptools. It may change in future versions, as it did in 62.1.0.
plat_specifier = f'.{sysconfig.get_platform()}-{sys.implementation.cache_tag}'
if sysconfig.get_config_var('Py_GIL_DISABLED'):
plat_specifier += 't'


if len(sys.argv) > 1 and sys.argv[1] == 'debug':
debug = True
Expand All @@ -35,9 +37,8 @@ with open(os.path.join("coilsnake", "assets", "modulelist.txt"), "r") as f:
pyver = '{}.{}'.format(sys.version_info[0], sys.version_info[1])

binaries = [(
'build/lib.{}-{}/coilsnake/util/eb/native_comp.cp*'.format(
sys_platform if sys_platform != 'darwin' else 'macosx',
pyver
'build/lib{}/coilsnake/util/eb/native_comp.cp*'.format(
plat_specifier
),
'coilsnake/util/eb'
)]
Expand Down
51 changes: 28 additions & 23 deletions DEVELOPMENT.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,24 @@

## Environment

Because Python is notorious for being difficult to maintain a clean installation of, it is recommended to develop either in a Python virtualenv or in an actual virtual machine.
Because Python is notorious for being difficult to maintain a clean installation of, it is recommended to develop either in a Python virtual environment or in an actual virtual machine.

### Using a virtualenv
### Using a virtual environment

1. `sudo pip3 install virtualenv`
1. `virtualenv CoilSnake_virtualenv --no-site-packages`
1. `source CoilSnake_virtualenv/bin/activate`
- The above command sets up your CoilSnake virtual development environment. When you open a new terminal for CoilSnake development, always re-run the above command in order to re-enter the virtual development environment. For more information about how this works, see [virtualenv's documentation](https://pypi.python.org/pypi/virtualenv/1.7).
If you're on Windows, whenever a command begins with `python3` below, use `py` instead.

1. Install Python through your package manager or via [Python.org](https://www.python.org/downloads/).
- On Debian-based OSes, run `sudo apt install python3-venv` to install the missing virtual environment support.
1. `python3 -m venv coilsnake_venv`
1. Activate the virtual environment.
- On Windows: `coilsnake_venv\Scripts\activate`
- On other platforms: `source coilsnake_venv/bin/activate`
- You'll know that it works if you see `(coilsnake_venv)` at the beginning of the line for your terminal. When you open a new terminal for CoilSnake development, always re-run the above command in order to re-activate the virtual development environment. For more information about how this works, see [`venv`'s documentation](https://docs.python.org/3/library/venv.html).
1. Follow the steps mentioned below for your respective system.

### Using a virtual machine

For Windows, you'll probably want to follow the steps from a fresh virtual machine. You can start up a new Windows 10 VM by the following command: `vagrant up windows`
For Windows, you have the option to instead follow the steps from a fresh virtual machine. You can start up a new Windows 10 VM by the following command: `vagrant up windows`

To make a Ubuntu VM, you can follow these instructions:

Expand All @@ -26,16 +31,16 @@ cd /vagrant

Please note that the included Vagrant configuration for Ubuntu does not run a GUI, meaning that you won't be able to test CoilSnake's GUI with it.

After installing a VM, follow the steps mentioned below for your respective system ([Linux](#linux)/[Windows](#windows)).
After installing a VM, follow the steps mentioned below for your respective system ([Linux](#linux)/[macOS](#macos)/[Windows](#windows)).

## Linux

1. Install any system dependencies required by CoilSnake. For Debian-based OSes, simply run:

```
sudo apt-get install python3-pip python3-dev g++ libyaml-dev \
python3-tk python3-pil.imagetk \
libjpeg-dev zlib1g-dev tk8.6-dev tcl8.6-dev
sudo apt install python3-pip python3-dev g++ libyaml-dev \
python3-tk python3-pil.imagetk \
libjpeg-dev zlib1g-dev tk8.6-dev tcl8.6-dev
```


Expand All @@ -58,40 +63,40 @@ sudo apt-get install python3-pip python3-dev g++ libyaml-dev \
## Windows

1. Install:
1. [Python 3.9](https://www.python.org/downloads/release/python-392/) (64-bit version)
1. [Python 3.8 or later](https://www.python.org/downloads/)
1. [Visual C++ 2019 Build Tools](https://visualstudio.microsoft.com/thank-you-downloading-visual-studio/?sku=BuildTools&rel=16)
- Select "C++ build tools" under the "Workloads" tab and make sure these are ticked:
1. MSVC v140 - VS 2015 C++ x64/x86 build tools
1. Windows 10 SDK
1. Find a path that exists on your computer similar to `C:\Program Files (x86)\Windows Kits\10\bin\10.0.19041.0\x86` and add it to your system environment variables.
1. Follow the '[Generic](#generic)' instructions below.
1. In commands beginning with `python3` use just `python` instead.
1. In commands beginning with `python3`, use just `py` instead.

## Generic

1. Using your favorite git client, clone the [CoilSnake](https://github.com/pk-hack/CoilSnake) repository.
1. Open the command line and `cd` to your local CoilSnake git repository's main directory.
1. `python3 -m pip install pip==18.1`
1. Install dependencies:
- `python3 setup.py develop`
1. Build additional coilsnake dependencies:
- `python3 setup.py build`
1. `python3 -m pip install --upgrade pip`
1. Use `pip` to install the current package in "editable" or "development" mode:
- `pip3 install -e .`

CoilSnake is now installed in development mode. After making code changes to the source, run your code by launching CoilSnake's GUI or CLI:
CoilSnake is now installed in development mode. After making code changes to the source, run your code by activating the virtual environment (see above) and launching CoilSnake's GUI or CLI:

```
python3 script/gui.py
coilsnake
# or...
python3 script/cli.py
coilsnake-cli
```

### Creating a standalone executable
There are also scripts to launch the GUI and CLI in the `script` folder, with the virtual environment active.

### Creating a standalone Windows executable

Note: The steps for creating a standalone executable are currently unmaintained and likely broken for systems other than 64-bit Windows.

1. Follow the steps above to build CoilSnake for your system.
1. Install pyinstaller:
- `python3 -m pip install pyinstaller`
- `pip3 install pyinstaller`
1. In the CoilSnake source directory, build the CoilSnake executable:
- `python3 setup_exe.py`
1. Run the output file under the 'dist' directory.
3 changes: 2 additions & 1 deletion MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
include README.md
recursive-include coilsnake/assets *
recursive-include coilsnake/assets *
recursive-include coilsnake/util/eb *
16 changes: 7 additions & 9 deletions coilsnake/ui/information.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,9 @@
from importlib.metadata import version

from coilsnake.util.common import project
# In case the file was not properly generated or bundled...
try:
from coilsnake.ui.git_commit import GIT_COMMIT
except:
GIT_COMMIT = None

VERSION = project.VERSION_NAMES[project.FORMAT_VERSION]
if GIT_COMMIT:
VERSION = f"{VERSION}-next-{GIT_COMMIT}"
VERSION = version('coilsnake')
PROJECT_VERSION = project.VERSION_NAMES[project.FORMAT_VERSION]
RELEASE_DATE = "March 19, 2023"

WEBSITE = "http://pk-hack.github.io/CoilSnake"
Expand All @@ -16,6 +12,7 @@
- Contributions by H.S, Michael1, John Soklaski,
João Silva, ShadowOne333, stochaztic, Catador,
cooprocks123e, and many others"""
# TODO: add the actual code dependencies here
DEPENDENCIES = [
{"name": "CoilSnake logo and icon",
"author": "Rydel"},
Expand All @@ -35,12 +32,13 @@
"url": "https://github.com/devinacker/exhal"},
{"name": "EB++",
"author": "Rufus",
"url": "http://goo.gl/BnNqUM"}
"url": "http://goo.gl/BnNqUM"},
]


def coilsnake_about():
description = f"""CoilSnake {VERSION} - {WEBSITE}
Compatible with projects created by Coilsnake version {PROJECT_VERSION}
Created by {AUTHOR}
Released on {RELEASE_DATE}
"""
Expand Down
3 changes: 2 additions & 1 deletion coilsnake/util/common/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
# format. Version numbers are necessary because the format of data files may
# change between versions of CoilSnake.

FORMAT_VERSION = 12
FORMAT_VERSION = 13

# Names for each version, corresponding the the CS version
VERSION_NAMES = {
Expand All @@ -28,6 +28,7 @@
10: "4.0",
11: "4.1",
12: "4.2",
13: "NEXT"
}

# The default project filename
Expand Down
31 changes: 31 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
[build-system]
# 62.1.0 changes the folder layout for built extensions -- we need the new layout
# (Before that, 61 is the first version supporting pyproject.toml.)
requires = ["setuptools >= 62.1", "setuptools-scm"]
build-backend = "setuptools.build_meta"

[project]
name = "coilsnake"
dynamic = ["version"]
description = "CoilSnake"
urls = {Homepage = "https://pk-hack.github.io/CoilSnake"}
requires-python = ">=3.8"
dependencies = [
"Pillow>=3.0.0",
"PyYAML>=3.11",
"CCScriptWriter @ https://github.com/pk-hack/CCScriptWriter/tarball/master",
"ccscript @ https://github.com/charasyn/ccscript_legacy/archive/refs/tags/v1.500.tar.gz",
# ??? CoilSnake hasn't been tested on Mac in a while. Is this still needed?
"pyobjc-framework-Cocoa; platform_system == 'Darwin'",
]

[project.scripts]
coilsnake-cli = "coilsnake.ui.cli:main"
# Comment out the next line to make CoilSnake launch with a terminal window on Windows
[project.gui-scripts]
coilsnake = "coilsnake.ui.gui:main"

[tool.setuptools.packages]
find = {}

[tool.setuptools_scm]
2 changes: 0 additions & 2 deletions requirements.txt

This file was deleted.

37 changes: 0 additions & 37 deletions set_git_commit.py

This file was deleted.

36 changes: 3 additions & 33 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,52 +1,22 @@
#!/usr/bin/env python
#!/usr/bin/env python3

import os
import platform
from setuptools import setup, find_packages
from setuptools import setup
from setuptools.extension import Extension

extra_compile_args = []

if platform.system() != "Windows":
extra_compile_args = ["-std=c99"]

install_requires = [
"Pillow>=3.0.0",
"PyYAML>=3.11",
"CCScriptWriter>=1.2",
"ccscript>=1.500"
]

if platform.system() == "Darwin":
install_requires.append("pyobjc-framework-Cocoa")
extra_compile_args.append("-std=c99")

setup(
name="coilsnake",
version="4.2",
description="CoilSnake",
url="https://pk-hack.github.io/CoilSnake",
packages=find_packages(),
include_package_data=True,

install_requires=install_requires,
dependency_links=[
"https://github.com/Lyrositor/CCScriptWriter/tarball/master#egg=CCScriptWriter-1.2",
"https://github.com/charasyn/ccscript_legacy/archive/refs/tags/v1.500.tar.gz#egg=ccscript-1.500"
],
ext_modules=[
Extension(
"coilsnake.util.eb.native_comp",
["coilsnake/util/eb/native_comp.c", "coilsnake/util/eb/exhal/compress.c"],
extra_compile_args=extra_compile_args,
)
],
entry_points={
"console_scripts": [
"coilsnake = coilsnake.ui.gui:main",
"coilsnake-cli = coilsnake.ui.cli:main"
]
},

test_suite="nose.collector",
tests_require=[
"nose>=1.0",
Expand Down