3 """ Create the Wheel Package """
4 from __future__
import absolute_import
5 from __future__
import unicode_literals
6 from __future__
import print_function
12 from setuptools
import sandbox
15 PATH_HERE = os.path.dirname(os.path.realpath(__file__))
16 PATH_TEMP = os.path.join(PATH_HERE,
"Temp")
17 UNIXLE_EXTENSIONS = [
".py",
".xml",
".json",
".pml",
".txt",
".htm",
".html",
".css"]
18 UNIXLE_EXCLUDED = [
".git",
".dll",
".so",
".pyd",
".dylib"]
21 """ Replace Windows Line Endings with Unix Line Endings """
22 if extensions
is None:
23 extensions = UNIXLE_EXTENSIONS
25 excluded = UNIXLE_EXCLUDED
26 for dname, _dirs, files
in os.walk(folder):
32 fext = os.path.splitext(fname)[-1]
33 if fext
not in extensions
and fname
not in extensions:
35 fpath = os.path.join(dname, fname)
36 with open(fpath,
"rb")
as filer:
40 if "\r\n" not in fdata:
44 with open(fpath,
"wb")
as filew:
45 filew.write(fdata.replace(
"\r\n",
"\n"))
47 print(
"Unix Line Ending : %s" % fpath)
50 """ Remove all sub folders and files by name or extension """
51 if not isinstance(names, list):
53 if not isinstance(extensions, list):
55 for dname, dirs, files
in os.walk(folder):
57 if dirname
not in names:
59 dirpath = os.path.join(dname, dirname)
60 if os.path.isdir(dirpath):
61 if not os.access(dirpath, os.W_OK):
62 os.chmod(dirpath, stat.S_IWRITE)
63 shutil.rmtree(dirpath, ignore_errors=
True)
65 fpath = os.path.join(dname, fname)
67 if os.path.isfile(fpath):
68 if not os.access(fpath, os.W_OK):
69 os.chmod(fpath, stat.S_IWRITE)
71 fext = os.path.splitext(fname)[-1]
72 if fext
in extensions
or fname
in extensions:
73 if os.path.isfile(fpath):
74 if not os.access(fpath, os.W_OK):
75 os.chmod(fpath, stat.S_IWRITE)
79 """ Allow write access to a path """
80 if os.path.isfile(path):
81 if not os.access(path, os.W_OK):
82 os.chmod(path, stat.S_IWRITE)
83 os.chmod(path, stat.S_IWUSR)
84 elif os.path.isdir(path):
85 if not os.access(path, os.W_OK):
86 os.chmod(path, stat.S_IWRITE)
87 os.chmod(path, stat.S_IWUSR)
88 for dname, dirs, files
in os.walk(path):
90 dirpath = os.path.join(dname, dirname)
91 if os.path.isdir(dirpath):
92 if not os.access(dirpath, os.W_OK):
93 os.chmod(dirpath, stat.S_IWRITE)
94 os.chmod(dirpath, stat.S_IWUSR)
96 fpath = os.path.join(dname, fname)
97 if os.path.isfile(fpath):
98 if not os.access(fpath, os.W_OK):
99 os.chmod(fpath, stat.S_IWRITE)
100 os.chmod(fpath, stat.S_IWUSR)
103 """ Prepare the Folders for a platform """
105 path_dist = os.path.join(PATH_HERE,
"dist")
106 if os.path.isdir(path_dist):
107 shutil.rmtree(path_dist, ignore_errors=
True)
108 path_egg = os.path.join(PATH_HERE,
"qicore.egg-info")
109 if os.path.isdir(path_egg):
110 shutil.rmtree(path_egg, ignore_errors=
True)
111 path_build = os.path.join(PATH_HERE,
"build")
112 if os.path.isdir(path_build):
113 shutil.rmtree(path_build, ignore_errors=
True)
114 path_temp = os.path.join(PATH_HERE,
"temp")
115 if os.path.isdir(path_temp):
116 shutil.rmtree(path_temp, ignore_errors=
True)
119 """ Create a Package """
120 print(
"- Clean Access Rights")
122 print(
"- Remove Building Folders")
124 print(
"- Clean .pyc Files")
127 print(
"- Build Package")
128 sandbox.run_setup(os.path.join(PATH_HERE,
"setup.py"), [
"bdist_wheel"])
129 print(
"- Remove Building Folders")
131 print(
"- Package Generation Finished")
133 if __name__ ==
"__main__":