This repository has been archived by the owner on May 18, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 19
/
setup.py
93 lines (74 loc) · 2.69 KB
/
setup.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
#! /usr/bin/env python3
# -*- coding: utf-8 -*-
"""Release packaging script for LDR Importer.
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.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software Foundation,
Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
END GPL LICENSE BLOCK
"""
from __future__ import print_function
import os
import sys
import shutil
import distutils.file_util
import distutils.dir_util
from __version__ import version
# Support Python 2 and 3 input
get_input = (input if sys.version_info[:2] >= (3, 0) else raw_input) # noqa
# Required folders
curDir = os.path.dirname(os.path.realpath(__file__))
archivesFolder = os.path.join(curDir, "Archives")
tmpFolder = os.path.join(archivesFolder, "tmp")
blenderFolder = os.path.join(tmpFolder, "io_scene_ldrimporter")
scriptFiles = [
"__init__.py",
"__version__.py",
"import_ldraw.py",
"src/__init__.py",
"src/ldcolors.py",
"src/ldconsole.py",
"src/ldmaterials.py",
"src/ldprefs.py",
"src/extras/__init__.py",
"src/extras/cleanup.py",
"src/extras/gaps.py",
"src/extras/linked_parts.py"
]
proseFiles = [
"README.md",
"LICENSE"
]
print("Creating required folders")
if not os.path.exists(blenderFolder):
os.makedirs(blenderFolder)
# Construct final version number (maj, min, patch) and archive filename
finalVersion = "v{0}.{1}.{2}".format(version[0], version[1], version[2])
archiveFile = "LDR-Importer-{0}".format(finalVersion)
# Copy the script and prose files
print("Copying required files")
for f in scriptFiles:
partDir = os.path.join(blenderFolder, os.path.dirname(f))
distutils.dir_util.create_tree(partDir, f)
distutils.file_util.copy_file(f, partDir)
for f in proseFiles:
distutils.file_util.copy_file(f, blenderFolder)
# Create the release archive
print("Creating release archive")
os.chdir(archivesFolder)
shutil.make_archive(archiveFile, format="zip", root_dir=tmpFolder)
# Clean up
print("Removing temporary files")
os.chdir(curDir)
distutils.dir_util.remove_tree(tmpFolder)
print("\nLDR Importer {0} packaged and saved to\n{1}.zip".format(
finalVersion, os.path.join(archivesFolder, archiveFile)))
get_input("\nPress Enter to close. :) ")
raise SystemExit(0)