บรรจุภัณฑ์ flatpak สำหรับ pygame
Flatpak เป็นระบบบรรจุภัณฑ์แอปพลิเคชัน Sandboxed สำหรับ Linux (เอกสารนักพัฒนา) Pygame เป็นกรอบสำหรับการสร้างเกม
ฉันมุ่งเน้นไปที่การใช้ flatpak-builder กับ JSON ปรากฏตัวมากกว่าเครื่องมือ Python ที่ฉันเริ่มเมื่อปีที่แล้ว แอพที่โฮสต์บน Flathub จะต้องสร้างด้วยวิธีนี้
ไฟล์หลักที่น่าสนใจคือ:
org.pygame.baseapp.jsonorg.pygame.baseapp-py35.jsonorg.pygame.aliens.jsonนี่เป็นเครื่องมือ ทดลอง ในการสร้างแพ็คเกจ Flatpak สำหรับเกม pygame เพื่อใช้:
คุณจะต้องมีระบบ Linux ที่ติดตั้ง flatpak> = 0.8 ที่ติดตั้งเช่น Fedora 25 หรือ Ubuntu 17.10
ติดตั้งโดยใช้ pip install pygame_fpak เครื่องมือต้องการ Python 3 เพื่อเรียกใช้แม้ว่าเกมของคุณจะใช้ Python 2
สร้างไฟล์กำหนดค่า pygame-fpak.toml เช่นนี้:
# At the moment, you can specify "3.6", "3.4" or "2.7".
# 3.6 produces a somewhat bigger app to download.
python = " 3.6 "
# User-visible name
name = " Solarwolf "
# Identifier based on a reverse domain name you control. E.g. if your
# project is on Github, you could use io.github.username.reponame
appid = " org.pygame.solarwolf "
# Files/directories needed to run the game - relative paths from where
# the config file lives.
files = [
" solarwolf "
]
# The function to start your game. This will be called like:
# from solarwolf.cli import main; main()
entry-point = " solarwolf.cli:main "
# Icons in different sizes. Icons should be square, sizes are pixels
# along one side of a square. 32, 48 and 64 are common.
[ icons ]
64 = " dist/solarwolf.png " เรียกใช้ python3 -m pygame_fpak pygame-fpak.toml
รหัสอื่นใน repo นี้สร้างแอพพื้นฐานสำหรับเครื่องมือที่อธิบายไว้ข้างต้น เพื่อสร้างและติดตั้ง:
# Slow, but only needed once:
make install-runtime
# Build the base applications and install them:
make install-baseapp-py36.done
make install-baseapp-py34.done
make install-baseapp-py27.doneแอปพลิเคชันพื้นฐานมีสามแบบ:
-py36 รวม Python 3.6 AS /app/bin/python3 นี่คือการดาวน์โหลดประมาณ 30 MIB และ 140 MIB เมื่อติดตั้ง ตัวอย่าง มนุษย์ต่างดาว ถูกสร้างขึ้นโดยค่าเริ่มต้น-py34 ใช้ Python 3.4 ซึ่งจัดทำโดย freedesktop.org runtime สิ่งนี้ทำให้เล็กลง - ประมาณ 7 MIB ในการดาวน์โหลดและติดตั้ง MIB 40 ตัว - แต่คุณไม่สามารถใช้คุณสมบัติ Python ล่าสุดในรหัสของคุณได้py27 ใช้ Python 2.7 มันมีขนาดใกล้เคียงกับแอพ Python 3.4แอปพลิเคชัน Flatpak ใช้ รันไทม์ ชุดของไลบรารีทั่วไปและปฏิบัติการ หากแอปพลิเคชันของคุณเป็นคนแรกที่ผู้ใช้ติดตั้งด้วยรันไทม์ที่กำหนด Flatpak จะดาวน์โหลดรันไทม์เช่นกัน หวังว่าแอพส่วนใหญ่จะแบ่งปันรันไทม์ไม่กี่ครั้งเพื่อให้การติดตั้งนั้นรวดเร็วและรวดเร็ว