minolin / acplugins

R&D about the upcoming server plugin infrastrucure of Assetto Corsa, driving simulator by Kunos simulazioni
Apache License 2.0
18 stars 4 forks source link

Add the python-server api plugin to pypi #5

Closed hgross closed 9 years ago

hgross commented 9 years ago

Would be really nice to have the great python plugin versioned on pypi. If you need help with this, contact me.

never-eat-yellow-snow commented 9 years ago

TBH I'm not sure about this one. In my opinion it would be better to include the python plugin code into the plugin itself and use it as a package there (it's just a very small layer with a neglectable amount of files).

hgross commented 9 years ago

For the scope of ac client plugins I totally agree with you. But for every other python application it makes sense to have this api in a central repository (since ad hoc reuse is almost always a bad idea). Think of server side applications or other desktop apps using the server api.

never-eat-yellow-snow commented 9 years ago

I don't get the point why this way of packaging should be a bad idea:

my_server_plugin_root

and in main.py you use it like this

from acpugins4python import ac_server_plugin

I agree it's a good idea to have the plugin itself shared via pypi, but from my point of view, the plugin really wants to control the API version it is using.

hgross commented 9 years ago

Yes, as I mentioned: For the ac client plugin scope it is all fine. No contradiction with your argument.

But I was talking about standalone python applications (not plugins) interfacing with the server. btw: A python application can still require a specific version of a PyPi package (and therefore api version). So there shouldn't be any loss of control.

never-eat-yellow-snow commented 9 years ago

I was also talking about standalone, server-side python applications, not about the client. I just don't see the advantage of having the plugin distributed over PyPi instead of just including the three python modules inside of the application (yet?).

hgross commented 9 years ago

Imagine you have a bunch of dependencies for your server-side python app and you copied all of them manually from a git repo to your project. If now this bunch gets obsolete with a new AC Server version (1.2.x, 1.3, ..) you have to manually check all of the git(hub) repos for updates, and copy them all over again. If they were published in the central PyPi repo a simple pip install -U module1, module2 would do this for you (without forcing you to manually check, if a new version is available in the github repos).

Sure, they are just three simple python files, but it's about the process. I understand that this might look like overkill at first sight but it definitely comes with some considerable advantages.

never-eat-yellow-snow commented 9 years ago

OK, I don't want to block this :) If you'd be willing to take care of the deployment, I'd be fine with that. Not sure how much effort this is? Would be cool, if the deployment could be done with a script.

I think we should at least add some version information to the plugin then (this is a good idea anyways).

hgross commented 9 years ago

The whole publish process is well defined and supported by pip. A typical publish to PyPi is done with a single command:

python setup.py register sdist upload

This command

To upload to PyPi you need to be registered (it is free): https://pypi.python.org/pypi?%3Aaction=register_form

I can upload it for you but I guess you want to keep control of the package. Alternativley I can provide you the setup.py and all initially needed files to get it going so you can publish it easily.

Versioning is included in the PyPi conventions - see this example setup.py which should be sufficient to publish to PyPi:

from setuptools import setup

setup(name='ac-server-api',
      version='0.1',
      description='Python api layer for Assetto Corsa\'s UDP server API. Developed and tested with ACServer 1.2',
      url='https://github.com/minolin/acplugins',
      author='Minolin',
      author_email='email@example.com',
      license='MIT',
      packages=['acserver'], # put the three files (plus an empty __init__.py) into a folder "acserver"
      zip_safe=False)

You can optionally include a README.rst which is then rendered at PyPi. See my package: https://pypi.python.org/pypi/speedwise-node If you download and unzip it, you can check the setup.py and everything - but the example above should enable you to publish to PyPi right away. It is really not that much effort needed to get going.

Another short and good example of the PyPi/pip mechanics can be found here: http://www.scotttorborg.com/python-packaging/minimal.html

never-eat-yellow-snow commented 9 years ago

OK, uploaded version 0.1 to pypi (acplugins4python). Would you please have a look and tell me if that's OK from your side?

hgross commented 9 years ago

Just tested it. Works fine, thank you! Off-topic: A little hint in README.md on how to enable the acServer's UDP ports in the server.cfg might be helpful.

never-eat-yellow-snow commented 9 years ago

Thanks for testing. Regarding README: when I have some spare time... Things are a bit busy right now. I think I can close this now... (just uploaded 0.3 to pypi with new API version)