Switch to pip install punyverse.

This commit is contained in:
Quantum 2018-08-22 02:00:32 -04:00
parent 0fea259382
commit aa9bd685ef
6 changed files with 101 additions and 108 deletions

7
MANIFEST.in Normal file
View file

@ -0,0 +1,7 @@
include MANIFEST.in
include LICENSE
include README.md
include punyverse/world.json
graft punyverse/assets
include punyverse/*.c
exclude punyverse/*.pyx

View file

@ -3,36 +3,19 @@ punyverse
Python simulator of a puny universe. (How many words can I stick into one?) Python simulator of a puny universe. (How many words can I stick into one?)
![Punyverse Preview](https://quantum2.xyz/wp-content/uploads/2017/07/punyverse.png) ![Punyverse Preview](https://guanzhong.ca/assets/projects/punyverse-c91f1cb1415c2922c5dcdf9773bc8d86e52e86e1c1b01d33a0969af7b669b8c4.png)
Installation Installation
------------ ------------
To install, simply clone this repository, or download a copy [here](https://github.com/quantum5/punyverse/archive/master.zip). Currently, only Python 2 on Windows is supported.
After that, download the [launcher](https://github.com/quantum5/punyverse/releases/download/launcher0.4/launcher.exe), To install, run `pip install punyverse`.
put it into the repository directory and let it unpack in your repository (or copy).
You may start playing any time by running `punyverse.exe`, or `punyverse_debug.exe` if you desire a console. Then, run `punyverse` to launch the simulator, or `punyversew` to launch without the console.
### A Note on Textures ### A Note on Textures
If your graphics card doesn't support the massive texture sizes this module comes with, you can shrink them. If your graphics card doesn't support the massive texture sizes this module comes with, you can shrink them.
You can run `small_images.exe` (or `small_images.py`, if you have python) to generate smaller versions of To do this, run `punyverse_small_images`.
shipped textures, which requires either `PIL` or `pgmagick` to process the images.
### Advanced Install
If you wish to use your own python installation, to run `punyverse`, you can clone the code.
Here are the things you need:
* Python 2.7, I have no Python 2.6 install to test this.
* a C compiler to compile `_model.c` and `_glgeom.c`
* requires OpenGL headers and libraries.
* not really necessary, but it runs way faster with these.
* install `pyglet`
After getting the dependencies done, you can now run the `punyverse` module using `python -mpunyverse`.
See above if you run into texture issues.

View file

@ -1,40 +0,0 @@
import pyglet
import json
import os
import sys
import uuid
import imp
import argparse
def load_dll(dir, module):
name = 'punyverse.' + module
path = os.path.join(dir, 'punyverse', module + '.pyd')
if not os.path.exists(path):
path = os.path.join(dir, 'punyverse.%s.pyd' % module)
if not os.path.exists(path):
raise ImportError('No module named %s' % module)
return imp.load_dynamic(name, path)
if __name__ == '__main__':
try:
dir = os.path.dirname(sys.executable)
if sys.frozen == 'windows_exe':
sys.stderr = open(os.path.join(dir, 'punyverse.log'), 'a')
except AttributeError:
sys.exit('This is only meant to be ran frozen.')
sys.path.insert(0, dir)
try:
import punyverse
except ImportError:
pass
# Model indirectly depends on _glgeom to handle textures
load_dll(dir, '_glgeom')
# Model path needs special handling
_model = load_dll(dir, '_model')
_model.model_base = os.path.join(dir, 'punyverse', 'assets', 'models')
with open('punyverse\__main__.py', 'r') as code:
exec(code)

View file

@ -1,29 +0,0 @@
from distutils.core import setup
import py2exe
from glob import glob
import sys
import os
import shutil
if len(sys.argv) < 2:
sys.argv.append('py2exe')
parent = os.path.dirname(__file__)
join = os.path.join
setup(
console=[{'dest_base': 'punyverse_debug', 'script': 'bootloader.py'}, 'small_images.py'],
windows=[{'dest_base': 'punyverse', 'script': 'bootloader.py'}],
options={'py2exe': {
'unbuffered': True, 'optimize': 2,
'excludes': [
'_ssl', 'unittest', 'doctest', 'PIL', 'email', 'distutils',
'pyglet.window.carbon', 'pyglet.window.xlib',
'pyglet.media.drivers.alsa',
'win32wnet', 'netbios', 'pgmagick'
],
'includes': ['punyverse._model', 'punyverse._glgeom'],
'dll_excludes': ['MPR.dll', 'w9xpopen.exe'],
}
}
)

View file

@ -39,7 +39,7 @@ try:
def save(image, file): def save(image, file):
image.write(file) image.write(file)
except ImportError: except ImportError:
import Image from PIL import Image
def get_image(image): def get_image(image):
return Image.open(image) return Image.open(image)
@ -97,19 +97,8 @@ textures = [
'moons/mimas.jpg', 'moons/mimas.jpg',
] ]
def frozen():
import imp
return (hasattr(sys, 'frozen') or # new py2exe
hasattr(sys, 'importers') # old py2exe
or imp.is_frozen('__main__')) # tools/freeze
def get_main_dir():
if frozen():
return os.path.dirname(sys.executable)
return os.path.dirname(__file__)
def main(): def main():
punyverse = os.path.join(get_main_dir(), 'punyverse') punyverse = os.path.dirname(__file__)
try: try:
with open(os.path.join(punyverse, 'assets', 'textures.txt')) as f: with open(os.path.join(punyverse, 'assets', 'textures.txt')) as f:
files = [i.strip() for i in f if not i.startswith('#') and i.strip()] files = [i.strip() for i in f if not i.startswith('#') and i.strip()]

83
setup.py Normal file
View file

@ -0,0 +1,83 @@
from __future__ import print_function
import sys
import os
from setuptools import setup, Extension
has_pyx = os.path.exists(os.path.join(os.path.dirname(__file__), 'punyverse', '_glgeom.pyx'))
try:
from Cython.Build import cythonize
except ImportError:
if has_pyx:
print('You need to install cython first before installing punyverse.', file=sys.stderr)
print('Run: pip install cython', file=sys.stderr)
print('Or if you do not have pip: easy_install cython', file=sys.stderr)
sys.exit(1)
cythonize = lambda x: x
if has_pyx:
pyx_path = lambda x: x
else:
pyx_path = lambda x: x.replace('.pyx', '.c')
with open(os.path.join(os.path.dirname(__file__), 'README.md')) as f:
long_description = f.read()
setup(
name='punyverse',
version='0.1',
packages=['punyverse'],
package_data={
'punyverse': [
'world.json',
'assets/textures.txt',
'assets/textures/*.jpg',
'assets/textures/*.png',
'assets/textures/moons/*',
'assets/models/asteroids/*',
'assets/models/satellites/*.mtl',
'assets/models/satellites/*.obj',
'assets/models/satellites/*.jpg',
'assets/models/satellites/*.png',
'assets/models/satellites/cassini/*',
],
},
ext_modules=cythonize([
Extension('punyverse._glgeom', sources=[pyx_path('punyverse/_glgeom.pyx')], libraries=['opengl32']),
Extension('punyverse._model', sources=[pyx_path('punyverse/_model.pyx')], libraries=['opengl32']),
]),
entry_points={
'console_scripts': [
'punyverse = punyverse.__main__:main',
'punyverse_small_images = punyverse.small_images:main',
],
'gui_scripts': [
'punyversew = punyverse.__main__:main'
]
},
install_requires=['pyglet', 'Pillow'],
author='quantum',
author_email='quantum2048@gmail.com',
url='https://github.com/quantum5/punyverse',
description='Python simulator of a puny universe.',
long_description=long_description,
long_description_content_type='text/markdown',
keywords='universe simulator',
classifiers=[
'Development Status :: 4 - Beta',
'Environment :: Win32 (MS Windows)',
'Intended Audience :: End Users/Desktop',
'License :: OSI Approved :: GNU General Public License v2 (GPLv2)',
'Operating System :: Microsoft :: Windows',
'Programming Language :: Python',
'Topic :: Games/Entertainment :: Simulation',
'Topic :: Multimedia :: Graphics :: 3D Rendering',
'Topic :: Scientific/Engineering :: Visualization',
],
)