- # define installer name
- OutFile "installer.exe"
- # set desktop as install directory
- InstallDir $ DESKTOP
- # default section start
- Section
- # define output path
- SetOutPath $ INSTDIR
- # specify file to go in output path
- File test.txt
- # define uninstaller name
- WriteUninstaller $ INSTDIR \ uninstaller.exe
- # -------
- # default section end
- SectionEnd
- # create a section to define what the uninstaller does.
- # the section will always be named "Uninstall"
- Section "Uninstall"
- # Always delete uninstaller first
- Delete $ INSTDIR \ uninstaller.exe
- # now delete installed file
- Delete $ INSTDIR \ test.txt
- SectionEnd
import os import sys from distutils.core import setup from distutils.sysconfig import get_python_lib # Warn if we are installing over top of an existing installation. This can # cause issues where files that were deleted from a more recent Django are # still present in site-packages. See #18115. overlay_warning = False if "install" in sys.argv: lib_paths = [get_python_lib()] if lib_paths[0].startswith("/usr/lib/"): # We have to try also with an explicit prefix of /usr/local in order to # catch Debian's custom user site-packages directory. lib_paths.append(get_python_lib(prefix="/usr/local")) for lib_path in lib_paths: existing_path = os.path.abspath(os.path.join(lib_path, "django")) if os.path.exists(existing_path): # We note the need for the warning here, but present it after the # command is run, so it's more likely to be seen. overlay_warning = True break def fullsplit(path, result=None): """ Split a pathname into components (the opposite of os.path.join) in a platform-neutral way. """ if result is None: result = [] head, tail = os.path.split(path) if head == '': return [tail] + result if head == path: return result return fullsplit(head, [tail] + result) EXCLUDE_FROM_PACKAGES = ['django.conf.project_template', 'django.conf.app_template', 'django.bin'] def is_package(package_name): for pkg in EXCLUDE_FROM_PACKAGES: if package_name.startswith(pkg): return False return True # Compile the list of packages available, because distutils doesn't have # an easy way to do this. packages, package_data = [], {} root_dir = os.path.dirname(__file__) if root_dir != '': os.chdir(root_dir) django_dir = 'django' for dirpath, dirnames, filenames in os.walk(django_dir): # Ignore PEP 3147 cache dirs and those whose names start with '.' dirnames[:] = [d for d in dirnames if not d.startswith('.') and d != '__pycache__'] parts = fullsplit(dirpath) package_name = '.'.join(parts) if '__init__.py' in filenames and is_package(package_name): packages.append(package_name) elif filenames: relative_path = [] while '.'.join(parts) not in packages: relative_path.append(parts.pop()) relative_path.reverse() path = os.path.join(*relative_path) package_files = package_data.setdefault('.'.join(parts), []) package_files.extend([os.path.join(path, f) for f in filenames]) # Dynamically calculate the version based on django.VERSION. version = __import__('django').get_version() setup( name='Django', version=version, url='http://www.djangoproject.com/', author='Django Software Foundation', author_email='foundation@djangoproject.com', description=('A high-level Python Web framework that encourages ' 'rapid development and clean, pragmatic design.'), license='BSD', packages=packages, package_data=package_data, scripts=['django/bin/django-admin.py'], classifiers=[ 'Development Status :: 5 - Production/Stable', 'Environment :: Web Environment', 'Framework :: Django', 'Intended Audience :: Developers', 'License :: OSI Approved :: BSD License', 'Operating System :: OS Independent', 'Programming Language :: Python', 'Programming Language :: Python :: 2', 'Programming Language :: Python :: 2.6', 'Programming Language :: Python :: 2.7', 'Programming Language :: Python :: 3', 'Programming Language :: Python :: 3.2', 'Programming Language :: Python :: 3.3', 'Topic :: Internet :: WWW/HTTP', 'Topic :: Internet :: WWW/HTTP :: Dynamic Content', 'Topic :: Internet :: WWW/HTTP :: WSGI', 'Topic :: Software Development :: Libraries :: Application Frameworks', 'Topic :: Software Development :: Libraries :: Python Modules', ], ) if overlay_warning: sys.stderr.write(""" ======== WARNING! ======== You have just installed Django over top of an existing installation, without removing it first. Because of this, your install may now include extraneous files from a previous version that have since been removed from Django. This is known to cause a variety of problems. You should manually remove the %(existing_path)s directory and re-install Django. """ % {"existing_path": existing_path})
AS AN ALTERNATIVE, django directory to Python's
site-packages directory, which is located wherever your python installation
lives. Some places you might check are:
/usr/lib/python2.7/site-packages (Unix, Python 2.7)
/usr/lib/python2.6/site-packages (Unix, Python 2.6)
C: \\ PYTHON \ site-packages (Windows)
- ! include "Include \ LogicLib.nsh"
- OutFile "installer.exe"
- Name "Django 1.6.2"
- Caption "Django 1.6.2"
- Icon "$ {NSISDIR} \ Contrib \ Graphics \ Icons \ nsis1-install.ico"
- CRCCheck on
- SilentInstall normal
- BGGradient 000000 0000FF FFFFFF
- InstallColors FF8080 000030
- XPStyle on
- InstallDir $ EXEDIR / * Provides a default installation to where the installer was saved * /
- SetFont "Tahoma" 10 / * I like this font and that's it * /
- SetOverWrite on
- # -NonSectionInstructionsEnd-
- Section "BaseInstructions"
- SetDatablockOptimize on
- / * Without setting the output path for the files, the installer swore
- the impossibility of recording already at run time,
- although it seems that InstallDir is enough
- SetOutPath "$ INSTDIR \ *"
- SetOverWrite on
- File / r "C: \ ins \ Django-1.6.2 \ *" / * That folder in which I had Django.
- This is how you can include the necessary files in the installer * /
- SectionEnd
- RequestExecutionLevel highest / * Out of harm's way ... * /
- CheckBitmap "$ {NSISDIR} \ Contrib \ Graphics \ Checks \ classic-cross.bmp"
- LicenseText "Django license"
- LicenseData "license.rtf" / * Got off ... laziness =) * /
- / * "How many languages do you know, so many times you are a man" =)
- NSIDIR, as you can see, is the generator installation folder.
- The whole language itself is remarkable intuitive * /
- LoadLanguageFile "$ {NSISDIR} \ Contrib \ Language files \ English.nlf"
- LoadLanguageFile "$ {NSISDIR} \ Contrib \ Language files \ Dutch.nlf"
- LoadLanguageFile "$ {NSISDIR} \ Contrib \ Language files \ French.nlf"
- LoadLanguageFile "$ {NSISDIR} \ Contrib \ Language files \ German.nlf"
- LoadLanguageFile "$ {NSISDIR} \ Contrib \ Language files \ Korean.nlf"
- LoadLanguageFile "Russian.nlf" / * Slightly corrected translation file into native * /
- LoadLanguageFile "$ {NSISDIR} \ Contrib \ Language files \ Spanish.nlf"
- LoadLanguageFile "$ {NSISDIR} \ Contrib \ Language files \ Swedish.nlf"
- LoadLanguageFile "$ {NSISDIR} \ Contrib \ Language files \ TradChinese.nlf"
- LoadLanguageFile "$ {NSISDIR} \ Contrib \ Language files \ SimpChinese.nlf"
- LoadLanguageFile "$ {NSISDIR} \ Contrib \ Language files \ Slovak.nlf"
- ; Set name using the normal interface (Name command)
- LangString Name $ { LANG_ENGLISH } "English"
- LangString Name $ { LANG_DUTCH } "Dutch"
- LangString Name $ { LANG_FRENCH } "French"
- LangString Name $ { LANG_GERMAN } "German"
- LangString Name $ { LANG_KOREAN } "Korean"
- LangString Name $ { LANG_RUSSIAN } "Russian"
- LangString Name $ { LANG_SPANISH } "Spanish"
- LangString Name $ { LANG_SWEDISH } "Swedish"
- LangString Name $ { LANG_TRADCHINESE } "Traditional Chinese"
- LangString Name $ { LANG_SIMPCHINESE } "Simplified Chinese"
- LangString Name $ { LANG_SLOVAK } "Slovak"
- ; Directly change the inner lang strings (Same as ComponentText)
- LangString ^ ComponentsText $ { LANG_ENGLISH } "English component page"
- LangString ^ ComponentsText $ { LANG_DUTCH } "Dutch component page"
- LangString ^ ComponentsText $ { LANG_FRENCH } "French component page"
- LangString ^ ComponentsText $ { LANG_GERMAN } "German component page"
- LangString ^ ComponentsText $ { LANG_KOREAN } "Korean component page"
- LangString ^ ComponentsText $ { LANG_RUSSIAN } "Russian component page"
- LangString ^ ComponentsText $ { LANG_SPANISH } "Spanish component page"
- LangString ^ ComponentsText $ { LANG_SWEDISH } "Swedish component page"
- LangString ^ ComponentsText $ { LANG_TRADCHINESE } "Traditional Chinese component page"
- LangString ^ ComponentsText $ { LANG_SIMPCHINESE } "Simplified Chinese component page"
- LangString ^ ComponentsText $ { LANG_SLOVAK } "Slovak component page"
- ; A LangString for the section name
- LangString Sec1Name $ { LANG_ENGLISH } "English section # 1"
- LangString Sec1Name $ { LANG_DUTCH } "Dutch section # 1"
- LangString Sec1Name $ { LANG_FRENCH } "French section # 1"
- LangString Sec1Name $ { LANG_GERMAN } "German section # 1"
- LangString Sec1Name $ { LANG_KOREAN } "Korean section # 1"
- LangString Sec1Name $ { LANG_RUSSIAN } "Russian section # 1"
- LangString Sec1Name $ { LANG_SPANISH } "Spanish section # 1"
- LangString Sec1Name $ { LANG_SWEDISH } "Swedish section # 1"
- LangString Sec1Name $ { LANG_TRADCHINESE } "Trandional Chinese section # 1"
- LangString Sec1Name $ { LANG_SIMPCHINESE } "Simplified Chinese section # 1"
- LangString Sec1Name $ { LANG_SLOVAK } "Slovak section # 1"
- ; --------------------------------
- Function .onInit
- ; Language selection dialog
- Push ""
- Push $ { LANG_ENGLISH }
- Push English
- Push $ { LANG_DUTCH }
- Push dutch
- Push $ { LANG_FRENCH }
- Push french
- Push $ { LANG_GERMAN }
- Push german
- Push $ { LANG_KOREAN }
- Push korean
- Push $ { LANG_RUSSIAN }
- Push russian
- Push $ { LANG_SPANISH }
- Push spanish
- Push $ { LANG_SWEDISH }
- Push swedish
- Push $ { LANG_TRADCHINESE }
- Push "Traditional Chinese"
- Push $ { LANG_SIMPCHINESE }
- Push "Simplified Chinese"
- Push $ { LANG_SLOVAK }
- Push Slovak
- Push A ; A means auto count languages
- ; push button (push "") must remain
- LangDLL :: LangDialog "Installer Language" "Please select the language of the installer"
- Pop $ LANGUAGE
- StrCmp $ LANGUAGE "cancel" 0 + 2
- Abort
- FunctionEnd
- ; --------------------------------
- ; --------------------------------
- Page license
- Page directory
- Page instfiles
- AutoCloseWindow false
- ShowInstDetails show
- Function "FinalStage"
- MessageBox MB_OK "Close window and see on your screen ... Thanks!"
- FunctionEnd
- / * Pay attention to the wrapper. It would seem that should
- to work without a section, just a call and we finished it, but no ... :( * /
- Section "Final"
- Call "FinalStage"
- SectionEnd
- Function .onGUIEnd / * There are other callbacks * /
- ClearErrors
- / * With a clean install, you could do without
- by copying django to site-packages, however using setup.py
- It seemed to me more kosher, considering the meta-information. I don't know python
- so I don’t know where and how the absence of the setup () call comes around. * /
- FileOpen $ 0 $ INSTDIR \ installer.bat w
- IfErrors done
- FileWrite $ 0 "cd $ INSTDIR $ \ npython setup.py install" / * I don’t always like Abracadabra with registers * /
- / * It should be noted here that adding something like del / Q $ INSTDIR \ installer.bat to a batch file does not lead to good.
- I would be grateful if they tell me why this is happening, because it is not nuggly and it seems intuitively
- that if the command is launched, the presence or absence of the file with the command does not play a role, but not the same ...
- FileClose $ 0
- done:
- Exec "$ INSTDIR \ installer.bat"
- FunctionEnd
- / * It would be possible to make a page with the choice of the python folder, in case the python is not registered in the PATH -
- that would be perfect, but I'm not a perfectionist maniac and I’ll do it only if the installer
- Someone will like it and I will be indicated on the defect. * /
Source: https://habr.com/ru/post/219285/
All Articles