171 |
172 |
172 def copyToFile(name, text): |
173 def copyToFile(name, text): |
173 """ |
174 """ |
174 Copy a string to a file. |
175 Copy a string to a file. |
175 |
176 |
176 @param name the name of the file. |
177 @param name name of the file |
177 @param text the contents to copy to the file. |
178 @type str |
|
179 @param text contents to copy to the file |
|
180 @type str |
178 """ |
181 """ |
179 with open(name, "w") as f: |
182 with open(name, "w") as f: |
180 f.write(text) |
183 f.write(text) |
181 |
184 |
182 |
185 |
183 def copyDesktopFile(src, dst): |
186 def copyDesktopFile(src, dst): |
184 """ |
187 """ |
185 Modify a desktop file and write it to its destination. |
188 Modify a desktop file and write it to its destination. |
186 |
189 |
187 @param src source file name (string) |
190 @param src source file name |
188 @param dst destination file name (string) |
191 @type str |
|
192 @param dst destination file name |
|
193 @type str |
189 """ |
194 """ |
190 global cfg, platBinDir |
195 global cfg, platBinDir |
191 |
196 |
192 with open(src, "r", encoding="utf-8") as f: |
197 with open(src, "r", encoding="utf-8") as f: |
193 text = f.read() |
198 text = f.read() |
206 |
211 |
207 def copyAppStreamFile(src, dst): |
212 def copyAppStreamFile(src, dst): |
208 """ |
213 """ |
209 Modify an appstream file and write it to its destination. |
214 Modify an appstream file and write it to its destination. |
210 |
215 |
211 @param src source file name (string) |
216 @param src source file name |
212 @param dst destination file name (string) |
217 @type str |
|
218 @param dst destination file name |
|
219 @type str |
213 """ |
220 """ |
214 if os.path.exists(os.path.join("eric", "src", "eric7", "UI", "Info.py")): |
221 if os.path.exists(os.path.join("eric", "src", "eric7", "UI", "Info.py")): |
215 # Installing from installer archive |
222 # Installing from installer archive |
216 from eric.src.eric7.UI.Info import Version # noqa: I101, I102 |
223 from eric.src.eric7.UI.Info import Version # noqa: I101, I102 |
217 elif os.path.exists(os.path.join("src", "eric7", "UI", "Info.py")): |
224 elif os.path.exists(os.path.join("src", "eric7", "UI", "Info.py")): |
240 def wrapperNames(dname, wfile): |
247 def wrapperNames(dname, wfile): |
241 """ |
248 """ |
242 Create the platform specific names for the wrapper script. |
249 Create the platform specific names for the wrapper script. |
243 |
250 |
244 @param dname name of the directory to place the wrapper into |
251 @param dname name of the directory to place the wrapper into |
|
252 @type str |
245 @param wfile basename (without extension) of the wrapper script |
253 @param wfile basename (without extension) of the wrapper script |
246 @return the names of the wrapper scripts |
254 @type str |
|
255 @return list containing the names of the wrapper scripts |
|
256 @rtype list of str |
247 """ |
257 """ |
248 wnames = ( |
258 wnames = ( |
249 (dname + "\\" + wfile + ".cmd", dname + "\\" + wfile + ".bat") |
259 [dname + "\\" + wfile + ".cmd", dname + "\\" + wfile + ".bat"] |
250 if sys.platform.startswith(("win", "cygwin")) |
260 if sys.platform.startswith(("win", "cygwin")) |
251 else (dname + "/" + wfile,) |
261 else [dname + "/" + wfile] |
252 ) |
262 ) |
253 |
263 |
254 return wnames |
264 return wnames |
255 |
265 |
256 |
266 |
257 def createPyWrapper(pydir, wfile, saveDir, isGuiScript=True): |
267 def createPyWrapper(pydir, wfile, saveDir, isGuiScript=True): |
258 """ |
268 """ |
259 Create an executable wrapper for a Python script. |
269 Create an executable wrapper for a Python script. |
260 |
270 |
261 @param pydir the name of the directory where the Python script will |
271 @param pydir name of the directory where the Python script will |
262 eventually be installed (string) |
272 eventually be installed |
263 @param wfile the basename of the wrapper (string) |
273 @type str |
264 @param saveDir directory to save the file into (string) |
274 @param wfile basename of the wrapper |
265 @param isGuiScript flag indicating a wrapper script for a GUI |
275 @type str |
266 application (boolean) |
276 @param saveDir directory to save the file into |
267 @return the platform specific name of the wrapper (string) |
277 @type str |
|
278 @param isGuiScript flag indicating a wrapper script for a GUI application |
|
279 @type bool |
|
280 @return the platform specific name of the wrapper |
|
281 @rtype str |
268 """ |
282 """ |
269 # all kinds of Windows systems |
283 # all kinds of Windows systems |
270 if sys.platform.startswith(("win", "cygwin")): |
284 if sys.platform.startswith(("win", "cygwin")): |
271 wname = wfile + ".cmd" |
285 wname = wfile + ".cmd" |
272 if isGuiScript: |
286 if isGuiScript: |
317 """ |
331 """ |
318 Copy Python, translation, documentation, wizards configuration, |
332 Copy Python, translation, documentation, wizards configuration, |
319 designer template files and DTDs of a directory tree. |
333 designer template files and DTDs of a directory tree. |
320 |
334 |
321 @param src name of the source directory |
335 @param src name of the source directory |
|
336 @type str |
322 @param dst name of the destination directory |
337 @param dst name of the destination directory |
|
338 @type str |
323 @param filters list of filter pattern determining the files to be copied |
339 @param filters list of filter pattern determining the files to be copied |
|
340 @type list of str |
324 @param excludeDirs list of (sub)directories to exclude from copying |
341 @param excludeDirs list of (sub)directories to exclude from copying |
|
342 @type list of str |
325 @param excludePatterns list of filter pattern determining the files to |
343 @param excludePatterns list of filter pattern determining the files to |
326 be skipped |
344 be skipped |
|
345 @type list of str |
327 """ |
346 """ |
328 if excludeDirs is None: |
347 if excludeDirs is None: |
329 excludeDirs = [] |
348 excludeDirs = [] |
330 if excludePatterns is None: |
349 if excludePatterns is None: |
331 excludePatterns = [] |
350 excludePatterns = [] |
382 def cleanupSource(dirName): |
401 def cleanupSource(dirName): |
383 """ |
402 """ |
384 Cleanup the sources directory to get rid of leftover files |
403 Cleanup the sources directory to get rid of leftover files |
385 and directories. |
404 and directories. |
386 |
405 |
387 @param dirName name of the directory to prune (string) |
406 @param dirName name of the directory to prune |
|
407 @type str |
388 """ |
408 """ |
389 # step 1: delete all Ui_*.py files without a corresponding |
409 # step 1: delete all Ui_*.py files without a corresponding |
390 # *.ui file |
410 # *.ui file |
391 dirListing = os.listdir(dirName) |
411 dirListing = os.listdir(dirName) |
392 for formName, sourceName in [ |
412 for formName, sourceName in [ |
657 |
677 |
658 def shutilCopy(src, dst, perm=0o644): |
678 def shutilCopy(src, dst, perm=0o644): |
659 """ |
679 """ |
660 Wrapper function around shutil.copy() to ensure the permissions. |
680 Wrapper function around shutil.copy() to ensure the permissions. |
661 |
681 |
662 @param src source file name (string) |
682 @param src source file name |
663 @param dst destination file name or directory name (string) |
683 @type str |
664 @param perm permissions to be set (integer) |
684 @param dst destination file name or directory name |
|
685 @type str |
|
686 @param perm permissions to be set |
|
687 @type int |
665 """ |
688 """ |
666 shutil.copy(src, dst) |
689 shutil.copy(src, dst) |
667 if os.path.isdir(dst): |
690 if os.path.isdir(dst): |
668 dst = os.path.join(dst, os.path.basename(src)) |
691 dst = os.path.join(dst, os.path.basename(src)) |
669 os.chmod(dst, perm) |
692 os.chmod(dst, perm) |
671 |
694 |
672 def installEric(): |
695 def installEric(): |
673 """ |
696 """ |
674 Actually perform the installation steps. |
697 Actually perform the installation steps. |
675 |
698 |
676 @return result code (integer) |
699 @return result code |
|
700 @rtype int |
677 """ |
701 """ |
678 global distDir, doCleanup, cfg, progLanguages, sourceDir, configName |
702 global distDir, doCleanup, cfg, progLanguages, sourceDir, configName |
679 global installApis |
703 global installApis |
680 |
704 |
681 # Create the platform specific wrappers. |
705 # Create the platform specific wrappers. |
1839 def __pyName(py_dir, py_file): |
1863 def __pyName(py_dir, py_file): |
1840 """ |
1864 """ |
1841 Local function to create the Python source file name for the compiled |
1865 Local function to create the Python source file name for the compiled |
1842 .ui file. |
1866 .ui file. |
1843 |
1867 |
1844 @param py_dir suggested name of the directory (string) |
1868 @param py_dir suggested name of the directory |
1845 @param py_file suggested name for the compile source file (string) |
1869 @type str |
1846 @return tuple of directory name (string) and source file name (string) |
1870 @param py_file suggested name for the compile source file |
|
1871 @type str |
|
1872 @return tuple of directory name and source file name |
|
1873 @rtype tuple of (str, str) |
1847 """ |
1874 """ |
1848 return py_dir, "Ui_{0}".format(py_file) |
1875 return py_dir, "Ui_{0}".format(py_file) |
1849 |
1876 |
1850 |
1877 |
1851 def __compileOneUi(ui_path, mapFunc=None): |
1878 def __compileOneUi(ui_path, mapFunc=None): |