arpruss / raspberryjammod

Raspberry Jam Mod - a Mod Forge Minecraft mod implementing most of Raspberry Juice/Pi API
http://www.instructables.com/id/Python-coding-for-Minecraft/
Other
355 stars 95 forks source link

Make the library pip-installable #27

Open aivarannamaa opened 7 years ago

aivarannamaa commented 7 years ago

Thank you for this work!

I want to propose an alternative, Python-centric, way for installing the plugin and the Python library. For users who have Python already installed, this approach could could feel more natural, than current approach.

Once the user has Minecraft and Forge set up, she runs pip install raspberryjam, which dowloads and installs the Python library into current interpreter or virtual environment (instead of .minecraft directory). After this she would execute following commands to download and install the mod:

import raspberryjam
raspberryjam.installMod()

It would be also nice, if the mod allowed specifying the scripts directory for \py game command (so that the user doesn't need to deal with a hidden folder deep under). This could be done either from the mod Config view in Minecraft (which currently crashes the game (1.12)), or by:

import raspberryjam
raspberryjam.setScriptDirectory("C:/Users/Aivar/Minecraft")

(BTW, does \py command currently allow anything else beside running a script in certain directory?)

If you like this proposal but don't have time for implementing it, then I could create the first prototype myself. (You only need to instruct me how to change the script lookup policy inside the mod.)

aivarannamaa commented 7 years ago

Looks like it's possible even to install the mod during pip install: https://stackoverflow.com/questions/20288711/post-install-script-with-python-setuptools

aivarannamaa commented 7 years ago

One may think that pip is too difficult for young beginners to use, but Thonny (http://thonny.org) makes it trivial: http://thonny.org/blog/2017/05/02/version_2_1_0.html

arpruss commented 7 years ago

I don' t know how to make a pip package. :-(

aivarannamaa commented 7 years ago

I made necessary files for creating a pip package: https://github.com/aivarannamaa/raspberryjammod/commit/4f913a3d1aba8526368ebc9daf5096e2f2823cf1

At the moment it cares only about mine module and mcpi package (all demo scripts are ignored).

To create the package in whl format you should change into mcpipy and run

python setup.py bdist_wheel

(you may need to do pip install wheel first). This should create a whl file in dist subfolder. It is actually a zip file so you can easily check its content.

I also made a trial PyPI entry: https://pypi.python.org/pypi/raspberryjammod I can later transfer the permissions to you (or delete it if you want to use another name). I had to increase the version number, because I made a mistake in initial upload and PyPI doesn't let you to change a version once it is uploaded.

You can test it by pip install raspberryjammod. I tested it myself with Python 3.6, but it should be also 2.7-compatible.

I added a convenience function for installing the mod:

from raspberryjammod import install
install()

or

> python -m raspberryjammod install

If you like it, then I can create a pulll-request.

arpruss commented 7 years ago

This is very kind of you, but I am not sure I want to upload something to another location each time I do a release.

And the licensing is weird, too: my stuff is MIT license, but the Mojang API files are under a "do anything other than evil" license which is not compatible with standard open source licenses (not that I want anybody doing evil!).

aivarannamaa commented 7 years ago

You can easily script the uploading just by replacing python setup.py bdist_wheel with python setup.py bdist_wheel upload. You can create .pypirc file to avoid typing passwords for uploading: https://docs.python.org/3.6/distutils/packageindex.html#the-pypirc-file

If you still decide to skip pypi support, do you don't mind if I keep https://pypi.python.org/pypi/raspberryjammod and use this with my students?

arpruss commented 7 years ago

You are certainly free to keep and maintain the pip package as you wish.