Django

Code

Ticket #6080: reusableapps3.diff

File reusableapps3.diff, 7.8 kB (added by jezdez, 10 months ago)

Only use setuptools if installed, otherwise fallback to distuils (now without throwing a UserWarning? because of the unsupported setup keywords), fully backwards compatible from my point of view

  • setup.py

    old new  
    1 from distutils.core import setup 
    2 from distutils.command.install import INSTALL_SCHEMES 
    3 import os 
    4 import sys 
     1import os, sys 
     2try: 
     3    from setuptools import setup 
     4except ImportError: 
     5    from distutils.core import setup 
     6    use_setuptools = False 
     7else: 
     8    use_setuptools = True 
    59 
    610def fullsplit(path, result=None): 
    711    """ 
     
    1721        return result 
    1822    return fullsplit(head, [tail] + result) 
    1923 
    20 # Tell distutils to put the data_files in platform-specific installation 
    21 # locations. See here for an explanation: 
    22 # http://groups.google.com/group/comp.lang.python/browse_thread/thread/35ec7b2fed36eaec/2105ee4d9e8042cb 
    23 for scheme in INSTALL_SCHEMES.values(): 
    24     scheme['data'] = scheme['purelib'] 
     24setuptools_options = {} 
     25version_tuple = __import__('django').VERSION 
     26if use_setuptools: 
     27    # Additional arguments for use with setuptools 
     28    setuptools_options = dict( 
     29        install_requires = ['setuptools>=0.6c7', 'Flup'], 
     30        extras_require = { 
     31            'MySQL':  ["MySQLdb>=1.2.1p2"], 
     32            'SQLite': ["pysqlite>=2.0.3"], 
     33            'PostgreSQL': ["psycopg>=1.1.21"], 
     34            'PostgreSQL2': ["psycopg2>=2.0.5"], 
     35            'Oracle': ["cx_Oracle>=4.3.1"], 
     36            'PyYaml': ["PyYaml"], 
     37        }, 
     38        zip_safe = False, 
     39    ) 
     40    # Dynamically calculate the version based on django.VERSION but leave out 
     41    # any non-int part, to use tag_build and tag_svn_revision from setup.cfg 
     42    version = '.'.join([str(i) for i in version_tuple if type(i) == int]) 
     43else: 
     44    # Dynamically calculate the version based on django.VERSION. 
     45    if version_tuple[2] is not None: 
     46        version = "%d.%d_%s" % version_tuple 
     47    else: 
     48        version = "%d.%d" % version_tuple[:2] 
     49    # Tell distutils to put the data_files in platform-specific installation 
     50    # locations. See here for an explanation: 
     51    # http://groups.google.com/group/comp.lang.python/browse_thread/thread/35ec7b2fed36eaec/2105ee4d9e8042cb 
     52    from distutils.command.install import INSTALL_SCHEMES 
     53    for scheme in INSTALL_SCHEMES.values(): 
     54        scheme['data'] = scheme['purelib'] 
    2555 
    2656# Compile the list of packages available, because distutils doesn't have 
    2757# an easy way to do this. 
     
    4373    elif filenames: 
    4474        data_files.append([dirpath, [os.path.join(dirpath, f) for f in filenames]]) 
    4575 
    46 # Dynamically calculate the version based on django.VERSION. 
    47 version_tuple = __import__('django').VERSION 
    48 if version_tuple[2] is not None: 
    49     version = "%d.%d_%s" % version_tuple 
    50 else: 
    51     version = "%d.%d" % version_tuple[:2] 
    52  
    5376setup( 
    5477    name = "Django", 
    5578    version = version, 
    5679    url = 'http://www.djangoproject.com/', 
     80    download_url = 'http://www.djangoproject.com/download/', 
     81    license = 'BSD', 
    5782    author = 'Lawrence Journal-World', 
    5883    author_email = 'holovaty@gmail.com', 
    5984    description = 'A high-level Python Web framework that encourages rapid development and clean, pragmatic design.', 
    6085    packages = packages, 
    6186    data_files = data_files, 
    6287    scripts = ['django/bin/django-admin.py'], 
     88    **setuptools_options 
    6389) 
  • docs/install.txt

    old new  
    224224command ``svn update`` from within the ``django-trunk`` directory. When you do 
    225225this, Subversion will automatically download any changes. 
    226226 
     227Using setuptools' ``develop`` command 
     228------------------------------------- 
     229 
     230**New in Django development version** 
     231 
     232If you already installed setuptools_ you can skip step 3 and 4 of the 
     233instructions above and use the ``develop`` command of setuptools instead:: 
     234 
     235    python setup.py develop 
     236 
     237This adds a special file automatically to your system's ``site-packages`` 
     238directory and enables the Python intepreter to find the Django checkout 
     239without the need to create a symbolic link or to set the ``PYTHONPATH`` 
     240environment variable. This is also platform-independent. 
     241 
     242Installing using easy_install 
     243~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
     244**New in Django development version** 
     245 
     246If you want to benefit from setuptools_'s package management and dependency 
     247tracking, don't hesitate to install Django with easy_install_. 
     248 
     2491. Make sure that you have Subversion_ and setuptools_ installed, and that you 
     250   can run its commands from a shell. (Enter ``svn help`` or 
     251   ``easy_install --help`` at a shell prompt to test this.) 
     252 
     2532. Install Django's main development branch (the 'trunk') like so:: 
     254 
     255    easy_install http://code.djangoproject.com/svn/django/trunk/ 
     256 
     257   The above line checks out Django's source automatically and runs 
     258   ``python setup.py install`` for you. 
     259    
     260This also works with Django's latest offical version or any other release  
     261available at the `Python Package Index`_:: 
     262 
     263    easy_install Django 
     264    easy_install Django==0.95.2 
     265    easy_install Django==0.90 
     266 
     267The Django source packages includes not only files with the actual code but 
     268also documentation, an example project and some extras. If you want to examine 
     269these files or use setuptools' ``develop`` command, tell easy_install_ to 
     270automatically extract the package after download to a given directory:: 
     271 
     272    easy_install -eb /path/to/django-source Django 
     273 
     274Once you are ready to install Django from these source files, just rerun 
     275easy_install_ with that directory as the target:: 
     276 
     277    easy_install /path/to/django-source 
     278 
     279If you want setuptools to install one of several recommended extras or a 
     280Python database binding during Django's installation, you can also use 
     281easy_install_ like this:: 
     282 
     283    easy_install Django[PostgreSQL] 
     284    easy_install Django[SQLite, PyYaml] 
     285 
     286To see a full list of the available extras, open ``setup.py`` and look at the 
     287``extras_require`` keyword. 
     288 
     289 
    227290.. _`download page`: http://www.djangoproject.com/download/ 
    228291.. _Subversion: http://subversion.tigris.org/ 
    229292.. _from the Control Panel: http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/sysdm_advancd_environmnt_addchange_variable.mspx 
     293.. _setuptools: http://peak.telecommunity.com/DevCenter/setuptools 
     294.. _`Python Package Index`: http://pypi.python.org/ 
     295.. _easy_install: http://peak.telecommunity.com/DevCenter/EasyInstall 
  • docs/model-api.txt

    old new  
    20502050Do this by editing your settings file and changing the ``INSTALLED_APPS`` 
    20512051setting to add the name of the module that contains your ``models.py``. 
    20522052 
     2053Any module that can be found on the Python module search path, which is defined 
     2054in the environment variable ``PYTHONPATH`` as a list of directory names, is 
     2055allowed. Please note this also applies to so-called `Python eggs`_, a single-file 
     2056distribution format for Python libraries and modules such as Django apps. 
     2057 
    20532058For example, if the models for your application live in the module 
    2054 ``mysite.myapp.models`` (the package structure that is created for an 
     2059``mysite.myapp.models`` (e.g. the package structure that is created for an 
    20552060application by the ``manage.py startapp`` script), ``INSTALLED_APPS`` should 
    20562061read, in part:: 
    20572062 
     
    20612066        #... 
    20622067    ) 
    20632068 
     2069.. _`Python eggs`: http://peak.telecommunity.com/DevCenter/PythonEggs 
     2070.. _setuptools: http://peak.telecommunity.com/DevCenter/setuptools 
     2071 
    20642072Providing initial SQL data 
    20652073========================== 
    20662074 
  • setup.cfg

    old new  
    22doc_files = docs examples extras AUTHORS INSTALL LICENSE README 
    33install-script = scripts/rpm-install.sh 
    44 
     5[egg_info] 
     6tag_build = pre 
     7tag_svn_revision = 1