setup.py

branch
setup.py
changeset 6951
ef3e87580dc9
parent 6950
62e39a353cd9
child 6958
949c3c76cc8a
equal deleted inserted replaced
6950:62e39a353cd9 6951:ef3e87580dc9
13 import os 13 import os
14 import sys 14 import sys
15 import subprocess 15 import subprocess
16 import shutil 16 import shutil
17 import fnmatch 17 import fnmatch
18 import datetime
18 19
19 from setuptools import setup, find_packages 20 from setuptools import setup, find_packages
20 from distutils.command.install_data import install_data
21 21
22 ###################################################################### 22 ######################################################################
23 ## some helper functions below 23 ## some helper functions below
24 ###################################################################### 24 ######################################################################
25
25 26
26 def getVersion(): 27 def getVersion():
27 """ 28 """
28 Function to get the version from file. 29 Function to get the version from file.
29 30
35 # assume it is a version info starting with year 36 # assume it is a version info starting with year
36 version = sys.argv[-1] 37 version = sys.argv[-1]
37 del sys.argv[-1] 38 del sys.argv[-1]
38 else: 39 else:
39 # calculate according our version scheme (year.month) 40 # calculate according our version scheme (year.month)
40 import datetime
41 today = datetime.date.today() 41 today = datetime.date.today()
42 version = "{0}.{1}".format(today.year - 2000, today.month) 42 version = "{0}.{1}".format(today.year - 2000, today.month)
43 return version 43 return version
44 44
45 45
61 os.path.splitext(fname)[1] in extensions: 61 os.path.splitext(fname)[1] in extensions:
62 filesList.append( 62 filesList.append(
63 os.path.relpath(os.path.join(dirpath, fname), package)) 63 os.path.relpath(os.path.join(dirpath, fname), package))
64 return filesList 64 return filesList
65 65
66
66 def getDataFiles(): 67 def getDataFiles():
67 """ 68 """
68 Return data_files in a platform dependent manner 69 Return data_files in a platform dependent manner.
70
71 @return list containing the platform specific data files
72 @rtype list of tuples of (str, list of str)
69 """ 73 """
70 if sys.platform.startswith('linux'): 74 if sys.platform.startswith('linux'):
71 dataFiles = [ 75 dataFiles = [
72 ('share/applications', [ 76 ('share/applications', [
73 'linux/eric6.desktop', 77 'linux/eric6.desktop',
89 else: 93 else:
90 dataFiles = [] 94 dataFiles = []
91 return dataFiles 95 return dataFiles
92 96
93 ###################################################################### 97 ######################################################################
94 ## make Linux detect eric6 desktop files
95 ######################################################################
96
97 class Eric6InstallDataWrapper(install_data):
98 """
99 Class providing an install_data command wrapper to perform
100 post-installation tasks.
101 """
102 def run(self):
103 """
104 Public method to perform the data installation.
105 """
106 # do the distutils install_data first
107 install_data.run(self)
108
109 # now perform our post installation stuff
110 if sys.platform.startswith('linux'):
111 try:
112 subprocess.call(['update-desktop-database'])
113 except:
114 print("ERROR: unable to update desktop database",
115 file=sys.stderr)
116
117 CmdClass = {
118 'install_data': Eric6InstallDataWrapper,
119 }
120
121 ######################################################################
122 ## functions to prepare the sources for building 98 ## functions to prepare the sources for building
123 ###################################################################### 99 ######################################################################
124 100
101
125 def prepareInfoFile(fileName, version): 102 def prepareInfoFile(fileName, version):
126 """ 103 """
127 Function to prepare an Info.py file when installing from source. 104 Function to prepare an Info.py file.
128 105
129 @param fileName name of the Python file containing the info (string) 106 @param fileName name of the Python file containing the info (string)
130 @param version version string for the package (string) 107 @param version version string for the package (string)
131 """ 108 """
132 if not fileName: 109 if not fileName:
156 f.close() 133 f.close()
157 else: 134 else:
158 shutil.copy(fileName + ".orig", fileName) 135 shutil.copy(fileName + ".orig", fileName)
159 136
160 137
138 def prepareAppdataFile(fileName, version):
139 """
140 Function to prepare a .appdata.xml file.
141
142 @param fileName name of the .appdata.xml file (string)
143 @param version version string for the package (string)
144 """
145 if not fileName:
146 return
147
148 try:
149 os.rename(fileName, fileName + ".orig")
150 except EnvironmentError:
151 pass
152 f = open(fileName + ".orig", "r", encoding="utf-8")
153 text = f.read()
154 f.close()
155 text = text.replace("@VERSION@", version)\
156 .replace("@DATE@", datetime.date.today().isoformat())
157 f = open(fileName, "w")
158 f.write(text)
159 f.close()
160
161
161 def cleanupSource(dirName): 162 def cleanupSource(dirName):
162 """ 163 """
163 Cleanup the sources directory to get rid of leftover files 164 Cleanup the sources directory to get rid of leftover files
164 and directories. 165 and directories.
165 166
223 ###################################################################### 224 ######################################################################
224 225
225 Version = getVersion() 226 Version = getVersion()
226 sourceDir = os.path.join(os.path.dirname(__file__), "eric6") 227 sourceDir = os.path.join(os.path.dirname(__file__), "eric6")
227 infoFileName = os.path.join(sourceDir, "UI", "Info.py") 228 infoFileName = os.path.join(sourceDir, "UI", "Info.py")
229 appdataFileName = os.path.join(os.path.dirname(__file__), "linux",
230 "eric6.appdata.xml")
228 if sys.argv[1].startswith("bdist"): 231 if sys.argv[1].startswith("bdist"):
229 # prepare the sources under "eric6" for building the wheel file 232 # prepare the sources under "eric6" for building the wheel file
230 print("preparing the sources...") 233 print("preparing the sources...") # __IGNORE_WARNING_M801__
231 cleanupSource(sourceDir) 234 cleanupSource(sourceDir)
232 compileUiFiles(sourceDir) 235 compileUiFiles(sourceDir)
233 prepareInfoFile(infoFileName, Version) 236 prepareInfoFile(infoFileName, Version)
234 print("Preparation finished") 237 prepareAppdataFile(appdataFileName, Version)
238 print("Preparation finished") # __IGNORE_WARNING_M801__
235 239
236 setup( 240 setup(
237 name="eric6", 241 name="eric6",
238 version=Version, 242 version=Version,
239 description="eric6 is an integrated development environment for the" 243 description="eric6 is an integrated development environment for the"
240 " Python language.", 244 " Python language.",
241 long_description="eric6 is an integrated development environment for the" 245 long_description="eric6 is an integrated development environment for the"
242 " Python language. It uses the PyQt5 bindings and the QScintilla2" 246 " Python language. It uses the PyQt5 bindings and the"
243 " editor widget. See https://eric-ide.python-projects.org for more" 247 " QScintilla2 editor widget. See"
244 " details.", 248 " https://eric-ide.python-projects.org for more details.",
245 author="Detlev Offenbach", 249 author="Detlev Offenbach",
246 author_email="detlev@die-offenbachs.de", 250 author_email="detlev@die-offenbachs.de",
247 url="https://eric-ide.python-projects.org", 251 url="https://eric-ide.python-projects.org",
248 project_urls={ 252 project_urls={
249 "Source Code": "https://die-offenbachs.homelinux.org/hg/eric/", 253 "Source Code": "https://die-offenbachs.homelinux.org/hg/eric/",
294 [".png", ".svg", ".svgz", ".xpm", ".ico", ".gif", ".icns", ".txt", 298 [".png", ".svg", ".svgz", ".xpm", ".ico", ".gif", ".icns", ".txt",
295 ".style", ".tmpl", ".html", ".qch", ".css", ".qss", ".e4h", 299 ".style", ".tmpl", ".html", ".qch", ".css", ".qss", ".e4h",
296 ".e6h", ".api", ".bas" ".dat"] 300 ".e6h", ".api", ".bas" ".dat"]
297 ) + ["i18n/eric6_de.qm", "i18n/eric6_en.qm", "i18n/eric6_es.qm", 301 ) + ["i18n/eric6_de.qm", "i18n/eric6_en.qm", "i18n/eric6_es.qm",
298 "i18n/eric6_ru.qm", 302 "i18n/eric6_ru.qm",
299 ] 303 ]
300 }, 304 },
301 entry_points={ 305 entry_points={
302 "gui_scripts": [ 306 "gui_scripts": [
303 "eric6 = eric6.eric6:main", 307 "eric6 = eric6.eric6:main",
304 "eric6_browser = eric6.eric6_browser:main", 308 "eric6_browser = eric6.eric6_browser:main",
320 "eric6_tray = eric6.eric6_tray:main", 324 "eric6_tray = eric6.eric6_tray:main",
321 "eric6_trpreviewer = eric6.eric6_trpreviewer:main", 325 "eric6_trpreviewer = eric6.eric6_trpreviewer:main",
322 "eric6_uipreviewer = eric6.eric6_uipreviewer:main", 326 "eric6_uipreviewer = eric6.eric6_uipreviewer:main",
323 "eric6_unittest = eric6.eric6_unittest:main", 327 "eric6_unittest = eric6.eric6_unittest:main",
324 ], 328 ],
325 "console_scripts":[ 329 "console_scripts": [
326 "eric6_api = eric6.eric6_api:main", 330 "eric6_api = eric6.eric6_api:main",
327 "eric6_doc = eric6.eric6_doc:main", 331 "eric6_doc = eric6.eric6_doc:main",
328 "eric6_post_install = eric6.eric6_post_install:main" 332 "eric6_post_install = eric6.eric6_post_install:main"
329 ], 333 ],
330 }, 334 },
331 cmdclass=CmdClass,
332 ) 335 )
333 336
334 if os.path.exists(infoFileName + ".orig"): 337 # cleanup
335 try: 338 for fileName in [infoFileName, appdataFileName]:
336 os.remove(infoFileName) 339 if os.path.exists(fileName + ".orig"):
337 os.rename(infoFileName + ".orig", infoFileName) 340 try:
338 except EnvironmentError: 341 os.remove(fileName)
339 pass 342 os.rename(fileName + ".orig", fileName)
343 except EnvironmentError:
344 pass

eric ide

mercurial