[PYTHON] The story of making a tool that runs on Mac and Windows at the game development site

Conclusion

I chose the Python language, and the difficulty of building the environment was high, so I ended up operating it at a very high cost for maintenance and expansion.

Background

At work I had to create a tool that would work on Mac and Windows. So I chose Python, which can be easily executed from the terminal (command line) of my Mac machine.

This tool synthesizes and outputs a lot of game icon images. The designer creates the icon material, and the Python program outputs a large number of icons while referring to the data on Google Sheets. (Finally, this icon image will be combined into one in the form of Atlas in Unity's NGUI, and it will end as multiple Atlas)

Problems other than Python

The first thing I learned from using Python this time is the difficulty of building an environment. And, rather than the convenience of a language that does not require build (compilation), there was also a lack of thought about source code control. After all, at first I was only doing simple image composition, so I passed the management of this tool to the designer by zipping the Python source code that ran on my Mac local instead of svn. Because of that, I didn't think that I would have such a hard time later, such as having to prepare a bat file and even a windows machine to check if Python works properly on windows.

Why I chose Python

I think Python is a very good language. There are already many libraries, and there are libraries for image editing as well, and it is a language that many programmers can handle.

This is because there is no need to build, and there is also the advantage that local data such as Path and file name required for each environment where the tool is used can be written directly in the Python source code and edited.

And the advantage of being able to execute a single file from the command line. Another factor in choosing Python was the lack of the idea of being able to cross-compile to Mac / Windows because it started with a really small program as a realistic task.

Python problems faced

The problem with the Python program I made this time is that I need to have a designer who is not a programmer take the time to build an environment such as a library on a machine that runs because it does not require compilation, and I instruct to build that environment ・ This is a point that I had to do.

Now I think I should have chosen a language that can be cross-compiled.

First of all, I wrote Python on a Mac, ran the Python file from the terminal, confirmed that it worked, then zipped it and handed it to the designer via chat. But when I pass it, it doesn't work on Windows. I receive reports of situations and errors in chat and respond, but it does not work at all. Eventually I walked to the designer's seat and checked the program. This interrupted his work and delayed his other implementations.

When I followed the error, I couldn't find the library on my Mac. Certainly there was no Python Imaging Library (PIL) at that time. This guy was really annoying.

First of all, as a solution $ brew install pil I remember spending hours investigating the work that only needed to be done, and having the various libraries introduced in vain. (It's like having some kind of library compiled with gcc ...) This work was really hard.

Google spreadsheet

Next is the CSV download from Google Sheets. Initially, the item data was referenced from the master data on the game project managed by Unity's Asset Server (Unity's own version control system). However, when the development of the next version is decided, the branch of the project will be newly cut to svn, and the master data referenced so far will be out of date. So to keep the item up to date, I (fortunately) decided to refer to a Google Sheets that is always up to date. I use a Python library called gspread to browse Google Spreadsheets.

I decided to ask the designer to write the google account and its password directly in the bat file that calls Python. And since I was still exchanging with zip, the designer committed zip to svn without my knowledge. This will keep his account and password on svn for the rest of his life, and anyone who can check out this zip file can hijack his account.

I had my password changed.

And because of the danger and gspread's deprecation of email addresses and passwords, OAuth support was needed. Yes, it was no longer a "little program". I skipped it, but of course I had to build gspread in the designer's environment, which was very difficult for me.

And this program is still being maintained and expanded. I'd like to switch quickly, but I haven't been able to devote time to the problem. (Various bad programmers ...)

Future challenges and gains

The mission of this program has always been to reduce the workload of designers. So I'd like to run it from UnityEditor and do an Atlas import, but that's not done all the time due to lack of study and lack of time. I'm not a tool programmer. You also have to implement the game.

However, what I got from this case was very big. A strength that can be executed from the command line by Python. Also, it was found that the burden and management on the execution environment are reduced because the compiled program does not require a library environment. I think this was a very important discovery and experience for me.

And above all, I think I need other inexperienced programmers like myself. If the execution environment of the program you are trying to create spans multiple operating systems, I hope this article will be helpful.

Recommended Posts

The story of making a tool that runs on Mac and Windows at the game development site
The story of making a box that interconnects Pepper's AL Memory and MQTT
A tool that automatically turns the gacha of a social game
A memo that reproduces the slide show (gadget) of Windows 7 on Windows 10.
The story of creating a site that lists the release dates of books
The story of making a module that skips mail with python
The story of making a sound camera with Touch Designer and ReSpeaker
The story of making a package that speeds up the operation of Juman (Juman ++) & KNP
Introducing youtube-dl, a video download tool that runs on the command line, and its zsh completion function.
The story of making a lie news generator
The story of making a mel icon generator
The story of IPv6 address that I want to keep at a minimum
The story of making a web application that records extensive reading with Django
The story of making a Line Bot that tells us the schedule of competitive programming
Introduced "Glances" command, a monitoring tool that can be understood at a glance, on Mac
A story that reduces the effort of operation / maintenance
CodePicnic that can create a [Development | Run | Tutorial | Demo] environment that runs on the browser
The story of making a music generation neural network
A story that analyzed the delivery of Nico Nama.
A rough summary of the differences between Windows and Linux
The story of making a question box bot with discord.py
I tried to make a script that traces the tweets of a specific user on Twitter and saves the posted image at once
The story of releasing a Python text check tool on GitHub x CircleCI for the first time
[First personal development] The story of deploying the Flask app and Twitter's automatic reply bot on Heroku
The story of making a standard driver for db with python.
[Windows] A story of a beginner who stumbles on Anaconda's PATH setting.
A python script that deletes ._DS_Store and ._ * files created on Mac
For the time being, the one who creates a homepage with Django at the speed of a second and publishes it on Heroku (Windows compatible)
The story of making a slackbot that outputs as gif or png when you send the processing code
The story of making a tool to load an image with Python ⇒ save it as another name
The story of writing a program
Let's take a look at the Scapy code. Overload of special methods __div__, __getitem__ and so on.
A story about trying to run JavaScripthon on Windows and giving up.
The story of making a university 100 yen breakfast LINE bot with Python
The story of having a hard time introducing OpenCV with M1 MAC
The story of the escape probability of a random walk on an integer grid
A python script for Mac that zips without garbled characters on Windows
Summarize the titles of Hottentori at the end and look at the present on the Web
The story of creating Botonyan that returns the contents of Google Docs in response to a specific keyword on Slack
Prepare a development environment that is portable and easy to duplicate without polluting the environment with Python embeddable (Windows)
This and that of the inclusion notation.
The story of making Python an exe
The story of making an immutable mold
The story of trying deep3d and losing
The story of blackjack A processing (python)
[pyqtgraph] Understand SignalProxy and create a crosshair that follows the cursor on the graph
The story of creating (probably) the smallest skill that implements personalization and in-skill billing
How to access the contents of a Linux disk on a Mac (but read-only)
Separately install a version of Python that is not pre-installed on your Mac
[Python] A program that calculates the number of updates of the highest and lowest records
[Hackathon] About making a tool that can be CD on Raspberry Pi [Convenient tool]