-1

I made a game that runs in your terminal using Python and curses. Now I want to launch it so that when people visit the repository on GitHub they can download it and play it on their own machine. I have a Dockerfile but I don't really know if it is necessary. How can other people install my game and have it running without any trouble?

Update:

I published the game with PyPI. You can have a look at it with pip install BirdJumpExtreme==0.0.1. I found this article really helpful: https://www.codementor.io/@ajayagrawal295/how-to-publish-your-own-python-package-12tbhi20tf

Phil
  • 321
  • 1
  • 17

2 Answers2

2

This is a pretty complicated question that can have a lot of possible answers. To start, I'd look into python packaging.

Here is a good guide: https://packaging.python.org/

This will help you get to a point where users can just run pip install . inside your source folder and then be able to run phils_awesome_game from the command line. Or, they could run pip install phils_awesome_game and it would download it from a repository (like https://pypi.org/).

wakey
  • 2,283
  • 4
  • 31
  • 58
  • 1
    Ok I will check it out. Do I even need to Dockerize anything then? – Phil Nov 18 '20 at 12:02
  • 1
    Docker is another packaging method, but it is probably a bit overkill for a pure python package. Docker is useful when your python program needs certain requirements to run, such as a locally installed database/redis/... – wakey Nov 18 '20 at 12:04
  • See here for a docker vs virtualenv comparison: https://dev.to/aaahmedaa/comment/1p8o – wakey Nov 18 '20 at 12:04
  • I didn't use a virtualenv though. Does that make a difference? – Phil Nov 18 '20 at 12:11
  • 2
    If you're not, I would 100% look into it. Virtualenvs are probably the best thing to happen to python in a while, and you will instantly become a better python developer once you have a handle on them. – wakey Nov 18 '20 at 12:13
  • Ok but now its too late to use a virtualenv in a finished project. Can I still use the python packaging style or is docker smarter bc I have that file already finished with all its necessary dependencies. – Phil Nov 18 '20 at 12:15
  • So I have to make my code a package? Is there no way for other people to just clone the repository or something like that – Phil Nov 18 '20 at 14:01
0

You can create your docker image with entrypoint of excecuting python file. For example:

FROM python:3.6
WORKDIR /test
# install requirements
COPY app.py .
ENTRYPOINT python app.py

Then create the image:

docker build . -t game

Now run the game:

docker run -it game
heydar dasoomi
  • 527
  • 1
  • 4
  • 19
  • And how can other people then run this image on their device or rather how can they access my docker build? – Phil Nov 18 '20 at 12:13
  • You can push it on docker hub and people can pull it and run it with `docker run -it imagename` command. – heydar dasoomi Nov 18 '20 at 12:15
  • Can other people access this docker hub also via my GitHub repository bc that's where my code is published? – Phil Nov 18 '20 at 12:16
  • 1
    you can create a Dockerfile in you repository to people them selves create docker image or you can push it on docker hub and add it's link in README.md of your project in github. – heydar dasoomi Nov 18 '20 at 12:18
  • Ahh ok thank you I'll just add the link to the docker image then – Phil Nov 18 '20 at 12:27