Skip to content

Commit

Permalink
Create package.py
Browse files Browse the repository at this point in the history
  • Loading branch information
FLO-2DKaren authored Oct 10, 2023
1 parent 94f5cb4 commit 19c70c6
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions package.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# FLO-2D Preprocessor tools for QGIS
# Copyright © 2021 Lutra Consulting for FLO-2D

# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version
import os
import re
import shutil
import subprocess


def get_plugin_version(directory):
metadata = os.path.join(directory, "metadata.txt")
reg = "\nversion=(.+)\n"
version = ""
with open(metadata, "r") as f:
match = re.search(reg, f.read())
if match:
version = match.group(1)
return version


if __name__ == "__main__":
print("Creating plugin package...")
this_dir = os.path.dirname(os.path.realpath(__file__))
plugin_dirname = "rasterizor"
plugin_path = os.path.join(this_dir, plugin_dirname)
print("Zipping plugin package...")
plugin_version = get_plugin_version(plugin_path)
zip_filename = f"{plugin_dirname}-{plugin_version}"
plugin_zip_path = os.path.join(this_dir, zip_filename)
shutil.make_archive(plugin_zip_path, "zip", this_dir, plugin_dirname)
print(f"Creating plugin package '{zip_filename}' finished.")

0 comments on commit 19c70c6

Please sign in to comment.