# HG changeset patch # User ymh # Date 1432858931 -7200 # Node ID fc0f3e398166cfa3f58c24363f1befeea32c78e4 # Parent a2f733f900c0f02913230b4038135efff20cd1df Creation of Django server project diff -r a2f733f900c0 -r fc0f3e398166 .hgignore --- a/.hgignore Wed May 13 12:39:14 2015 +0200 +++ b/.hgignore Fri May 29 02:22:11 2015 +0200 @@ -10,6 +10,7 @@ authserver/testCAS/.git* authserver/casserver/simple-cas4-overlay-template/.git authserver/casserver/simple-cas4-overlay-template/target +authserver/casserver/tmp .classpath .settings target/ @@ -29,3 +30,12 @@ authserver/testCAS/storage/framework/cache/* authserver/testCAS/storage/framework/sessions/* authserver/testCAS/storage/framework/views/* +server/src/remieplt/settings/* +server/virtualenv/sync/env/* +server/virtualenv/web/env/* +server/virtualenv/sync/project-boot.py +server/virtualenv/web/project-boot.py +server/run/* +server/web/* +server/src/dist +server/src/MANIFEST.in diff -r a2f733f900c0 -r fc0f3e398166 server/run/.hgkeep diff -r a2f733f900c0 -r fc0f3e398166 server/run/log/.hgkeep diff -r a2f733f900c0 -r fc0f3e398166 server/src/CHANGES --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/server/src/CHANGES Fri May 29 02:22:11 2015 +0200 @@ -0,0 +1,1 @@ +v00.01, 2015-05-29 -- initial release. diff -r a2f733f900c0 -r fc0f3e398166 server/src/LICENSE --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/server/src/LICENSE Fri May 29 02:22:11 2015 +0200 @@ -0,0 +1,523 @@ +Copyright (c) 2011, IRI (Institute d Recherche de d'Innovation) +All rights reserved. + + + +CeCILL-C FREE SOFTWARE LICENSE AGREEMENT + + + Notice + +This Agreement is a Free Software license agreement that is the result +of discussions between its authors in order to ensure compliance with +the two main principles guiding its drafting: + + * firstly, compliance with the principles governing the distribution + of Free Software: access to source code, broad rights granted to + users, + * secondly, the election of a governing law, French law, with which + it is conformant, both as regards the law of torts and + intellectual property law, and the protection that it offers to + both authors and holders of the economic rights over software. + +The authors of the CeCILL-C (for Ce[a] C[nrs] I[nria] L[ogiciel] L[ibre]) +license are: + +Commissariat à l'Energie Atomique - CEA, a public scientific, technical +and industrial research establishment, having its principal place of +business at 25 rue Leblanc, immeuble Le Ponant D, 75015 Paris, France. + +Centre National de la Recherche Scientifique - CNRS, a public scientific +and technological establishment, having its principal place of business +at 3 rue Michel-Ange, 75794 Paris cedex 16, France. + +Institut National de Recherche en Informatique et en Automatique - +INRIA, a public scientific and technological establishment, having its +principal place of business at Domaine de Voluceau, Rocquencourt, BP +105, 78153 Le Chesnay cedex, France. + + + Preamble + +The purpose of this Free Software license agreement is to grant users +the right to modify and re-use the software governed by this license. + +The exercising of this right is conditional upon the obligation to make +available to the community the modifications made to the source code of +the software so as to contribute to its evolution. + +In consideration of access to the source code and the rights to copy, +modify and redistribute granted by the license, users are provided only +with a limited warranty and the software's author, the holder of the +economic rights, and the successive licensors only have limited liability. + +In this respect, the risks associated with loading, using, modifying +and/or developing or reproducing the software by the user are brought to +the user's attention, given its Free Software status, which may make it +complicated to use, with the result that its use is reserved for +developers and experienced professionals having in-depth computer +knowledge. Users are therefore encouraged to load and test the +suitability of the software as regards their requirements in conditions +enabling the security of their systems and/or data to be ensured and, +more generally, to use and operate it in the same conditions of +security. This Agreement may be freely reproduced and published, +provided it is not altered, and that no provisions are either added or +removed herefrom. + +This Agreement may apply to any or all software for which the holder of +the economic rights decides to submit the use thereof to its provisions. + + + Article 1 - DEFINITIONS + +For the purpose of this Agreement, when the following expressions +commence with a capital letter, they shall have the following meaning: + +Agreement: means this license agreement, and its possible subsequent +versions and annexes. + +Software: means the software in its Object Code and/or Source Code form +and, where applicable, its documentation, "as is" when the Licensee +accepts the Agreement. + +Initial Software: means the Software in its Source Code and possibly its +Object Code form and, where applicable, its documentation, "as is" when +it is first distributed under the terms and conditions of the Agreement. + +Modified Software: means the Software modified by at least one +Integrated Contribution. + +Source Code: means all the Software's instructions and program lines to +which access is required so as to modify the Software. + +Object Code: means the binary files originating from the compilation of +the Source Code. + +Holder: means the holder(s) of the economic rights over the Initial +Software. + +Licensee: means the Software user(s) having accepted the Agreement. + +Contributor: means a Licensee having made at least one Integrated +Contribution. + +Licensor: means the Holder, or any other individual or legal entity, who +distributes the Software under the Agreement. + +Integrated Contribution: means any or all modifications, corrections, +translations, adaptations and/or new functions integrated into the +Source Code by any or all Contributors. + +Related Module: means a set of sources files including their +documentation that, without modification to the Source Code, enables +supplementary functions or services in addition to those offered by the +Software. + +Derivative Software: means any combination of the Software, modified or +not, and of a Related Module. + +Parties: mean both the Licensee and the Licensor. + +These expressions may be used both in singular and plural form. + + + Article 2 - PURPOSE + +The purpose of the Agreement is the grant by the Licensor to the +Licensee of a non-exclusive, transferable and worldwide license for the +Software as set forth in Article 5 hereinafter for the whole term of the +protection granted by the rights over said Software. + + + Article 3 - ACCEPTANCE + +3.1 The Licensee shall be deemed as having accepted the terms and +conditions of this Agreement upon the occurrence of the first of the +following events: + + * (i) loading the Software by any or all means, notably, by + downloading from a remote server, or by loading from a physical + medium; + * (ii) the first time the Licensee exercises any of the rights + granted hereunder. + +3.2 One copy of the Agreement, containing a notice relating to the +characteristics of the Software, to the limited warranty, and to the +fact that its use is restricted to experienced users has been provided +to the Licensee prior to its acceptance as set forth in Article 3.1 +hereinabove, and the Licensee hereby acknowledges that it has read and +understood it. + + + Article 4 - EFFECTIVE DATE AND TERM + + + 4.1 EFFECTIVE DATE + +The Agreement shall become effective on the date when it is accepted by +the Licensee as set forth in Article 3.1. + + + 4.2 TERM + +The Agreement shall remain in force for the entire legal term of +protection of the economic rights over the Software. + + + Article 5 - SCOPE OF RIGHTS GRANTED + +The Licensor hereby grants to the Licensee, who accepts, the following +rights over the Software for any or all use, and for the term of the +Agreement, on the basis of the terms and conditions set forth hereinafter. + +Besides, if the Licensor owns or comes to own one or more patents +protecting all or part of the functions of the Software or of its +components, the Licensor undertakes not to enforce the rights granted by +these patents against successive Licensees using, exploiting or +modifying the Software. If these patents are transferred, the Licensor +undertakes to have the transferees subscribe to the obligations set +forth in this paragraph. + + + 5.1 RIGHT OF USE + +The Licensee is authorized to use the Software, without any limitation +as to its fields of application, with it being hereinafter specified +that this comprises: + + 1. permanent or temporary reproduction of all or part of the Software + by any or all means and in any or all form. + + 2. loading, displaying, running, or storing the Software on any or + all medium. + + 3. entitlement to observe, study or test its operation so as to + determine the ideas and principles behind any or all constituent + elements of said Software. This shall apply when the Licensee + carries out any or all loading, displaying, running, transmission + or storage operation as regards the Software, that it is entitled + to carry out hereunder. + + + 5.2 RIGHT OF MODIFICATION + +The right of modification includes the right to translate, adapt, +arrange, or make any or all modifications to the Software, and the right +to reproduce the resulting software. It includes, in particular, the +right to create a Derivative Software. + +The Licensee is authorized to make any or all modification to the +Software provided that it includes an explicit notice that it is the +author of said modification and indicates the date of the creation thereof. + + + 5.3 RIGHT OF DISTRIBUTION + +In particular, the right of distribution includes the right to publish, +transmit and communicate the Software to the general public on any or +all medium, and by any or all means, and the right to market, either in +consideration of a fee, or free of charge, one or more copies of the +Software by any means. + +The Licensee is further authorized to distribute copies of the modified +or unmodified Software to third parties according to the terms and +conditions set forth hereinafter. + + + 5.3.1 DISTRIBUTION OF SOFTWARE WITHOUT MODIFICATION + +The Licensee is authorized to distribute true copies of the Software in +Source Code or Object Code form, provided that said distribution +complies with all the provisions of the Agreement and is accompanied by: + + 1. a copy of the Agreement, + + 2. a notice relating to the limitation of both the Licensor's + warranty and liability as set forth in Articles 8 and 9, + +and that, in the event that only the Object Code of the Software is +redistributed, the Licensee allows effective access to the full Source +Code of the Software at a minimum during the entire period of its +distribution of the Software, it being understood that the additional +cost of acquiring the Source Code shall not exceed the cost of +transferring the data. + + + 5.3.2 DISTRIBUTION OF MODIFIED SOFTWARE + +When the Licensee makes an Integrated Contribution to the Software, the +terms and conditions for the distribution of the resulting Modified +Software become subject to all the provisions of this Agreement. + +The Licensee is authorized to distribute the Modified Software, in +source code or object code form, provided that said distribution +complies with all the provisions of the Agreement and is accompanied by: + + 1. a copy of the Agreement, + + 2. a notice relating to the limitation of both the Licensor's + warranty and liability as set forth in Articles 8 and 9, + +and that, in the event that only the object code of the Modified +Software is redistributed, the Licensee allows effective access to the +full source code of the Modified Software at a minimum during the entire +period of its distribution of the Modified Software, it being understood +that the additional cost of acquiring the source code shall not exceed +the cost of transferring the data. + + + 5.3.3 DISTRIBUTION OF DERIVATIVE SOFTWARE + +When the Licensee creates Derivative Software, this Derivative Software +may be distributed under a license agreement other than this Agreement, +subject to compliance with the requirement to include a notice +concerning the rights over the Software as defined in Article 6.4. +In the event the creation of the Derivative Software required modification +of the Source Code, the Licensee undertakes that: + + 1. the resulting Modified Software will be governed by this Agreement, + 2. the Integrated Contributions in the resulting Modified Software + will be clearly identified and documented, + 3. the Licensee will allow effective access to the source code of the + Modified Software, at a minimum during the entire period of + distribution of the Derivative Software, such that such + modifications may be carried over in a subsequent version of the + Software; it being understood that the additional cost of + purchasing the source code of the Modified Software shall not + exceed the cost of transferring the data. + + + 5.3.4 COMPATIBILITY WITH THE CeCILL LICENSE + +When a Modified Software contains an Integrated Contribution subject to +the CeCILL license agreement, or when a Derivative Software contains a +Related Module subject to the CeCILL license agreement, the provisions +set forth in the third item of Article 6.4 are optional. + + + Article 6 - INTELLECTUAL PROPERTY + + + 6.1 OVER THE INITIAL SOFTWARE + +The Holder owns the economic rights over the Initial Software. Any or +all use of the Initial Software is subject to compliance with the terms +and conditions under which the Holder has elected to distribute its work +and no one shall be entitled to modify the terms and conditions for the +distribution of said Initial Software. + +The Holder undertakes that the Initial Software will remain ruled at +least by this Agreement, for the duration set forth in Article 4.2. + + + 6.2 OVER THE INTEGRATED CONTRIBUTIONS + +The Licensee who develops an Integrated Contribution is the owner of the +intellectual property rights over this Contribution as defined by +applicable law. + + + 6.3 OVER THE RELATED MODULES + +The Licensee who develops a Related Module is the owner of the +intellectual property rights over this Related Module as defined by +applicable law and is free to choose the type of agreement that shall +govern its distribution under the conditions defined in Article 5.3.3. + + + 6.4 NOTICE OF RIGHTS + +The Licensee expressly undertakes: + + 1. not to remove, or modify, in any manner, the intellectual property + notices attached to the Software; + + 2. to reproduce said notices, in an identical manner, in the copies + of the Software modified or not; + + 3. to ensure that use of the Software, its intellectual property + notices and the fact that it is governed by the Agreement is + indicated in a text that is easily accessible, specifically from + the interface of any Derivative Software. + +The Licensee undertakes not to directly or indirectly infringe the +intellectual property rights of the Holder and/or Contributors on the +Software and to take, where applicable, vis-à-vis its staff, any and all +measures required to ensure respect of said intellectual property rights +of the Holder and/or Contributors. + + + Article 7 - RELATED SERVICES + +7.1 Under no circumstances shall the Agreement oblige the Licensor to +provide technical assistance or maintenance services for the Software. + +However, the Licensor is entitled to offer this type of services. The +terms and conditions of such technical assistance, and/or such +maintenance, shall be set forth in a separate instrument. Only the +Licensor offering said maintenance and/or technical assistance services +shall incur liability therefor. + +7.2 Similarly, any Licensor is entitled to offer to its licensees, under +its sole responsibility, a warranty, that shall only be binding upon +itself, for the redistribution of the Software and/or the Modified +Software, under terms and conditions that it is free to decide. Said +warranty, and the financial terms and conditions of its application, +shall be subject of a separate instrument executed between the Licensor +and the Licensee. + + + Article 8 - LIABILITY + +8.1 Subject to the provisions of Article 8.2, the Licensee shall be +entitled to claim compensation for any direct loss it may have suffered +from the Software as a result of a fault on the part of the relevant +Licensor, subject to providing evidence thereof. + +8.2 The Licensor's liability is limited to the commitments made under +this Agreement and shall not be incurred as a result of in particular: +(i) loss due the Licensee's total or partial failure to fulfill its +obligations, (ii) direct or consequential loss that is suffered by the +Licensee due to the use or performance of the Software, and (iii) more +generally, any consequential loss. In particular the Parties expressly +agree that any or all pecuniary or business loss (i.e. loss of data, +loss of profits, operating loss, loss of customers or orders, +opportunity cost, any disturbance to business activities) or any or all +legal proceedings instituted against the Licensee by a third party, +shall constitute consequential loss and shall not provide entitlement to +any or all compensation from the Licensor. + + + Article 9 - WARRANTY + +9.1 The Licensee acknowledges that the scientific and technical +state-of-the-art when the Software was distributed did not enable all +possible uses to be tested and verified, nor for the presence of +possible defects to be detected. In this respect, the Licensee's +attention has been drawn to the risks associated with loading, using, +modifying and/or developing and reproducing the Software which are +reserved for experienced users. + +The Licensee shall be responsible for verifying, by any or all means, +the suitability of the product for its requirements, its good working +order, and for ensuring that it shall not cause damage to either persons +or properties. + +9.2 The Licensor hereby represents, in good faith, that it is entitled +to grant all the rights over the Software (including in particular the +rights set forth in Article 5). + +9.3 The Licensee acknowledges that the Software is supplied "as is" by +the Licensor without any other express or tacit warranty, other than +that provided for in Article 9.2 and, in particular, without any warranty +as to its commercial value, its secured, safe, innovative or relevant +nature. + +Specifically, the Licensor does not warrant that the Software is free +from any error, that it will operate without interruption, that it will +be compatible with the Licensee's own equipment and software +configuration, nor that it will meet the Licensee's requirements. + +9.4 The Licensor does not either expressly or tacitly warrant that the +Software does not infringe any third party intellectual property right +relating to a patent, software or any other property right. Therefore, +the Licensor disclaims any and all liability towards the Licensee +arising out of any or all proceedings for infringement that may be +instituted in respect of the use, modification and redistribution of the +Software. Nevertheless, should such proceedings be instituted against +the Licensee, the Licensor shall provide it with technical and legal +assistance for its defense. Such technical and legal assistance shall be +decided on a case-by-case basis between the relevant Licensor and the +Licensee pursuant to a memorandum of understanding. The Licensor +disclaims any and all liability as regards the Licensee's use of the +name of the Software. No warranty is given as regards the existence of +prior rights over the name of the Software or as regards the existence +of a trademark. + + + Article 10 - TERMINATION + +10.1 In the event of a breach by the Licensee of its obligations +hereunder, the Licensor may automatically terminate this Agreement +thirty (30) days after notice has been sent to the Licensee and has +remained ineffective. + +10.2 A Licensee whose Agreement is terminated shall no longer be +authorized to use, modify or distribute the Software. However, any +licenses that it may have granted prior to termination of the Agreement +shall remain valid subject to their having been granted in compliance +with the terms and conditions hereof. + + + Article 11 - MISCELLANEOUS + + + 11.1 EXCUSABLE EVENTS + +Neither Party shall be liable for any or all delay, or failure to +perform the Agreement, that may be attributable to an event of force +majeure, an act of God or an outside cause, such as defective +functioning or interruptions of the electricity or telecommunications +networks, network paralysis following a virus attack, intervention by +government authorities, natural disasters, water damage, earthquakes, +fire, explosions, strikes and labor unrest, war, etc. + +11.2 Any failure by either Party, on one or more occasions, to invoke +one or more of the provisions hereof, shall under no circumstances be +interpreted as being a waiver by the interested Party of its right to +invoke said provision(s) subsequently. + +11.3 The Agreement cancels and replaces any or all previous agreements, +whether written or oral, between the Parties and having the same +purpose, and constitutes the entirety of the agreement between said +Parties concerning said purpose. No supplement or modification to the +terms and conditions hereof shall be effective as between the Parties +unless it is made in writing and signed by their duly authorized +representatives. + +11.4 In the event that one or more of the provisions hereof were to +conflict with a current or future applicable act or legislative text, +said act or legislative text shall prevail, and the Parties shall make +the necessary amendments so as to comply with said act or legislative +text. All other provisions shall remain effective. Similarly, invalidity +of a provision of the Agreement, for any reason whatsoever, shall not +cause the Agreement as a whole to be invalid. + + + 11.5 LANGUAGE + +The Agreement is drafted in both French and English and both versions +are deemed authentic. + + + Article 12 - NEW VERSIONS OF THE AGREEMENT + +12.1 Any person is authorized to duplicate and distribute copies of this +Agreement. + +12.2 So as to ensure coherence, the wording of this Agreement is +protected and may only be modified by the authors of the License, who +reserve the right to periodically publish updates or new versions of the +Agreement, each with a separate number. These subsequent versions may +address new issues encountered by Free Software. + +12.3 Any Software distributed under a given version of the Agreement may +only be subsequently distributed under the same version of the Agreement +or a subsequent version. + + + Article 13 - GOVERNING LAW AND JURISDICTION + +13.1 The Agreement is governed by French law. The Parties agree to +endeavor to seek an amicable solution to any disagreements or disputes +that may arise during the performance of the Agreement. + +13.2 Failing an amicable solution within two (2) months as from their +occurrence, and unless emergency proceedings are necessary, the +disagreements or disputes shall be referred to the Paris Courts having +jurisdiction, by the more diligent Party. + + +Version 1.0 dated 2006-09-05. + + diff -r a2f733f900c0 -r fc0f3e398166 server/src/MANIFEST --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/server/src/MANIFEST Fri May 29 02:22:11 2015 +0200 @@ -0,0 +1,20 @@ +# file GENERATED by distutils, do NOT edit +CHANGES +LICENSE +MANIFEST.in +README +setup.py +remie/__init__.py +remie/admin.py +remie/models.py +remie/tests.py +remie/views.py +remie/migrations/__init__.py +remieplt/__init__.py +remieplt/urls.py +remieplt/wsgi.py +remieplt/settings/__init__.py +remieplt/settings/dev.py +remieplt/templates/admin/base_site.html +remieplt/templates/ldt/ldt_utils/workspace.html +remieplt/templates/registration/login.html diff -r a2f733f900c0 -r fc0f3e398166 server/src/README --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/server/src/README Fri May 29 02:22:11 2015 +0200 @@ -0,0 +1,3 @@ +============ +Remie Platform +============ diff -r a2f733f900c0 -r fc0f3e398166 server/src/manage.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/server/src/manage.py Fri May 29 02:22:11 2015 +0200 @@ -0,0 +1,10 @@ +#!/usr/bin/env python +import os +import sys + +if __name__ == "__main__": + os.environ.setdefault("DJANGO_SETTINGS_MODULE", "remieplt.settings") + + from django.core.management import execute_from_command_line + + execute_from_command_line(sys.argv) diff -r a2f733f900c0 -r fc0f3e398166 server/src/remie/__init__.py diff -r a2f733f900c0 -r fc0f3e398166 server/src/remie/admin.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/server/src/remie/admin.py Fri May 29 02:22:11 2015 +0200 @@ -0,0 +1,3 @@ +from django.contrib import admin + +# Register your models here. diff -r a2f733f900c0 -r fc0f3e398166 server/src/remie/migrations/__init__.py diff -r a2f733f900c0 -r fc0f3e398166 server/src/remie/models.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/server/src/remie/models.py Fri May 29 02:22:11 2015 +0200 @@ -0,0 +1,3 @@ +from django.db import models + +# Create your models here. diff -r a2f733f900c0 -r fc0f3e398166 server/src/remie/tests.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/server/src/remie/tests.py Fri May 29 02:22:11 2015 +0200 @@ -0,0 +1,3 @@ +from django.test import TestCase + +# Create your tests here. diff -r a2f733f900c0 -r fc0f3e398166 server/src/remie/views.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/server/src/remie/views.py Fri May 29 02:22:11 2015 +0200 @@ -0,0 +1,3 @@ +from django.shortcuts import render + +# Create your views here. diff -r a2f733f900c0 -r fc0f3e398166 server/src/remieplt/__init__.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/server/src/remieplt/__init__.py Fri May 29 02:22:11 2015 +0200 @@ -0,0 +1,17 @@ +VERSION = (0, 1, 0, "alpha", 0) + +VERSION_STR = unicode(".".join(map(lambda i:"%02d" % (i,), VERSION[:2]))) + + +def get_version(): + version = '%s.%s' % (VERSION[0], VERSION[1]) + if VERSION[2]: + version = '%s.%s' % (version, VERSION[2]) + if VERSION[3] == 'alpha': + version = '%s-alpha.%s' % (version, VERSION[4]) + else: + if VERSION[3] != 'final': + version = '%s %s %s' % (version, VERSION[3], VERSION[4]) + return version + +__version__ = get_version() diff -r a2f733f900c0 -r fc0f3e398166 server/src/remieplt/settings/__init__.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/server/src/remieplt/settings/__init__.py Fri May 29 02:22:11 2015 +0200 @@ -0,0 +1,249 @@ +""" +Django settings for remieplt project. + +Generated by 'django-admin startproject' using Django 1.8.2. + +For more information on this file, see +https://docs.djangoproject.com/en/dev/topics/settings/ + +For the full list of settings and their values, see +https://docs.djangoproject.com/en/dev/ref/settings/ +""" + +# Build paths inside the project like this: os.path.join(BASE_DIR, ...) +import os, remieplt + +BASE_DIR = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) + + +# Quick-start development settings - unsuitable for production +# See https://docs.djangoproject.com/en/dev/howto/deployment/checklist/ + +# SECURITY WARNING: keep the secret key used in production secret! +SECRET_KEY = None + +# SECURITY WARNING: don't run with debug turned on in production! +DEBUG = False + +ALLOWED_HOSTS = [] + + +# Application definition + +INSTALLED_APPS = ( + 'django_extensions', + 'django.contrib.admin', + 'django.contrib.auth', + 'django.contrib.contenttypes', + 'django.contrib.sessions', + 'django.contrib.messages', + 'django.contrib.staticfiles', + 'django.contrib.sites', + 'haystack', + 'corsheaders', + 'tastypie', + 'guardian', + 'taggit', + 'taggit_templatetags', + 'registration', + 'oauth_provider', + 'social.apps.django_app.default', + 'sorl.thumbnail', + 'ldt', + 'ldt.core', + 'ldt.security', + 'ldt.user', + 'ldt.ldt_utils', + 'ldt.text', + 'ldt.management', + 'ldt.indexation', + 'chunked_uploads', + 'remie' +) + +MIDDLEWARE_CLASSES = ( + 'django.middleware.cache.UpdateCacheMiddleware', + 'django.middleware.cache.FetchFromCacheMiddleware', + 'corsheaders.middleware.CorsMiddleware', + 'django.contrib.sessions.middleware.SessionMiddleware', + 'django.middleware.common.CommonMiddleware', + 'django.middleware.gzip.GZipMiddleware', + 'django.middleware.csrf.CsrfViewMiddleware', + 'django.contrib.auth.middleware.AuthenticationMiddleware', + 'django.contrib.auth.middleware.SessionAuthenticationMiddleware', + 'django.contrib.messages.middleware.MessageMiddleware', + 'django.middleware.clickjacking.XFrameOptionsMiddleware', + 'django.middleware.security.SecurityMiddleware', + 'ldt.ldt_utils.middleware.swfupload.SWFUploadMiddleware', + 'ldt.ldt_utils.middleware.userprofile.LanguageMiddleware', + 'ldt.security.middleware.SecurityMiddleware', +) + +ROOT_URLCONF = 'remieplt.urls' + +TEMPLATES = [ + { + 'BACKEND': 'django.template.backends.django.DjangoTemplates', + 'DIRS': [os.path.join(os.path.dirname(os.path.dirname(__file__)), 'templates')], + 'APP_DIRS': True, + 'OPTIONS': { + 'context_processors': [ + 'django.template.context_processors.debug', + 'django.template.context_processors.request', + 'django.contrib.auth.context_processors.auth', + 'django.template.context_processors.i18n', + 'django.template.context_processors.media', + 'django.template.context_processors.static', + 'django.template.context_processors.tz', + 'django.contrib.messages.context_processors.messages', + 'ldt.utils.context_processors.ldt_context', + ], + }, + }, +] + +WSGI_APPLICATION = 'remieplt.wsgi.application' + + +# Database +# https://docs.djangoproject.com/en/dev/ref/settings/#databases + +DATABASES = { + 'default': { + 'ENGINE': 'django.db.backends.sqlite3', + 'NAME': os.path.abspath(os.path.join(BASE_DIR, '..', '..', 'run', 'db.sqlite3')), + } +} + + +# Internationalization +# https://docs.djangoproject.com/en/dev/topics/i18n/ + +LANGUAGE_CODE = 'en-us' + +TIME_ZONE = 'UTC' + +USE_I18N = True + +USE_L10N = True + +USE_TZ = True + +ugettext = lambda s: s + +LANGUAGES = ( + ('fr', ugettext('French')), + ('en', ugettext('English')), + ('ja', ugettext('Japanese')), +) + +SITE_ID = 1 + +# Static files (CSS, JavaScript, Images) +# https://docs.djangoproject.com/en/dev/howto/static-files/ + +STATIC_URL = '/static/' + + +AUTH_USER_MODEL = 'user.LdtUser' + +AUTHENTICATION_BACKENDS = ( +# 'social.backends.open_id.OpenIdAuth', +# 'social.backends.google.GoogleOpenId', +# 'social.backends.twitter.TwitterOAuth', +# 'social.backends.facebook.FacebookOAuth2', + 'guardian.backends.ObjectPermissionBackend', + 'django.contrib.auth.backends.ModelBackend', +) + + +ADMINS = ( + #('Your Name', 'your_email@domain.com'), +) + +MANAGERS = ADMINS + + + +# Registration settings +ACCOUNT_ACTIVATION_DAYS = 7 +REGISTRATION_OPEN = False + + +# ldt settings +DECOUPAGE_BLACKLIST = ( + "de_PPP", +) + +ZIP_BLACKLIST = ( + "__MACOSX", +) + +LDT_MAX_SEARCH_NUMBER = 50 +LDT_JSON_DEFAULT_INDENT = 2 +LDT_MAX_FRAGMENT_PER_SEARCH = 3 +LDT_RESULTS_PER_PAGE = 10 +LDT_MAX_CONTENTS_PER_PAGE = 10 +LDT_MAX_PROJECTS_PER_PAGE = 10 +LDT_FRONT_MEDIA_PER_PAGE = 9 +LDT_FRONT_PROJECTS_PER_PAGE = 12 +LDT_MEDIA_IN_RESULTS_PAGE = 6 + +TEST_WEBSERVER_ADDRPORT = "127.0.0.1:8888" + +EMPTY_MEDIA_EXTERNALID = None + + +SOCIAL_AUTH_COMPLETE_URL_NAME = 'complete' +SOCIAL_AUTH_ASSOCIATE_URL_NAME = 'associate_complete' + +AUTO_INDEX_AFTER_SAVE = True + +ANONYMOUS_USER_ID = -1 + +WEB_VERSION = remieplt.get_version() + +DIVISIONS_FOR_STAT_ANNOTATION = 64 + +FRONT_TAG_LIST = [] + +DEFAULT_CONTENT_ICON = "thumbnails/contents/content_default_icon.png" +DEFAULT_PROJECT_ICON = "thumbnails/projects/project_default_icon.png" +DEFAULT_USER_ICON = "thumbnails/users/user_default_icon.png" +DEFAULT_GROUP_ICON = "thumbnails/groups/group_default_icon.png" +PROFILE_IMG_MAX_SIZE = 1000000 + +USE_GROUP_PERMISSIONS = ['Project', 'Content', 'Media'] +FORBIDDEN_STREAM_URL = "rtmp://media.iri.centrepompidou.fr/ddc_player/mp4:video/forbidden_stream.mp4?old_path=" +PUBLIC_GROUP_NAME = 'everyone' +MAX_USERS_SEARCH = 20 + +SYNTAX = { + '++' : 'OK', + '--' : 'KO', + '==' : 'REF', + '??' : 'Q' + } + +EXTERNAL_STREAM_SRC = ['youtube.com', 'dailymotion.com', 'vimeo.com'] + +HAYSTACK_CONNECTIONS = { + 'default': { + 'ENGINE': 'haystack.backends.simple_backend.SimpleEngine', + }, +} +HAYSTACK_SIGNAL_PROCESSOR = 'ldt.indexation.signals.LdtSignalProcessor' +LDT_INDEXATION_INSERT_BATCH_SIZE = 5000 + + +#Cors headers for API +CORS_ORIGIN_ALLOW_ALL = True + + +MAX_TAG_LENGTH = 255 +FORCE_LOWERCASE_TAGS = True + +TAGGIT_TAGCLOUD_MIN = 1.0 +TAGGIT_TAGCLOUD_MAX = 12.0 + +EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend' diff -r a2f733f900c0 -r fc0f3e398166 server/src/remieplt/settings/dev.py.tmpl --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/server/src/remieplt/settings/dev.py.tmpl Fri May 29 02:22:11 2015 +0200 @@ -0,0 +1,161 @@ +# -*- coding: utf-8 -*- +from remieplt.settings import * +import os, logging + +#TODO override +DEBUG = True +TEMPLATE_DEBUG = DEBUG + + +BASE_URL = '%(base_url)s' +WEB_URL = '%(web_url)s' + +PLATFORM_BASE_URL = WEB_URL + BASE_URL + 'remieplt/' + +STREAM_SRC_PREFIX = "" + +BASE_STATIC_URL = WEB_URL + BASE_URL + 'static/' +BASE_STATIC_ROOT = os.path.abspath(BASE_DIR + "../../web/static/").rstrip("/")+"/" + +STREAM_URL = BASE_STATIC_URL + "/content/" + + +# Absolute path to the directory that holds media. +# Example: "/home/media/media.lawrence.com/" +MEDIA_ROOT = BASE_STATIC_ROOT + "media/" + +# URL that handles the media served from MEDIA_ROOT. Make sure to use a +# trailing slash if there is a path component (optional in other cases). +# Examples: "http://media.lawrence.com", "http://example.com/media/" +MEDIA_URL = BASE_STATIC_URL + 'media/' + + +STATIC_URL = BASE_STATIC_URL + 'site/' + +# Absolute path to the directory that static files (js, css, swf...) +# DO NOT forget to do command line ./manage.py collectstatic to gather static media into the web/static folder +STATIC_ROOT = BASE_STATIC_ROOT + "site/" + +CONTENT_ROOT = MEDIA_ROOT + "/content/" + +STREAM_PATH = CONTENT_ROOT + + +SRC_BASE_URL = BASE_URL + __name__.split('.')[0] + '/' + +LOGIN_URL = SRC_BASE_URL + 'accounts/login/' +LOGOUT_URL = SRC_BASE_URL + 'accounts/disconnect/' +LOGIN_REDIRECT_URL = SRC_BASE_URL + 'ldt/' +LOGOUT_REDIRECT_URL = SRC_BASE_URL + 'accounts/login' +PROFILE_REDIRECT_URL = SRC_BASE_URL + 'auth_accounts/create/profile' +LOGIN_ERROR_URL = SRC_BASE_URL + 'accounts/login' + + +CORS_URLS_REGEX = r"^" + BASE_URL + 'ldtplatform/api/.*$' + + +# Make this unique, and don't share it with anybody. +SECRET_KEY = '%(secret_key)s' + +# PATH to the ffmpeg executable, used to know automatically the media file duration +FFMPEG_PATH = "" + + +DATABASES = { + 'default': { + 'ENGINE': 'django.db.backends.%(db_engine)s', # Add 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'. + 'NAME': '%(db_name)s', # Or path to database file if using sqlite3. + 'USER': '%(db_user)s', # Not used with sqlite3. + 'PASSWORD': '%(db_password)s', # Not used with sqlite3. + 'HOST': '%(db_host)s', # Set to empty string for localhost. Not used with sqlite3. + 'PORT': '%(db_port)d', # Set to empty string for default. Not used with sqlite3. + }, +} + +LOG_FILE = os.path.abspath(os.path.join(BASE_DIR,"../run/log/log.txt")) +LOG_LEVEL = logging.DEBUG + +LOGGING = { + 'version': 1, + 'disable_existing_loggers': False, + 'filters': { + 'require_debug_false': { + '()': 'django.utils.log.RequireDebugFalse' + } + }, + 'formatters' : { + 'simple' : { + 'format': "%(asctime)s - %(levelname)s : %(message)s", + }, + 'semi-verbose': { + 'format': '%(levelname)s %(asctime)s %(module)s %(message)s' + }, + }, + 'handlers': { + 'mail_admins': { + 'level': 'ERROR', + 'filters': ['require_debug_false'], + 'class': 'django.utils.log.AdminEmailHandler' + }, + 'stream_to_console': { + 'level': LOG_LEVEL, + 'class': 'logging.StreamHandler' + }, + 'file': { + 'level': LOG_LEVEL, + 'class': 'logging.FileHandler', + 'filename': LOG_FILE, + 'formatter': 'semi-verbose', + }, + }, + 'loggers': { +# 'django.db.backends':{ +# 'handlers': ['file'], +# 'level': LOG_LEVEL, +# 'propagate': True, +# }, + 'django.request': { + 'handlers': ['file'], + 'level': LOG_LEVEL, + 'propagate': True, + }, + 'ldt': { + 'handlers': ['file'], + 'level': LOG_LEVEL, + 'propagate': True, + }, +# 'pyelasticsearch': { +# 'handlers': ['file'], +# 'level': LOG_LEVEL, +# 'propagate': True, +# }, + } +} + + +ADMINS = ( + #('Your Name', 'your_email@domain.com'), +) + +MANAGERS = ADMINS + +GOOGLE_ANALYTICS_CODE = None + + +ACCOUNT_ACTIVATION_DAYS = 7 +REGISTRATION_OPEN = False + +LDT_MAX_SEARCH_NUMBER = 50 +LDT_JSON_DEFAULT_INDENT = 2 + +EMPTY_MEDIA_EXTERNALID = None + +FRONT_TAG_LIST = [u"Enmi 2011", u"film", u"conférence"] + +HAYSTACK_CONNECTIONS = { + 'default': { + 'ENGINE': 'ldt.indexation.backends.elasticsearch_backend.ElasticsearchSearchEngine', + 'URL': 'http://127.0.0.1:9200/', + 'INDEX_NAME': 'ldt', + }, +} diff -r a2f733f900c0 -r fc0f3e398166 server/src/remieplt/templates/admin/base_site.html --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/server/src/remieplt/templates/admin/base_site.html Fri May 29 02:22:11 2015 +0200 @@ -0,0 +1,21 @@ +{% extends "admin/base.html" %} +{% load i18n %} + +{% block title %}{{ title }} | {% trans 'Django site admin' %}{% endblock %} + +{% block branding %} +

{% trans 'Django administration' %}

+{% endblock %} + +{% block nav-global %} + + + Admin home + Website home +{% endblock %} \ No newline at end of file diff -r a2f733f900c0 -r fc0f3e398166 server/src/remieplt/templates/ldt/ldt_utils/workspace.html --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/server/src/remieplt/templates/ldt/ldt_utils/workspace.html Fri May 29 02:22:11 2015 +0200 @@ -0,0 +1,2 @@ +{% extends "ldt/ldt_utils/workspace_base.html" %} + diff -r a2f733f900c0 -r fc0f3e398166 server/src/remieplt/templates/registration/login.html --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/server/src/remieplt/templates/registration/login.html Fri May 29 02:22:11 2015 +0200 @@ -0,0 +1,55 @@ +{% extends "registration/base.html" %} +{% load i18n %} +{% load static %} + +{% block css_import %} + {{ block.super }} + + +{% endblock %} + +{% block login %} +{% endblock %} + +{% block content_title %}{% trans 'Log in' %}{% endblock %} +{% block iricontent %} + {% if form.errors %} +

{% trans "Sorry, that's not a valid username or password." %}

+ {% endif %} +
+
+
+ {% csrf_token %} + +
    + {{form.as_ul}} +
+ +
+ +
+
+
+ +
+ +{% endblock %} + + + diff -r a2f733f900c0 -r fc0f3e398166 server/src/remieplt/urls.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/server/src/remieplt/urls.py Fri May 29 02:22:11 2015 +0200 @@ -0,0 +1,54 @@ +"""remieplt URL Configuration + +The `urlpatterns` list routes URLs to views. For more information please see: + https://docs.djangoproject.com/en/dev/topics/http/urls/ +Examples: +Function views + 1. Add an import: from my_app import views + 2. Add a URL to urlpatterns: url(r'^$', views.home, name='home') +Class-based views + 1. Add an import: from other_app.views import Home + 2. Add a URL to urlpatterns: url(r'^$', Home.as_view(), name='home') +Including another URLconf + 1. Add an import: from blog import urls as blog_urls + 2. Add a URL to urlpatterns: url(r'^blog/', include(blog_urls)) +""" +from ldt.auth.views import login as pf_login +from ldt.text import VERSION_STR + +from django.conf import settings +from django.conf.urls import include, url +from django.conf.urls.static import static +from django.contrib import admin +from django.contrib.staticfiles.urls import staticfiles_urlpatterns +from django.views.generic import RedirectView + + +js_info_dict = { + 'packages': ('django.contrib.admin',), +} + +urlpatterns = [ + url(r'^admin/', include(admin.site.urls)), + url(r'^i18n/', include('django.conf.urls.i18n')), + + url(r'^ldt/', include('ldt.ldt_utils.urls')), + url(r'^user/', include('ldt.user.urls')), + url(r'^api/', include('ldt.api.urls')), + url(r'^api/' + VERSION_STR + '/text/', include('ldt.text.urls')), + + url(r'^auth_accounts/', include('registration.backends.simple.urls')), + + url(r'^accounts/', include('social.apps.django_app.urls', namespace='social')), + url(r'^accounts/login/$',pf_login,{'template_name': 'registration/login.html'},name='auth_login'), + url(r'^oauth/', include('oauth_provider.urls')), + + + url(r'^/?$', RedirectView.as_view(url='ldt')), + + url(r'^jsi18n/$', 'django.views.i18n.javascript_catalog', js_info_dict), + +] + +urlpatterns += staticfiles_urlpatterns() +urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT) diff -r a2f733f900c0 -r fc0f3e398166 server/src/remieplt/wsgi.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/server/src/remieplt/wsgi.py Fri May 29 02:22:11 2015 +0200 @@ -0,0 +1,16 @@ +""" +WSGI config for remieplt project. + +It exposes the WSGI callable as a module-level variable named ``application``. + +For more information on this file, see +https://docs.djangoproject.com/en/dev/howto/deployment/wsgi/ +""" + +import os + +from django.core.wsgi import get_wsgi_application + +os.environ.setdefault("DJANGO_SETTINGS_MODULE", "remieplt.settings") + +application = get_wsgi_application() diff -r a2f733f900c0 -r fc0f3e398166 server/src/requirement.txt --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/server/src/requirement.txt Fri May 29 02:22:11 2015 +0200 @@ -0,0 +1,1 @@ +ldt (==1.56.3) diff -r a2f733f900c0 -r fc0f3e398166 server/src/setup.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/server/src/setup.py Fri May 29 02:22:11 2015 +0200 @@ -0,0 +1,125 @@ +import os +from distutils.core import setup +from distutils.command.install_data import install_data +from distutils.command.install import INSTALL_SCHEMES +import sys + + +class osx_install_data(install_data): + # On MacOS, the platform-specific lib dir is /System/Library/Framework/Python/.../ + # which is wrong. Python 2.5 supplied with MacOS 10.5 has an Apple-specific fix + # for this in distutils.command.install_data#306. It fixes install_lib but not + # install_data, which is why we roll our own install_data class. + + def finalize_options(self): + # By the time finalize_options is called, install.install_lib is set to the + # fixed directory, so we set the installdir to install_lib. The + # install_data class uses ('install_data', 'install_dir') instead. + self.set_undefined_options('install', ('install_lib', 'install_dir')) + install_data.finalize_options(self) + +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) + + +def launch_setup(script_name, script_args): + if sys.platform == "darwin": + cmdclasses = {'install_data': osx_install_data} + else: + cmdclasses = {'install_data': install_data} + + + root_dir = os.path.dirname(__file__) + if root_dir != '': + os.chdir(root_dir) + source_dirs = ['remieplt', 'remie'] + + version_variables = {} + try: + execfile(os.path.join(source_dirs[0], "__init__.py"), version_variables) + except: + pass + + version = version_variables['__version__'] + + packages, data_files = [], [] + + for source_dir in source_dirs: + for dirpath, dirnames, filenames in os.walk(source_dir): + # Ignore dirnames that start with '.' + for i, dirname in enumerate(dirnames): + if dirname.startswith('.'): del dirnames[i] + if '__init__.py' in filenames: + packages.append('.'.join(fullsplit(dirpath))) + elif filenames: + data_files.append([dirpath, [os.path.join(dirpath, f) for f in filenames]]) + + + # Tell distutils to put the data_files in platform-specific installation + # locations. See here for an explanation: + # http://groups.google.com/group/comp.lang.python/browse_thread/thread/35ec7b2fed36eaec/2105ee4d9e8042cb + for scheme in INSTALL_SCHEMES.values(): + scheme['data'] = scheme['purelib'] + + # Small hack for working with bdist_wininst. + # See http://mail.python.org/pipermail/distutils-sig/2004-August/004134.html + if len(sys.argv) > 1 and sys.argv[1] == 'bdist_wininst': + for file_info in data_files: + file_info[0] = '\\PURELIB\\%s' % file_info[0] + + #write MANIFEST.in + + with open("MANIFEST.in", "w") as m: + m.write("include CHANGES\n") + m.write("include LICENSE\n") + m.write("include README\n") + m.write("include MANIFEST.in\n") + for entry in data_files: + file_list = entry[1] + for filename in file_list: + m.write("include %s\n" % (filename)) + + setup( + script_name = script_name, + script_args = script_args, + name='remie', + version=version, + author='IRI', + author_email='contact@iri.centrepompidou.fr', + packages=packages, + data_files=data_files, + cmdclass = cmdclasses, + scripts=[], + url='http://www.iri.centrepompidou.fr/dev/hg/remie', + license='LICENSE', + description='Platform remie', + long_description=open('README').read(), + classifiers=['Development Status :: 4 - Beta', + 'Environment :: Web Environment', + 'Framework :: Django', + 'Intended Audience :: Developers', + 'License :: Ceccil-C', + 'Operating System :: OS Independent', + 'Programming Language :: Python', + 'Topic :: Utilities', + ], + ) + + +if __name__ == "__main__": + + script_name = os.path.basename(sys.argv[0]) + script_args = sys.argv[1:] + + launch_setup(script_name, script_args) diff -r a2f733f900c0 -r fc0f3e398166 server/virtualenv/res/lib/lib_create_env.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/server/virtualenv/res/lib/lib_create_env.py Fri May 29 02:22:11 2015 +0200 @@ -0,0 +1,434 @@ +import sys +import os +import os.path +import shutil +import tarfile +import zipfile +import urllib +import platform +import patch +import struct +import glob +import re + +join = os.path.join +system_str = platform.system() + +URLS = { + #'': {'setup': '', 'url':'', 'local':''}, + 'DISTRIBUTE': {'setup': 'distribute', 'url':'http://pypi.python.org/packages/source/d/distribute/distribute-0.6.34.tar.gz', 'local':"distribute-0.6.34.tar.gz", 'install': {'method': 'pip', 'option_str': None, 'dict_extra_env': None}}, + 'DJANGO': {'setup': 'django', 'url': 'https://github.com/IRI-Research/django/archive/d11d79737105223c99d15b3956837c1246f60441.tar.gz', 'local':"django-1.8.2.dev.tar.gz", 'install': {'method': 'pip', 'option_str': None, 'dict_extra_env': None}}, + 'DJANGO-EXTENSIONS': { 'setup': 'django-extensions', 'url':'https://github.com/django-extensions/django-extensions/archive/1.5.3.tar.gz', 'local':"django-extensions-1.5.3.tar.gz", 'install': {'method': 'pip', 'option_str': None, 'dict_extra_env': None}}, + 'DJANGO-REGISTRATION': { 'setup': 'django-registration', 'url':'https://github.com/macropin/django-registration/archive/v1.2.tar.gz', 'local':"django-registration-redux-1.2.tar.gz", 'install': {'method': 'easy_install', 'option_str': '-Z', 'dict_extra_env': None}}, + 'DJANGO-TEMPLATETAG-SUGAR': { 'setup': 'django-templatetag-sugar', 'url': 'https://github.com/alex/django-templatetag-sugar/archive/1.0.tar.gz', 'local': 'django-templatetag-sugar-1.0.tar.gz', 'install': {'method': 'pip', 'option_str': None, 'dict_extra_env': None}}, + 'DJANGO-TAGGIT': { 'setup': 'django-taggit', 'url':'https://github.com/alex/django-taggit/archive/0.14.0.tar.gz', 'local':"django-taggit-0.14.0.tar.gz", 'install': {'method': 'pip', 'option_str': None, 'dict_extra_env': None}}, + 'DJANGO-TAGGIT-TEMPLATETAGS': { 'setup': 'django-taggit-templatetags', 'url':'https://github.com/feuervogel/django-taggit-templatetags/archive/d2216c9d1888e0739a04899a36e5149b5cbb3381.zip', 'local':"django-taggit-templatetags-0.4.5dev-r0.zip", 'install': {'method': 'pip', 'option_str': None, 'dict_extra_env': None}}, + 'OAUTH2': { 'setup': 'python-oauth2', 'url':"https://github.com/simplegeo/python-oauth2/tarball/hudson-python-oauth2-211", 'local':"oauth2-1.5.211.tar.gz", 'install': {'method': 'easy_install', 'option_str': None, 'dict_extra_env': None}}, + 'HTTPLIB2': { 'setup': 'python-httplib2', 'url':'https://pypi.python.org/packages/source/h/httplib2/httplib2-0.9.1.tar.gz', 'local':"httplib2-0.9.1.tar.gz", 'install': {'method': 'pip', 'option_str': None, 'dict_extra_env': None}}, + 'DJANGO-OAUTH-PLUS': { 'setup': 'django-oauth-plus', 'url':'https://pypi.python.org/packages/source/d/django-oauth-plus/django-oauth-plus-2.2.6.tar.gz', 'local':"django-oauth-plus-2.2.6.tar.gz", 'install': {'method': 'pip', 'option_str': None, 'dict_extra_env': None}}, + 'OPENID': {'setup':'openid', 'url':'http://pypi.python.org/packages/source/p/python-openid/python-openid-2.2.5.tar.gz', 'local':"python-openid-2.2.5.tar.gz", 'install': {'method': 'pip', 'option_str': None, 'dict_extra_env': None}}, + 'SOCIAL_AUTH': {'setup':'social_auth', 'url':'https://github.com/omab/python-social-auth/archive/v0.2.7.tar.gz', 'local':"python-social-auth-0.2.7.tar.gz", 'install': {'method': 'pip', 'option_str': None, 'dict_extra_env': None}}, + 'DJANGO_GUARDIAN' : { 'setup': 'django-guardian', 'url':'https://github.com/TauPan/django-guardian/archive/full-django-1.8-compatibility.tar.gz', 'local':"django-guardian-1.2.6.dev.tar.gz", 'install': {'method': 'pip', 'option_str': None, 'dict_extra_env': None}}, + 'SORL_THUMBNAIL' : { 'setup': 'sorl-thumbnail', 'url':'https://github.com/mariocesar/sorl-thumbnail/archive/v12.2.tar.gz', 'local':"sorl-thumbnail-12.2.tar.gz", 'install': {'method': 'pip', 'option_str': None, 'dict_extra_env': None}}, + 'LIBJPEG': {'setup': None, 'url':'jpegsrc.v9.tar.gz', 'local':'jpegsrc.v9.tar.gz', 'install': {'method': 'install_libjpeg', 'option_str': None, 'dict_extra_env': None}}, + 'ZLIB': {'setup': None, 'url':'zlib-1.2.8.tar.gz', 'local':'zlib-1.2.8.tar.gz', 'install': {'method': 'install_zlib', 'option_str': None, 'dict_extra_env': None}}, + 'HAYSTACK': {'setup': 'django-haystack', 'url': 'https://github.com/toastdriven/django-haystack/archive/v2.3.1.tar.gz', 'local': 'django-haystack-2.3.1.tar.gz', 'install':{'method':'pip', 'option_str': None, 'dict_extra_env': None}}, + 'REQUESTS': {'setup': 'requests', 'url':'https://github.com/kennethreitz/requests/archive/v2.7.0.tar.gz', 'local':'requests-2.7.0.tar.gz', 'install' : {'method':'pip', 'option_str': None, 'dict_extra_env': None}}, + 'ELASTICSEARCH': {'setup': 'elasticsearch', 'url':'https://github.com/elastic/elasticsearch-py/archive/1.4.0.tar.gz', 'local':'elasticsearch-1.4.0.tar.gz', 'install' : {'method':'pip', 'option_str': None, 'dict_extra_env': None}}, + 'PYELASTICSEARCH': {'setup': 'pyelasticsearch', 'url':'https://pypi.python.org/packages/source/p/pyelasticsearch/pyelasticsearch-1.2.3.tar.gz', 'local':'pyelasticsearch-1.2.3.tar.gz', 'install' : {'method':'pip', 'option_str': None, 'dict_extra_env': None}}, + 'WHOOSH': {'setup': 'whoosh', 'url':'https://bitbucket.org/mchaput/whoosh/get/2.7.0.tar.gz', 'local':'whoosh-2.7.0.tar.gz', 'install' : {'method':'pip', 'option_str': None, 'dict_extra_env': None}}, + 'SETUPTOOLS_HG' : {'setup':'setuptools_hg', 'url':'https://bitbucket.org/jezdez/setuptools_hg/get/v0.4.tar.gz', 'local': 'setuptools_hg-0.4.tar.gz', 'install' : {'method':'pip', 'option_str': None, 'dict_extra_env': None}}, + # dependencies for Tastypie : mimeparse>=0.1.3, python-dateutil>=2.1, lxml, PyYAML (not necessary but we never know), python-digest, defusedxml + 'MIMEPARSE' : {'setup':'mimeparse', 'url':'http://pypi.python.org/packages/source/m/mimeparse/mimeparse-0.1.3.tar.gz', 'local': 'mimeparse-0.1.3.tar.gz', 'install' : {'method':'pip', 'option_str': None, 'dict_extra_env': None}}, + 'SIX' : {'setup':'six', 'url':'https://pypi.python.org/packages/source/s/six/six-1.9.0.tar.gz', 'local': 'six-1.9.0.tar.gz', 'install' : {'method':'pip', 'option_str': None, 'dict_extra_env': None}}, + 'PYTHON-DATEUTIL' : {'setup':'python-dateutil', 'url':'https://pypi.python.org/packages/source/p/python-dateutil/python-dateutil-2.1.tar.gz', 'local': 'python-dateutil-2.1.tar.gz', 'install' : {'method':'pip', 'option_str': None, 'dict_extra_env': None}}, + 'PYYAML' : {'setup':'pyyaml', 'url':'http://pypi.python.org/packages/source/P/PyYAML/PyYAML-3.11.tar.gz', 'local': 'PyYAML-3.11.tar.gz', 'install' : {'method':'pip', 'option_str': None, 'dict_extra_env': None}}, + 'PYTHON-DIGEST' : {'setup':'python-digest', 'url':'http://pypi.python.org/packages/source/p/python-digest/python-digest-1.7.tar.gz', 'local': 'python-digest-1.7.tar.gz', 'install' : {'method':'pip', 'option_str': None, 'dict_extra_env': None}}, + 'DEFUSEDXML' : {'setup':'defusedxml', 'url':'https://pypi.python.org/packages/source/d/defusedxml/defusedxml-0.4.1.tar.gz', 'local': 'defusedxml-0.4.1.tar.gz', 'install' : {'method':'pip', 'option_str': None, 'dict_extra_env': None}}, + 'DJANGO-TASTYPIE' : {'setup':'django-tastypie', 'url':'https://github.com/toastdriven/django-tastypie/archive/130cb64eb6c0e688b1efe3b9839fbd86f034b4ed.tar.gz', 'local': 'django-tastypie-0.12.2.dev0.tar.gz', 'install' : {'method':'pip', 'option_str': None, 'dict_extra_env': None}}, + 'DJANGO-CORS-HEADERS' : {'setup':'django-cors-headers', 'url':'https://github.com/ottoyiu/django-cors-headers/archive/1.0.0.tar.gz', 'local': 'django-cors-headers-1.0.0.tar.gz', 'install' : {'method':'pip', 'option_str': None, 'dict_extra_env': None}}, + 'DJANGO-CHUNCKED-UPLOADS' : {'setup': 'django-chuncked-uploads', 'url':'https://github.com/IRI-Research/django-chunked-uploads/archive/v0.6.tar.gz', 'local':'django-chunked-uploads-0.6.tar.gz', 'install' : {'method':'pip', 'option_str': None, 'dict_extra_env': None}}, + 'OAUTHLIB': { 'setup': 'oauthlib', 'url':"https://github.com/idan/oauthlib/archive/0.7.2.tar.gz", 'local':"oauthlib-0.7.2.tar.gz", 'install': {'method': 'pip', 'option_str': None, 'dict_extra_env': None}}, + 'URLLIB3': { 'setup': 'urllib3', 'url':'https://github.com/shazow/urllib3/archive/1.10.4.tar.gz', 'local':"urllib3-1.10.4.tar.gz", 'install': {'method': 'pip', 'option_str': None, 'dict_extra_env': None}}, + 'SIMPLEJSON' : { 'setup': 'simplejson', 'url': 'https://github.com/simplejson/simplejson/archive/v3.6.5.tar.gz', 'local' : 'simplejson-3.6.5.tar.gz', 'install': {'method': 'pip', 'option_str': None, 'dict_extra_env': None}}, + 'PYJWT' : { 'setup': 'pyjwt', 'url': 'https://github.com/jpadilla/pyjwt/archive/1.1.0.tar.gz', 'local' : 'pyjwt-1.1.0.tar.gz', 'install': {'method': 'pip', 'option_str': None, 'dict_extra_env': None}}, + 'PYTHON-MIMEPARSE': { 'setup': 'python-mimeparse', 'url': 'https://pypi.python.org/packages/source/p/python-mimeparse/python-mimeparse-0.1.4.tar.gz', 'local' : 'python-mimeparse-0.1.4.tar.gz', 'install': {'method': 'pip', 'option_str': None, 'dict_extra_env': None}}, + 'REQUESTS-OAUTHLIB': { 'setup': 'requests-oauthlib', 'url': 'https://github.com/requests/requests-oauthlib/archive/v0.5.0.tar.gz', 'local' : 'requests-oauthlib-0.5.0.tar.gz', 'install': {'method': 'pip', 'option_str': None, 'dict_extra_env': None}}, + 'SOUTH': { 'setup': 'South', 'url':'http://www.aeracode.org/releases/south/south-1.0.2.tar.gz', 'local':"south-1.0.2.tar.gz", 'install': {'method': 'pip', 'option_str': None, 'dict_extra_env': None}}, +} + +if system_str == 'Windows': + + size = 8 * struct.calcsize("P") + if size==32: + mysqlres = "MySQL-python-1.2.3.win32-py2.7.exe" + else: + mysqlres = "MySQL-python-1.2.3.win-amd64-py2.7.exe" + + URLS.update({ + 'PSYCOPG2': {'setup': 'psycopg2','url': 'psycopg2-2.4.6.win32-py2.7-pg9.2.2-release.exe', 'local':"psycopg2-2.4.6.win32-py2.7-pg9.2.2-release.exe", 'install': {'method': 'install_psycopg2', 'option_str': None, 'dict_extra_env': None}}, + 'PIL': {'setup': 'pil', 'url': 'http://effbot.org/media/downloads/PIL-1.1.7.win32-py2.7.exe', 'local':"PIL-1.1.7.win32-py2.7.exe", 'install': {'method': 'easy_install', 'option_str': None, 'dict_extra_env': None}}, + 'LXML': {'setup': 'lxml', 'url': 'http://pypi.python.org/packages/2.7/l/lxml/lxml-2.3-py2.7-win32.egg', 'local':"lxml-2.3-py2.7-win32.egg", 'install': {'method': 'easy_install', 'option_str': None, 'dict_extra_env': None}}, + 'MYSQL': { 'setup': 'mysql-python', 'url': mysqlres, 'local': mysqlres, 'install': {'method': 'easy_install', 'option_str': None, 'dict_extra_env': None}}, + }) +else: + if system_str == "Darwin": + lxml_options = {'STATIC_DEPS': 'true', 'LIBXML2_VERSION': '2.9.2', 'LIBXSLT_VERSION': '1.1.28', 'LIBICONV_VERSION': '1.14'} + if os.path.exists('/usr/local/opt/xz'): + if not os.path.exists('/usr/local/opt/libxml2'): + sys.exit("You have installed xz with Homebrew but do not have libxml2 installed with Homebrew. Install libxml2 with Homebrew and try again.") + lxml_options = {'LDFLAGS': '-L/usr/local/opt/libxml2/lib', 'CPPFLAGS': '-I/usr/local/opt/libxml2/include'} + mysql_method = 'install_mysql' + else: + lxml_options = None + mysql_method = 'pip' + + URLS.update({ + 'PSYCOPG2': {'setup': 'psycopg2','url': 'http://initd.org/psycopg/tarballs/PSYCOPG-2-6/psycopg2-2.6.tar.gz', 'local':"psycopg2-2.6.tar.gz", 'install': {'method': 'pip', 'option_str': None, 'dict_extra_env': None}}, + 'PIL': {'setup': 'pillow', 'url': 'https://github.com/python-pillow/Pillow/archive/2.8.1.tar.gz', 'local':"Pillow-2.8.1.tar.gz", 'install': {'method': 'pip', 'option_str': None, 'dict_extra_env': None}}, + 'LXML': {'setup': 'lxml', 'url': 'lxml-3.2.1.tar.bz2', 'local': 'lxml-3.2.1.tar.bz2', 'install': {'method': 'pip', 'option_str': None, 'dict_extra_env': lxml_options}}, + 'MYSQL': { 'setup': 'mysql-python', 'url': 'http://downloads.sourceforge.net/project/mysql-python/mysql-python-test/1.2.4b4/MySQL-python-1.2.4b4.tar.gz', 'local':"MySQL-python-1.2.4b4.tar.gz", 'install': {'method': mysql_method, 'option_str': None, 'dict_extra_env': None}}, + }) + + +class ResourcesEnv(object): + + def __init__(self, src_base, run_base, urls, normal_installs): + self.src_base = src_base + self.run_base = run_base + self.URLS = {} + self.__init_url(urls) + self.NORMAL_INSTALL = normal_installs + + def get_src_base_path(self, fpath): + return os.path.abspath(os.path.join(self.src_base, fpath)).replace("\\","/") + + def get_run_res_base_path(self, fpath): + return os.path.abspath(os.path.join(self.run_base, 'res', fpath)).replace("\\","/") + + def __add_package_def(self, key, dict): + self.URLS[key] = dict + + def __init_url(self, urls): + for key, url_dict in urls.items(): + url_dict_copy = url_dict.copy() + if url_dict.get('install', {}).get('method','pip') == 'pip-req': + get_base_path = self.get_run_res_base_path + else: + get_base_path = self.get_src_base_path + if not url_dict['url'].startswith("http://"): + url_dict_copy['url'] = get_base_path(url_dict['url']) + url_dict_copy['local'] = get_base_path(url_dict['local']) + + self.__add_package_def(key, url_dict_copy ) + +def ensure_dir(dir, logger): + logger.notify('Check directory %s' % dir) + if not os.path.exists(dir): + logger.notify('Creating directory %s' % dir) + os.makedirs(dir) + +def extend_parser(parser): + parser.add_option( + '--index-url', + metavar='INDEX_URL', + dest='index_url', + default='http://pypi.python.org/simple/', + help='base URL of Python Package Index') + parser.add_option( + '--type-install', + metavar='type_install', + dest='type_install', + help='type install : local, url, setup - default : local') + parser.add_option( + '--ignore-packages', + metavar='ignore_packages', + dest='ignore_packages', + default=None, + help='list of comma separated keys for package to ignore') + parser.add_option( + '--no-clear', + metavar='do not clear env', + dest='clear', + default=True, + action='store_false', + help='do not clear env') + + + +def install_psycopg2(option_str, extra_env, res_source_key, home_dir, lib_dir, tmp_dir, src_dir, res_env, logger, call_subprocess, filter_python_develop): + psycopg2_src = os.path.join(src_dir,"psycopg2.zip") + shutil.copy(res_env.URLS['PSYCOPG2'][res_source_key], psycopg2_src) + #extract psycopg2 + zf = zipfile.ZipFile(psycopg2_src) + psycopg2_base_path = os.path.join(src_dir,"psycopg2") + zf.extractall(psycopg2_base_path) + zf.close() + + psycopg2_src_path = os.path.join(psycopg2_base_path, os.listdir(psycopg2_base_path)[0]) + shutil.copytree(os.path.join(psycopg2_src_path, 'psycopg2'), os.path.abspath(os.path.join(home_dir, 'Lib/site-packages', 'psycopg2'))) + shutil.copy(os.path.join(psycopg2_src_path, 'psycopg2-2.4.5-py2.7.egg-info'), os.path.abspath(os.path.join(home_dir, 'Lib/site-packages', 'site-packages'))) + + +def install_mysql(option_str, extra_env, res_source_key, home_dir, lib_dir, tmp_dir, src_dir, res_env, logger, call_subprocess, filter_python_develop): + + args = [os.path.abspath(os.path.join(home_dir, 'bin', 'pip')), 'install', res_env.URLS['MYSQL'][res_source_key]] + if option_str : + args.insert(4,option_str) + call_subprocess(args, + cwd=os.path.abspath(tmp_dir), + filter_stdout=filter_python_develop, + show_stdout=True, + extra_env=extra_env) + + mysqlconfig_output = [] + + call_subprocess(['mysql_config', '--libmysqld-libs'], + cwd=os.path.abspath(tmp_dir), + filter_stdout=lambda line: mysqlconfig_output.append(line), + show_stdout=True) + + mysqlconfig_output = "".join(mysqlconfig_output) + m = re.search("\-L[\'\"]?([\w\/]+)[\'\"]?", mysqlconfig_output) + if m: + repdylibpath = m.group(1) + else: + repdylibpath = '/usr/local/mysql/lib' + + dyliblist = glob.glob(repdylibpath+"/libmysqlclient.*.dylib") + def key_func(s): + m = re.match(repdylibpath+"/libmysqlclient\.([\d]+)\.dylib", s) + if m: + return int(m.group(1)) + else: + return sys.maxint + dyliblist.sort(key=key_func) + + if dyliblist: + dylibpath = dyliblist[0] + else: + dylibpath = '/usr/local/mysql/lib/libmysqlclient.18.dylib' + + dylibname = os.path.basename(dylibpath) + sopath = os.path.join(os.path.abspath(lib_dir), 'site-packages', '_mysql.so') + + call_subprocess(['install_name_tool', '-change', dylibname, dylibpath, sopath], + cwd=os.path.abspath(tmp_dir), + filter_stdout=filter_python_develop, + show_stdout=True) + + +def gen_install_comp_lib(lib_name, lib_key, configure_options=[], configure_env={}): + + def install_lib(option_str, extra_env, res_source_key, home_dir, lib_dir, tmp_dir, src_dir, res_env, logger, call_subprocess, filter_python_develop): + lib_src = os.path.join(src_dir,lib_name+".tar.gz") + logger.notify("Copy %s to %s " % (res_env.URLS[lib_key][res_source_key],lib_src)) + shutil.copy(res_env.URLS[lib_key][res_source_key], lib_src) + tf = tarfile.open(lib_src,'r:gz') + lib_base_path = os.path.join(src_dir, lib_name) + logger.notify("Extract %s to %s " % (lib_name,lib_base_path)) + tf.extractall(lib_base_path) + tf.close() + + lib_src_path = os.path.join(lib_base_path, os.listdir(lib_base_path)[0]) + + + context_map = { + 'option_str' : option_str, + 'home_dir': os.path.abspath(home_dir), + 'lib_dir': os.path.abspath(lib_dir), + 'tmp_dir': os.path.abspath(tmp_dir), + 'src_dir': os.path.abspath(src_dir), + } + + configure_options_trans = map(lambda s: s % context_map, configure_options) + configure_env_trans = {k: s % context_map for k,s in configure_env.items()} + + logger.notify(lib_name + " configure in " + lib_src_path) + call_subprocess(['./configure', '--prefix='+os.path.abspath(home_dir)] + configure_options_trans, + cwd=os.path.abspath(lib_src_path), + filter_stdout=filter_python_develop, + show_stdout=True, + extra_env=configure_env_trans + ) + + logger.notify(lib_name + " make in " + lib_src_path) + call_subprocess(['make'], + cwd=os.path.abspath(lib_src_path), + filter_stdout=filter_python_develop, + show_stdout=True) + + logger.notify(lib_name + "make install in " + lib_src_path) + call_subprocess(['make', 'install'], + cwd=os.path.abspath(lib_src_path), + filter_stdout=filter_python_develop, + show_stdout=True) + return install_lib + +install_libjpeg = gen_install_comp_lib("libjpeg", "LIBJPEG", ['--enable-shared'], {}) +install_zlib = gen_install_comp_lib("zlib", "ZLIB", [], {}) + +#osx_extra_env = {'ARCHFLAGS': '-Wno-error=unused-command-line-argument-hard-error-in-future', 'CFLAGS': '-Qunused-arguments', 'CPPFLAGS': '-Qunused-arguments'} +osx_extra_env = {} + +def lib_generate_install_methods(path_locations, src_base, run_base, Logger, call_subprocess, normal_installs, options_to_add=None, urls= None): + + all_urls = URLS.copy() + if urls is not None: + all_urls.update(urls) + + res_env = ResourcesEnv(src_base, run_base, all_urls, normal_installs) + + def filter_python_develop(line): + if not line.strip(): + return Logger.DEBUG + for prefix in ['Searching for', 'Reading ', 'Best match: ', 'Processing ', + 'Moving ', 'Adding ', 'running ', 'writing ', 'Creating ', + 'creating ', 'Copying ']: + if line.startswith(prefix): + return Logger.DEBUG + return Logger.NOTIFY + + + def normal_install(key, res_path, method, option_str, extra_env, res_source_key, home_dir, tmp_dir, res_env, logger, call_subprocess): + logger.notify("Install %s from %s with %s" % (key,res_path,method)) + if method == 'pip': + if sys.platform == 'win32': + args = [os.path.abspath(os.path.join(home_dir, 'Scripts', 'pip')), 'install', res_path] + else: + args = [os.path.abspath(os.path.join(home_dir, 'bin', 'pip')), 'install', res_path] + if option_str : + args.append(option_str) + if res_source_key == 'local': + if extra_env is None: + extra_env = {} + args.insert(2, '-f') + args.insert(3, res_env.get_src_base_path("")) + args.insert(4, '--no-index') + logger.notify("Install %s from %s with %s args %s " % (key,res_path,method, repr(args))) + call_subprocess(args, + cwd=os.path.abspath(tmp_dir), + filter_stdout=filter_python_develop, + show_stdout=True, + extra_env=extra_env) + if method == 'pip-req': + if sys.platform == 'win32': + args = [os.path.abspath(os.path.join(home_dir, 'Scripts', 'pip')), 'install', '-r', res_path] + else: + args = [os.path.abspath(os.path.join(home_dir, 'bin', 'pip')), 'install', '-r', res_path] + if option_str : + args.append(option_str) + if res_source_key == 'local': + if extra_env is None: + extra_env = {} + args.insert(2, '-f') + args.insert(3, res_env.get_src_base_path("")) + args.insert(4, '--no-index') + logger.notify("Install %s from %s with %s args %s " % (key,res_path,method, repr(args))) + call_subprocess(args, + cwd=os.path.abspath(tmp_dir), + filter_stdout=filter_python_develop, + show_stdout=True, + extra_env=extra_env) + else: + if sys.platform == 'win32': + args = [os.path.abspath(os.path.join(home_dir, 'Scripts', 'easy_install')), res_path] + else: + args = [os.path.abspath(os.path.join(home_dir, 'bin', 'easy_install')), res_path] + if option_str : + args.insert(1,option_str) + call_subprocess(args, + cwd=os.path.abspath(tmp_dir), + filter_stdout=filter_python_develop, + show_stdout=True, + extra_env=extra_env) + + + def after_install(options, home_dir): + + global logger + + verbosity = options.verbose - options.quiet + logger = Logger([(Logger.level_for_integer(2-verbosity), sys.stdout)]) + + + home_dir, lib_dir, inc_dir, bin_dir = path_locations(home_dir) + base_dir = os.path.dirname(home_dir) + src_dir = os.path.join(home_dir, 'src') + tmp_dir = os.path.join(home_dir, 'tmp') + ensure_dir(src_dir, logger) + ensure_dir(tmp_dir, logger) + system_str = platform.system() + + res_source_key = getattr(options, 'type_install') if hasattr(options, 'type_install') else 'local' #.get('type_install', 'local') + if res_source_key is None: + res_source_key = 'local' + + ignore_packages = [] + + if system_str == 'Windows': + default_install_options = {'method': 'easy_install', 'option_str': None, 'dict_extra_env': {}} + else: + default_install_options = {'method': 'pip', 'option_str': None, 'dict_extra_env': {}} + + if options.ignore_packages : + ignore_packages = options.ignore_packages.split(",") + + logger.indent += 2 + try: + for key in res_env.NORMAL_INSTALL: + install_options = None + if isinstance(key, dict): + install_options = key.get('install', default_install_options) + install_options['method'] = 'pip-req' + res_path = res_env.get_run_res_base_path(key['requirement']) + else: + if key not in res_env.URLS: + logger.notify("%s not found in def : passing" % (key,)) + install_options = res_env.URLS[key].get('install', None) + res_path = res_env.URLS[key][res_source_key] + if install_options is None: + install_options = default_install_options + method = install_options.get('method', default_install_options['method']) + option_str = install_options.get('option_str', default_install_options['option_str']) + extra_env = install_options.get('dict_extra_env', default_install_options['dict_extra_env']) + if not extra_env: + extra_env = {} + + if 'TMPDIR' not in extra_env: + extra_env['TMPDIR'] = os.path.abspath(tmp_dir) + if system_str == 'Darwin': + for flag_key, flag_value in iter(osx_extra_env.items()): + flags = extra_env.get(flag_key, '') + if flag_value not in flags: + #flags += " -Wno-error=unused-command-line-argument-hard-error-in-future" + flags += " "+flag_value + extra_env[flag_key] = flags.strip() + + #isinstance(lst, (list, tuple)) + if key not in ignore_packages: + logger.notify("install %s with method %s" % (key, repr(method))) + if callable(method): + method(option_str, extra_env, res_source_key, home_dir, lib_dir, tmp_dir, src_dir, res_env, logger, call_subprocess, filter_python_develop) + elif method in globals() and callable(globals()[method]) and method not in ['pip', 'easy_install']: + globals()[method](option_str, extra_env, res_source_key, home_dir, lib_dir, tmp_dir, src_dir, res_env, logger, call_subprocess, filter_python_develop) + else: + normal_install(key, res_path, method, option_str, extra_env, res_source_key, home_dir, tmp_dir, res_env, logger, call_subprocess) + + logger.notify("Clear source dir") + shutil.rmtree(src_dir) + + finally: + logger.indent -= 2 + script_dir = join(base_dir, bin_dir) + logger.notify('Run "%s Package" to install new packages that provide builds' + % join(script_dir, 'easy_install')) + + def adjust_options(options, args): + if not options_to_add: + return + for opt,opt_val in options_to_add.items(): + #if not hasattr(options,test_opt) or getattr(options, test_opt) is None: + setattr(options, opt, opt_val) + + return adjust_options, extend_parser, after_install diff -r a2f733f900c0 -r fc0f3e398166 server/virtualenv/res/lib/patch.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/server/virtualenv/res/lib/patch.py Fri May 29 02:22:11 2015 +0200 @@ -0,0 +1,589 @@ +""" Patch utility to apply unified diffs + + Brute-force line-by-line non-recursive parsing + + Copyright (c) 2008-2010 anatoly techtonik + Available under the terms of MIT license + + Project home: http://code.google.com/p/python-patch/ + + + $Id: patch.py 76 2010-04-08 19:10:21Z techtonik $ + $HeadURL: https://python-patch.googlecode.com/svn/trunk/patch.py $ +""" + +__author__ = "techtonik.rainforce.org" +__version__ = "10.04" + +import copy +import logging +import re +# cStringIO doesn't support unicode in 2.5 +from StringIO import StringIO +from logging import debug, info, warning + +from os.path import exists, isfile, abspath +from os import unlink + + +#------------------------------------------------ +# Logging is controlled by "python_patch" logger + +debugmode = False + +logger = logging.getLogger("python_patch") +loghandler = logging.StreamHandler() +logger.addHandler(loghandler) + +debug = logger.debug +info = logger.info +warning = logger.warning + +#: disable library logging by default +logger.setLevel(logging.CRITICAL) + +#------------------------------------------------ + + +def fromfile(filename): + """ Parse patch file and return Patch() object + """ + + info("reading patch from file %s" % filename) + fp = open(filename, "rb") + patch = Patch(fp) + fp.close() + return patch + + +def fromstring(s): + """ Parse text string and return Patch() object + """ + + return Patch( + StringIO.StringIO(s) + ) + + + +class HunkInfo(object): + """ Parsed hunk data container (hunk starts with @@ -R +R @@) """ + + def __init__(self): + self.startsrc=None #: line count starts with 1 + self.linessrc=None + self.starttgt=None + self.linestgt=None + self.invalid=False + self.text=[] + + def copy(self): + return copy.copy(self) + +# def apply(self, estream): +# """ write hunk data into enumerable stream +# return strings one by one until hunk is +# over +# +# enumerable stream are tuples (lineno, line) +# where lineno starts with 0 +# """ +# pass + + + +class Patch(object): + + def __init__(self, stream=None): + + # define Patch data members + # table with a row for every source file + + #: list of source filenames + self.source=None + self.target=None + #: list of lists of hunks + self.hunks=None + #: file endings statistics for every hunk + self.hunkends=None + + if stream: + self.parse(stream) + + def copy(self): + return copy.copy(self) + + def parse(self, stream): + """ parse unified diff """ + self.source = [] + self.target = [] + self.hunks = [] + self.hunkends = [] + + # define possible file regions that will direct the parser flow + header = False # comments before the patch body + filenames = False # lines starting with --- and +++ + + hunkhead = False # @@ -R +R @@ sequence + hunkbody = False # + hunkskip = False # skipping invalid hunk mode + + header = True + lineends = dict(lf=0, crlf=0, cr=0) + nextfileno = 0 + nexthunkno = 0 #: even if index starts with 0 user messages number hunks from 1 + + # hunkinfo holds parsed values, hunkactual - calculated + hunkinfo = HunkInfo() + hunkactual = dict(linessrc=None, linestgt=None) + + fe = enumerate(stream) + for lineno, line in fe: + + # analyze state + if header and line.startswith("--- "): + header = False + # switch to filenames state + filenames = True + #: skip hunkskip and hunkbody code until you read definition of hunkhead + if hunkbody: + # process line first + if re.match(r"^[- \+\\]", line): + # gather stats about line endings + if line.endswith("\r\n"): + self.hunkends[nextfileno-1]["crlf"] += 1 + elif line.endswith("\n"): + self.hunkends[nextfileno-1]["lf"] += 1 + elif line.endswith("\r"): + self.hunkends[nextfileno-1]["cr"] += 1 + + if line.startswith("-"): + hunkactual["linessrc"] += 1 + elif line.startswith("+"): + hunkactual["linestgt"] += 1 + elif not line.startswith("\\"): + hunkactual["linessrc"] += 1 + hunkactual["linestgt"] += 1 + hunkinfo.text.append(line) + # todo: handle \ No newline cases + else: + warning("invalid hunk no.%d at %d for target file %s" % (nexthunkno, lineno+1, self.target[nextfileno-1])) + # add hunk status node + self.hunks[nextfileno-1].append(hunkinfo.copy()) + self.hunks[nextfileno-1][nexthunkno-1]["invalid"] = True + # switch to hunkskip state + hunkbody = False + hunkskip = True + + # check exit conditions + if hunkactual["linessrc"] > hunkinfo.linessrc or hunkactual["linestgt"] > hunkinfo.linestgt: + warning("extra hunk no.%d lines at %d for target %s" % (nexthunkno, lineno+1, self.target[nextfileno-1])) + # add hunk status node + self.hunks[nextfileno-1].append(hunkinfo.copy()) + self.hunks[nextfileno-1][nexthunkno-1]["invalid"] = True + # switch to hunkskip state + hunkbody = False + hunkskip = True + elif hunkinfo.linessrc == hunkactual["linessrc"] and hunkinfo.linestgt == hunkactual["linestgt"]: + self.hunks[nextfileno-1].append(hunkinfo.copy()) + # switch to hunkskip state + hunkbody = False + hunkskip = True + + # detect mixed window/unix line ends + ends = self.hunkends[nextfileno-1] + if ((ends["cr"]!=0) + (ends["crlf"]!=0) + (ends["lf"]!=0)) > 1: + warning("inconsistent line ends in patch hunks for %s" % self.source[nextfileno-1]) + if debugmode: + debuglines = dict(ends) + debuglines.update(file=self.target[nextfileno-1], hunk=nexthunkno) + debug("crlf: %(crlf)d lf: %(lf)d cr: %(cr)d\t - file: %(file)s hunk: %(hunk)d" % debuglines) + + if hunkskip: + match = re.match("^@@ -(\d+)(,(\d+))? \+(\d+)(,(\d+))?", line) + if match: + # switch to hunkhead state + hunkskip = False + hunkhead = True + elif line.startswith("--- "): + # switch to filenames state + hunkskip = False + filenames = True + if debugmode and len(self.source) > 0: + debug("- %2d hunks for %s" % (len(self.hunks[nextfileno-1]), self.source[nextfileno-1])) + + if filenames: + if line.startswith("--- "): + if nextfileno in self.source: + warning("skipping invalid patch for %s" % self.source[nextfileno]) + del self.source[nextfileno] + # double source filename line is encountered + # attempt to restart from this second line + re_filename = "^--- ([^\t]+)" + match = re.match(re_filename, line) + # todo: support spaces in filenames + if match: + self.source.append(match.group(1).strip()) + else: + warning("skipping invalid filename at line %d" % lineno) + # switch back to header state + filenames = False + header = True + elif not line.startswith("+++ "): + if nextfileno in self.source: + warning("skipping invalid patch with no target for %s" % self.source[nextfileno]) + del self.source[nextfileno] + else: + # this should be unreachable + warning("skipping invalid target patch") + filenames = False + header = True + else: + if nextfileno in self.target: + warning("skipping invalid patch - double target at line %d" % lineno) + del self.source[nextfileno] + del self.target[nextfileno] + nextfileno -= 1 + # double target filename line is encountered + # switch back to header state + filenames = False + header = True + else: + re_filename = "^\+\+\+ ([^\t]+)" + match = re.match(re_filename, line) + if not match: + warning("skipping invalid patch - no target filename at line %d" % lineno) + # switch back to header state + filenames = False + header = True + else: + self.target.append(match.group(1).strip()) + nextfileno += 1 + # switch to hunkhead state + filenames = False + hunkhead = True + nexthunkno = 0 + self.hunks.append([]) + self.hunkends.append(lineends.copy()) + continue + + if hunkhead: + match = re.match("^@@ -(\d+)(,(\d+))? \+(\d+)(,(\d+))?", line) + if not match: + if nextfileno-1 not in self.hunks: + warning("skipping invalid patch with no hunks for file %s" % self.target[nextfileno-1]) + # switch to header state + hunkhead = False + header = True + continue + else: + # switch to header state + hunkhead = False + header = True + else: + hunkinfo.startsrc = int(match.group(1)) + hunkinfo.linessrc = 1 + if match.group(3): hunkinfo.linessrc = int(match.group(3)) + hunkinfo.starttgt = int(match.group(4)) + hunkinfo.linestgt = 1 + if match.group(6): hunkinfo.linestgt = int(match.group(6)) + hunkinfo.invalid = False + hunkinfo.text = [] + + hunkactual["linessrc"] = hunkactual["linestgt"] = 0 + + # switch to hunkbody state + hunkhead = False + hunkbody = True + nexthunkno += 1 + continue + else: + if not hunkskip: + warning("patch file incomplete - %s" % filename) + # sys.exit(?) + else: + # duplicated message when an eof is reached + if debugmode and len(self.source) > 0: + debug("- %2d hunks for %s" % (len(self.hunks[nextfileno-1]), self.source[nextfileno-1])) + + info("total files: %d total hunks: %d" % (len(self.source), sum(len(hset) for hset in self.hunks))) + + + def apply(self): + """ apply parsed patch """ + + total = len(self.source) + for fileno, filename in enumerate(self.source): + + f2patch = filename + if not exists(f2patch): + f2patch = self.target[fileno] + if not exists(f2patch): + warning("source/target file does not exist\n--- %s\n+++ %s" % (filename, f2patch)) + continue + if not isfile(f2patch): + warning("not a file - %s" % f2patch) + continue + filename = f2patch + + info("processing %d/%d:\t %s" % (fileno+1, total, filename)) + + # validate before patching + f2fp = open(filename) + hunkno = 0 + hunk = self.hunks[fileno][hunkno] + hunkfind = [] + hunkreplace = [] + validhunks = 0 + canpatch = False + for lineno, line in enumerate(f2fp): + if lineno+1 < hunk.startsrc: + continue + elif lineno+1 == hunk.startsrc: + hunkfind = [x[1:].rstrip("\r\n") for x in hunk.text if x[0] in " -"] + hunkreplace = [x[1:].rstrip("\r\n") for x in hunk.text if x[0] in " +"] + #pprint(hunkreplace) + hunklineno = 0 + + # todo \ No newline at end of file + + # check hunks in source file + if lineno+1 < hunk.startsrc+len(hunkfind)-1: + if line.rstrip("\r\n") == hunkfind[hunklineno]: + hunklineno+=1 + else: + debug("hunk no.%d doesn't match source file %s" % (hunkno+1, filename)) + # file may be already patched, but we will check other hunks anyway + hunkno += 1 + if hunkno < len(self.hunks[fileno]): + hunk = self.hunks[fileno][hunkno] + continue + else: + break + + # check if processed line is the last line + if lineno+1 == hunk.startsrc+len(hunkfind)-1: + debug("file %s hunk no.%d -- is ready to be patched" % (filename, hunkno+1)) + hunkno+=1 + validhunks+=1 + if hunkno < len(self.hunks[fileno]): + hunk = self.hunks[fileno][hunkno] + else: + if validhunks == len(self.hunks[fileno]): + # patch file + canpatch = True + break + else: + if hunkno < len(self.hunks[fileno]): + warning("premature end of source file %s at hunk %d" % (filename, hunkno+1)) + + f2fp.close() + + if validhunks < len(self.hunks[fileno]): + if self._match_file_hunks(filename, self.hunks[fileno]): + warning("already patched %s" % filename) + else: + warning("source file is different - %s" % filename) + if canpatch: + backupname = filename+".orig" + if exists(backupname): + warning("can't backup original file to %s - aborting" % backupname) + else: + import shutil + shutil.move(filename, backupname) + if self.write_hunks(backupname, filename, self.hunks[fileno]): + warning("successfully patched %s" % filename) + unlink(backupname) + else: + warning("error patching file %s" % filename) + shutil.copy(filename, filename+".invalid") + warning("invalid version is saved to %s" % filename+".invalid") + # todo: proper rejects + shutil.move(backupname, filename) + + # todo: check for premature eof + + + def can_patch(self, filename): + """ Check if specified filename can be patched. Returns None if file can + not be found among source filenames. False if patch can not be applied + clearly. True otherwise. + + :returns: True, False or None + """ + idx = self._get_file_idx(filename, source=True) + if idx == None: + return None + return self._match_file_hunks(filename, self.hunks[idx]) + + + def _match_file_hunks(self, filepath, hunks): + matched = True + fp = open(abspath(filepath)) + + class NoMatch(Exception): + pass + + lineno = 1 + line = fp.readline() + hno = None + try: + for hno, h in enumerate(hunks): + # skip to first line of the hunk + while lineno < h.starttgt: + if not len(line): # eof + debug("check failed - premature eof before hunk: %d" % (hno+1)) + raise NoMatch + line = fp.readline() + lineno += 1 + for hline in h.text: + if hline.startswith("-"): + continue + if not len(line): + debug("check failed - premature eof on hunk: %d" % (hno+1)) + # todo: \ No newline at the end of file + raise NoMatch + if line.rstrip("\r\n") != hline[1:].rstrip("\r\n"): + debug("file is not patched - failed hunk: %d" % (hno+1)) + raise NoMatch + line = fp.readline() + lineno += 1 + + except NoMatch: + matched = False + # todo: display failed hunk, i.e. expected/found + + fp.close() + return matched + + + def patch_stream(self, instream, hunks): + """ Generator that yields stream patched with hunks iterable + + Converts lineends in hunk lines to the best suitable format + autodetected from input + """ + + # todo: At the moment substituted lineends may not be the same + # at the start and at the end of patching. Also issue a + # warning/throw about mixed lineends (is it really needed?) + + hunks = iter(hunks) + + srclineno = 1 + + lineends = {'\n':0, '\r\n':0, '\r':0} + def get_line(): + """ + local utility function - return line from source stream + collecting line end statistics on the way + """ + line = instream.readline() + # 'U' mode works only with text files + if line.endswith("\r\n"): + lineends["\r\n"] += 1 + elif line.endswith("\n"): + lineends["\n"] += 1 + elif line.endswith("\r"): + lineends["\r"] += 1 + return line + + for hno, h in enumerate(hunks): + debug("hunk %d" % (hno+1)) + # skip to line just before hunk starts + while srclineno < h.startsrc: + yield get_line() + srclineno += 1 + + for hline in h.text: + # todo: check \ No newline at the end of file + if hline.startswith("-") or hline.startswith("\\"): + get_line() + srclineno += 1 + continue + else: + if not hline.startswith("+"): + get_line() + srclineno += 1 + line2write = hline[1:] + # detect if line ends are consistent in source file + if sum([bool(lineends[x]) for x in lineends]) == 1: + newline = [x for x in lineends if lineends[x] != 0][0] + yield line2write.rstrip("\r\n")+newline + else: # newlines are mixed + yield line2write + + for line in instream: + yield line + + + def write_hunks(self, srcname, tgtname, hunks): + src = open(srcname, "rb") + tgt = open(tgtname, "wb") + + debug("processing target file %s" % tgtname) + + tgt.writelines(self.patch_stream(src, hunks)) + + tgt.close() + src.close() + return True + + + def _get_file_idx(self, filename, source=None): + """ Detect index of given filename within patch. + + :param filename: + :param source: search filename among sources (True), + targets (False), or both (None) + :returns: int or None + """ + filename = abspath(filename) + if source == True or source == None: + for i,fnm in enumerate(self.source): + if filename == abspath(fnm): + return i + if source == False or source == None: + for i,fnm in enumerate(self.target): + if filename == abspath(fnm): + return i + + + + +from optparse import OptionParser +from os.path import exists +import sys + +if __name__ == "__main__": + opt = OptionParser(usage="%prog [options] unipatch-file", version="python-patch %s" % __version__) + opt.add_option("--debug", action="store_true", dest="debugmode", help="debug mode") + (options, args) = opt.parse_args() + + if not args: + opt.print_version() + opt.print_help() + sys.exit() + debugmode = options.debugmode + patchfile = args[0] + if not exists(patchfile) or not isfile(patchfile): + sys.exit("patch file does not exist - %s" % patchfile) + + + if debugmode: + loglevel = logging.DEBUG + logformat = "%(levelname)8s %(message)s" + else: + loglevel = logging.INFO + logformat = "%(message)s" + logger.setLevel(loglevel) + loghandler.setFormatter(logging.Formatter(logformat)) + + + + patch = fromfile(patchfile) + #pprint(patch) + patch.apply() + + # todo: document and test line ends handling logic - patch.py detects proper line-endings + # for inserted hunks and issues a warning if patched file has incosistent line ends diff -r a2f733f900c0 -r fc0f3e398166 server/virtualenv/res/src/Django-1.8.2.dev.tar.gz Binary file server/virtualenv/res/src/Django-1.8.2.dev.tar.gz has changed diff -r a2f733f900c0 -r fc0f3e398166 server/virtualenv/res/src/MySQL-python-1.2.3.win-amd64-py2.7.exe Binary file server/virtualenv/res/src/MySQL-python-1.2.3.win-amd64-py2.7.exe has changed diff -r a2f733f900c0 -r fc0f3e398166 server/virtualenv/res/src/MySQL-python-1.2.3.win32-py2.7.exe Binary file server/virtualenv/res/src/MySQL-python-1.2.3.win32-py2.7.exe has changed diff -r a2f733f900c0 -r fc0f3e398166 server/virtualenv/res/src/MySQL-python-1.2.4b4.tar.gz Binary file server/virtualenv/res/src/MySQL-python-1.2.4b4.tar.gz has changed diff -r a2f733f900c0 -r fc0f3e398166 server/virtualenv/res/src/PIL-1.1.7.win32-py2.7.exe Binary file server/virtualenv/res/src/PIL-1.1.7.win32-py2.7.exe has changed diff -r a2f733f900c0 -r fc0f3e398166 server/virtualenv/res/src/Pillow-2.8.1.tar.gz Binary file server/virtualenv/res/src/Pillow-2.8.1.tar.gz has changed diff -r a2f733f900c0 -r fc0f3e398166 server/virtualenv/res/src/PyYAML-3.11.tar.gz Binary file server/virtualenv/res/src/PyYAML-3.11.tar.gz has changed diff -r a2f733f900c0 -r fc0f3e398166 server/virtualenv/res/src/South-1.0.2.tar.gz Binary file server/virtualenv/res/src/South-1.0.2.tar.gz has changed diff -r a2f733f900c0 -r fc0f3e398166 server/virtualenv/res/src/defusedxml-0.4.1.tar.gz Binary file server/virtualenv/res/src/defusedxml-0.4.1.tar.gz has changed diff -r a2f733f900c0 -r fc0f3e398166 server/virtualenv/res/src/distribute-0.6.34.tar.gz Binary file server/virtualenv/res/src/distribute-0.6.34.tar.gz has changed diff -r a2f733f900c0 -r fc0f3e398166 server/virtualenv/res/src/django-chunked-uploads-0.6.tar.gz Binary file server/virtualenv/res/src/django-chunked-uploads-0.6.tar.gz has changed diff -r a2f733f900c0 -r fc0f3e398166 server/virtualenv/res/src/django-cors-headers-1.0.0.tar.gz Binary file server/virtualenv/res/src/django-cors-headers-1.0.0.tar.gz has changed diff -r a2f733f900c0 -r fc0f3e398166 server/virtualenv/res/src/django-extensions-1.5.3.tar.gz Binary file server/virtualenv/res/src/django-extensions-1.5.3.tar.gz has changed diff -r a2f733f900c0 -r fc0f3e398166 server/virtualenv/res/src/django-guardian-1.2.6.dev.tar.gz Binary file server/virtualenv/res/src/django-guardian-1.2.6.dev.tar.gz has changed diff -r a2f733f900c0 -r fc0f3e398166 server/virtualenv/res/src/django-haystack-2.0.0.tar.gz Binary file server/virtualenv/res/src/django-haystack-2.0.0.tar.gz has changed diff -r a2f733f900c0 -r fc0f3e398166 server/virtualenv/res/src/django-haystack-2.3.1.tar.gz Binary file server/virtualenv/res/src/django-haystack-2.3.1.tar.gz has changed diff -r a2f733f900c0 -r fc0f3e398166 server/virtualenv/res/src/django-oauth-plus-2.2.6.tar.gz Binary file server/virtualenv/res/src/django-oauth-plus-2.2.6.tar.gz has changed diff -r a2f733f900c0 -r fc0f3e398166 server/virtualenv/res/src/django-openid-consumer-0.1.1.tar.gz Binary file server/virtualenv/res/src/django-openid-consumer-0.1.1.tar.gz has changed diff -r a2f733f900c0 -r fc0f3e398166 server/virtualenv/res/src/django-registration-redux-1.2.tar.gz Binary file server/virtualenv/res/src/django-registration-redux-1.2.tar.gz has changed diff -r a2f733f900c0 -r fc0f3e398166 server/virtualenv/res/src/django-social-auth-0.7.23.tar.gz Binary file server/virtualenv/res/src/django-social-auth-0.7.23.tar.gz has changed diff -r a2f733f900c0 -r fc0f3e398166 server/virtualenv/res/src/django-taggit-0.14.0.tar.gz Binary file server/virtualenv/res/src/django-taggit-0.14.0.tar.gz has changed diff -r a2f733f900c0 -r fc0f3e398166 server/virtualenv/res/src/django-taggit-templatetags-0.4.5dev-r0.zip Binary file server/virtualenv/res/src/django-taggit-templatetags-0.4.5dev-r0.zip has changed diff -r a2f733f900c0 -r fc0f3e398166 server/virtualenv/res/src/django-tastypie-0.12.2.dev0.tar.gz Binary file server/virtualenv/res/src/django-tastypie-0.12.2.dev0.tar.gz has changed diff -r a2f733f900c0 -r fc0f3e398166 server/virtualenv/res/src/django-templatetag-sugar-1.0.tar.gz Binary file server/virtualenv/res/src/django-templatetag-sugar-1.0.tar.gz has changed diff -r a2f733f900c0 -r fc0f3e398166 server/virtualenv/res/src/elasticsearch-1.4.0.tar.gz Binary file server/virtualenv/res/src/elasticsearch-1.4.0.tar.gz has changed diff -r a2f733f900c0 -r fc0f3e398166 server/virtualenv/res/src/httplib2-0.9.1.tar.gz Binary file server/virtualenv/res/src/httplib2-0.9.1.tar.gz has changed diff -r a2f733f900c0 -r fc0f3e398166 server/virtualenv/res/src/jezdez-setuptools_hg-b025f18e170b.tar.gz Binary file server/virtualenv/res/src/jezdez-setuptools_hg-b025f18e170b.tar.gz has changed diff -r a2f733f900c0 -r fc0f3e398166 server/virtualenv/res/src/jpegsrc.v8d.tar.gz Binary file server/virtualenv/res/src/jpegsrc.v8d.tar.gz has changed diff -r a2f733f900c0 -r fc0f3e398166 server/virtualenv/res/src/libxml2-2.9.2.tar.gz Binary file server/virtualenv/res/src/libxml2-2.9.2.tar.gz has changed diff -r a2f733f900c0 -r fc0f3e398166 server/virtualenv/res/src/lxml-2.3-py2.7-win32.egg Binary file server/virtualenv/res/src/lxml-2.3-py2.7-win32.egg has changed diff -r a2f733f900c0 -r fc0f3e398166 server/virtualenv/res/src/lxml-3.2.1.tar.bz2 Binary file server/virtualenv/res/src/lxml-3.2.1.tar.bz2 has changed diff -r a2f733f900c0 -r fc0f3e398166 server/virtualenv/res/src/mimeparse-0.1.3.tar.gz Binary file server/virtualenv/res/src/mimeparse-0.1.3.tar.gz has changed diff -r a2f733f900c0 -r fc0f3e398166 server/virtualenv/res/src/oauth2-1.5.211.tar.gz Binary file server/virtualenv/res/src/oauth2-1.5.211.tar.gz has changed diff -r a2f733f900c0 -r fc0f3e398166 server/virtualenv/res/src/oauthlib-0.7.2.tar.gz Binary file server/virtualenv/res/src/oauthlib-0.7.2.tar.gz has changed diff -r a2f733f900c0 -r fc0f3e398166 server/virtualenv/res/src/psycopg2-2.4.6.win32-py2.7-pg9.2.2-release.exe Binary file server/virtualenv/res/src/psycopg2-2.4.6.win32-py2.7-pg9.2.2-release.exe has changed diff -r a2f733f900c0 -r fc0f3e398166 server/virtualenv/res/src/psycopg2-2.6.tar.gz Binary file server/virtualenv/res/src/psycopg2-2.6.tar.gz has changed diff -r a2f733f900c0 -r fc0f3e398166 server/virtualenv/res/src/pyelasticsearch-1.2.3.tar.gz Binary file server/virtualenv/res/src/pyelasticsearch-1.2.3.tar.gz has changed diff -r a2f733f900c0 -r fc0f3e398166 server/virtualenv/res/src/pyjwt-1.1.0.tar.gz Binary file server/virtualenv/res/src/pyjwt-1.1.0.tar.gz has changed diff -r a2f733f900c0 -r fc0f3e398166 server/virtualenv/res/src/python-dateutil-2.1.tar.gz Binary file server/virtualenv/res/src/python-dateutil-2.1.tar.gz has changed diff -r a2f733f900c0 -r fc0f3e398166 server/virtualenv/res/src/python-digest-1.7.tar.gz Binary file server/virtualenv/res/src/python-digest-1.7.tar.gz has changed diff -r a2f733f900c0 -r fc0f3e398166 server/virtualenv/res/src/python-mimeparse-0.1.4.tar.gz Binary file server/virtualenv/res/src/python-mimeparse-0.1.4.tar.gz has changed diff -r a2f733f900c0 -r fc0f3e398166 server/virtualenv/res/src/python-openid-2.2.5.tar.gz Binary file server/virtualenv/res/src/python-openid-2.2.5.tar.gz has changed diff -r a2f733f900c0 -r fc0f3e398166 server/virtualenv/res/src/python-social-auth-0.2.7.tar.gz Binary file server/virtualenv/res/src/python-social-auth-0.2.7.tar.gz has changed diff -r a2f733f900c0 -r fc0f3e398166 server/virtualenv/res/src/requests-2.7.0.tar.gz Binary file server/virtualenv/res/src/requests-2.7.0.tar.gz has changed diff -r a2f733f900c0 -r fc0f3e398166 server/virtualenv/res/src/requests-oauthlib-0.5.0.tar.gz Binary file server/virtualenv/res/src/requests-oauthlib-0.5.0.tar.gz has changed diff -r a2f733f900c0 -r fc0f3e398166 server/virtualenv/res/src/setuptools_hg-0.4.tar.gz Binary file server/virtualenv/res/src/setuptools_hg-0.4.tar.gz has changed diff -r a2f733f900c0 -r fc0f3e398166 server/virtualenv/res/src/simplejson-3.3.0.tar.gz Binary file server/virtualenv/res/src/simplejson-3.3.0.tar.gz has changed diff -r a2f733f900c0 -r fc0f3e398166 server/virtualenv/res/src/simplejson-3.6.5.tar.gz Binary file server/virtualenv/res/src/simplejson-3.6.5.tar.gz has changed diff -r a2f733f900c0 -r fc0f3e398166 server/virtualenv/res/src/six-1.9.0.tar.gz Binary file server/virtualenv/res/src/six-1.9.0.tar.gz has changed diff -r a2f733f900c0 -r fc0f3e398166 server/virtualenv/res/src/sorl-thumbnail-12.2.tar.gz Binary file server/virtualenv/res/src/sorl-thumbnail-12.2.tar.gz has changed diff -r a2f733f900c0 -r fc0f3e398166 server/virtualenv/res/src/urllib3-1.10.4.tar.gz Binary file server/virtualenv/res/src/urllib3-1.10.4.tar.gz has changed diff -r a2f733f900c0 -r fc0f3e398166 server/virtualenv/res/src/whoosh-2.7.0.tar.gz Binary file server/virtualenv/res/src/whoosh-2.7.0.tar.gz has changed diff -r a2f733f900c0 -r fc0f3e398166 server/virtualenv/res/src/zlib-1.2.8.tar.gz Binary file server/virtualenv/res/src/zlib-1.2.8.tar.gz has changed diff -r a2f733f900c0 -r fc0f3e398166 server/virtualenv/web/create_python_env.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/server/virtualenv/web/create_python_env.py Fri May 29 02:22:11 2015 +0200 @@ -0,0 +1,65 @@ +""" +Call this like ``python create_python_env.py``; it will +refresh the project-boot.py script + +-prerequisite: + +- virtualenv +- distribute +- psycopg2 requires the PostgreSQL libpq libraries and the pg_config utility + +- python project-boot.py --distribute --no-site-packages --index-url=http://pypi.websushi.org/ --clear --type-install=local --ignore-packages=MYSQL +- python project-boot.py --no-site-packages --clear --ignore-packages=MYSQL --type-install=local +- For Linux : +python project-boot.py --unzip-setuptools --no-site-packages --index-url=http://pypi.websushi.org/ --clear --type-install=local + +Probleme avec mysql : + +sudo install_name_tool -change libmysqlclient.18.dylib /usr/local/mysql/lib/libmysqlclient.18.dylib ~/dev/workspace/platform/virtualenv/web/env/venv_platform/lib/python2.7/site-packages/_mysql.so + +""" + +import os +import subprocess +import re +import sys + + +here = os.path.dirname(os.path.abspath(__file__)) +base_dir = here +script_name = os.path.join(base_dir, 'project-boot.py') + +import virtualenv + +src_base = os.path.abspath(os.path.join(here,"..","res","src")).replace("\\","/") +lib_path = os.path.abspath(os.path.join(here,"..","res","lib")).replace("\\","/") +patch_path = os.path.abspath(os.path.join(here,"res","patch")).replace("\\","/") + + +EXTRA_TEXT = "import sys\n" +EXTRA_TEXT += "sys.path.append('%s')\n" % (lib_path) +EXTRA_TEXT += "sys.path.append('%s')\n" % (os.path.abspath(os.path.join(here,"res")).replace("\\","/")) +EXTRA_TEXT += "from res_create_env import generate_install_methods\n" +EXTRA_TEXT += "adjust_options, extend_parser, after_install = generate_install_methods(path_locations, '%s', '%s', Logger, call_subprocess)\n" % (src_base, here) + +def main(): + python_version = ".".join(map(str,sys.version_info[0:2])) + text = virtualenv.create_bootstrap_script(EXTRA_TEXT, python_version=python_version) + if os.path.exists(script_name): + f = open(script_name) + cur_text = f.read() + f.close() + else: + cur_text = '' + print 'Updating %s' % script_name + if cur_text == 'text': + print 'No update' + else: + print 'Script changed; updating...' + f = open(script_name, 'w') + f.write(text) + f.close() + +if __name__ == '__main__': + main() + diff -r a2f733f900c0 -r fc0f3e398166 server/virtualenv/web/env/.hgkeep diff -r a2f733f900c0 -r fc0f3e398166 server/virtualenv/web/res/README --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/server/virtualenv/web/res/README Fri May 29 02:22:11 2015 +0200 @@ -0,0 +1,22 @@ +README - Platform virtualenv lib modifications +------------------------------------------------- + +1. DJANGO-PISTON +https://bitbucket.org/jespern/django-piston/overview +------------------------------------------------------ +Model name collision with python-oauth. +Described here: https://bitbucket.org/david/django-oauth/issue/3/collision-with-django-piston-on-syncdb + +Piston and Django-oauth use the same model for Tokens, and same related name to their ForeignKey User. +One of the related_name has to be modified. +See platform/virtualenv/web/res/patch/piston.diff + + +2. PYTHON-OAUTH2 +https://github.com/simplegeo/python-oauth2 +--------------------------------------------- +Request paramters are not handled correctly, and sometimes appear twice in the request query_string. +Described here: https://github.com/simplegeo/python-oauth2/issues#issue/21 + +Modification made in get_normalized_parameters in order to avoid doubling the parameters, and making the request non-valid. +See platform/virtualenv/web/res/patch/oauth2.diff \ No newline at end of file diff -r a2f733f900c0 -r fc0f3e398166 server/virtualenv/web/res/patch/.keepme diff -r a2f733f900c0 -r fc0f3e398166 server/virtualenv/web/res/patch/django_contrib_auth_views.diff --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/server/virtualenv/web/res/patch/django_contrib_auth_views.diff Fri May 29 02:22:11 2015 +0200 @@ -0,0 +1,20 @@ +--- Django-1.3/django/contrib/auth/views.py.OLD jeu. avr. 14 15:48:14 2011 ++++ Django-1.3/django/contrib/auth/views.py jeu. avr. 14 15:48:32 2011 +@@ -18,6 +18,9 @@ + from django.contrib.auth.tokens import default_token_generator + from django.contrib.sites.models import get_current_site + ++#CHANGE BY TC FOR IRI'S PLATFORM ++from social_auth.views import list as social_list ++#END TC + + @csrf_protect + @never_cache +@@ -63,6 +66,7 @@ + redirect_field_name: redirect_to, + 'site': current_site, + 'site_name': current_site.name, ++ 'social_list': social_list + } + context.update(extra_context or {}) + return render_to_response(template_name, context, diff -r a2f733f900c0 -r fc0f3e398166 server/virtualenv/web/res/patch/oauth2.diff --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/server/virtualenv/web/res/patch/oauth2.diff Fri May 29 02:22:11 2015 +0200 @@ -0,0 +1,11 @@ +diff -r 7ea87e3229fd5c4eebd0 oauth2/__init__.py +@@ -385,386 +385,391 @@ + url_items = self._split_url_string(query).items() + non_oauth_url_items = list([(k, v) for k, v in url_items if not k.startswith('oauth_')]) + +- items.extend(non_oauth_url_items) ++ for (key,value) in non_oauth_url_items: ++ if (key,value) not in items: ++ items.append((key,value)) + + encoded_str = urllib.urlencode(sorted(items)) \ No newline at end of file diff -r a2f733f900c0 -r fc0f3e398166 server/virtualenv/web/res/patch/social_auth_views_diff.diff --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/server/virtualenv/web/res/patch/social_auth_views_diff.diff Fri May 29 02:22:11 2015 +0200 @@ -0,0 +1,31 @@ +--- D:/CavalieT/My Documents/Flex Builder 3/platform_diane/platform/virtualenv/web/res/src/omab-django-social-auth-v0.3.8-9-g5d610a5/omab-django-social-auth-5d610a5/social_auth/views.py lun. mars 28 12:03:45 2011 ++++ D:/CavalieT/My Documents/Flex Builder 3/platform_diane/platform/virtualenv/web/env/myplatformenv/Lib/site-packages/django_social_auth-0.3.8-py2.6.egg/social_auth/views.py ven. avr. 8 12:06:02 2011 +@@ -7,13 +7,27 @@ + from django.contrib.auth import login, REDIRECT_FIELD_NAME + from django.contrib.auth.decorators import login_required + +-from social_auth.backends import get_backend ++from social_auth.backends import get_backend, get_backends + from social_auth.utils import sanitize_redirect + + + DEFAULT_REDIRECT = getattr(settings, 'LOGIN_REDIRECT_URL', '') + ++#TC ++def list(): ++ """Start list process""" ++ log_url = getattr(settings, 'LOGIN_URL', '') ++ response = "
    " ++ # We list all wanted backends among all availables ++ for backend in get_backends(): ++ for backend_str in settings.AUTHENTICATION_BACKENDS: ++ if backend in backend_str: ++ response += "
  • " + backend + "
  • " ++ response += "
" ++ return response ++#END change by TC + ++ + def auth(request, backend): + """Start authentication process""" + complete_url = getattr(settings, 'SOCIAL_AUTH_COMPLETE_URL_NAME', diff -r a2f733f900c0 -r fc0f3e398166 server/virtualenv/web/res/requirements.txt --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/server/virtualenv/web/res/requirements.txt Fri May 29 02:22:11 2015 +0200 @@ -0,0 +1,39 @@ +-f ../../res/src +defusedxml==0.4.1 +Django==1.8.2.dev +django-chunked-uploads==0.6 +django-cors-headers==1.0.0 +django-extensions==1.5.3 +django-guardian==1.2.6.dev +django-haystack==2.3.1 +django-oauth-plus==2.2.6 +django-registration-redux==1.2 +django-taggit==0.14.0 +django-taggit-templatetags===0.4.5dev-r0 +django-tastypie==0.12.2.dev0 +django-templatetag-sugar==1.0 +elasticsearch==1.4.0 +httplib2==0.9.1 +lxml==3.2.1 +mimeparse==0.1.3 +oauth2==1.5.211 +oauthlib==0.7.2 +Pillow==2.8.1 +psycopg2==2.6 +pyelasticsearch==1.2.3 +PyJWT==1.1.0 +python-dateutil==2.1 +python-digest==1.7 +python-mimeparse==0.1.4 +python-openid==2.2.5 +python-social-auth==0.2.7 +PyYAML==3.11 +requests==2.7.0 +requests-oauthlib==0.5.0 +setuptools-hg==0.4 +simplejson==3.6.5 +six==1.9.0 +sorl-thumbnail==12.2 +South==1.0.2 +urllib3==1.10.4 +Whoosh==2.7.0 diff -r a2f733f900c0 -r fc0f3e398166 server/virtualenv/web/res/res_create_env.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/server/virtualenv/web/res/res_create_env.py Fri May 29 02:22:11 2015 +0200 @@ -0,0 +1,71 @@ +import platform +import os +import sys + +from lib_create_env import lib_generate_install_methods + +system_str = platform.system() + +extra_env = None +if system_str == 'Darwin': + extra_env = {'STATIC_DEPS': 'true', 'LIBXML2_VERSION': '2.9.2', 'LIBXSLT_VERSION': '1.1.28', 'LIBICONV_VERSION': '1.14'} + if os.path.exists('/usr/local/opt/xz'): + if not os.path.exists('/usr/local/opt/libxml2'): + sys.exit("You have installed xz with Homebrew but do not have libxml2 installed with Homebrew. Install libxml2 with Homebrew and try again.") + extra_env = {'LDFLAGS': '-L/usr/local/opt/libxml2/lib', 'CPPFLAGS': '-I/usr/local/opt/libxml2/include'} + + + +INSTALLS = [ # (key,method, option_str, dict_extra_env) + { + 'requirement':'requirements.txt', + 'install': { + 'option_str': None, + 'dict_extra_env': extra_env + } + }, +# 'LXML', +# 'SIMPLEJSON', +# 'PSYCOPG2', + #'MYSQL', +# 'PIL', +# 'DJANGO', +# 'DJANGO-EXTENSIONS', +# 'DJANGO-REGISTRATION', +# 'DJANGO-TAGGIT', +# 'DJANGO-TAGGIT-TEMPLATETAGS', +# 'HTTPLIB2', +# 'OAUTH2', +# 'OAUTHLIB', +# 'SETUPTOOLS_HG', +# 'DJANGO-OAUTH-PLUS', +# 'OPENID', +# 'SOCIAL_AUTH', +# 'DJANGO_GUARDIAN', +# 'SORL_THUMBNAIL', +# 'HAYSTACK', +# 'URLLIB3', +# 'REQUESTS', +# 'ELASTICSEARCH', +# 'PYELASTICSEARCH', +# 'WHOOSH', +# 'MIMEPARSE', +# 'SIX', +# 'PYTHON-DATEUTIL', +# 'PYYAML', +# 'PYTHON-DIGEST', +# 'DEFUSEDXML', +# 'DJANGO-TASTYPIE', +# 'DJANGO-CORS-HEADERS', +# 'DJANGO-CHUNCKED-UPLOADS', +# 'PYJWT', +# 'DJANGO-TEMPLATETAG-SUGAR', +# 'PYTHON-MIMEPARSE', +# 'REQUESTS-OAUTHLIB', +# 'SOUTH, +] + +OPTIONS_TO_ADD = {'type_install': 'local', 'unzip_setuptools': True} + +def generate_install_methods(path_locations, src_base, run_base, Logger, call_subprocess): + return lib_generate_install_methods(path_locations, src_base, run_base, Logger, call_subprocess, INSTALLS, OPTIONS_TO_ADD) diff -r a2f733f900c0 -r fc0f3e398166 server/virtualenv/web/res/srvr_requirements.txt --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/server/virtualenv/web/res/srvr_requirements.txt Fri May 29 02:22:11 2015 +0200 @@ -0,0 +1,3 @@ +python-memcached +uWSGI +pytz \ No newline at end of file diff -r a2f733f900c0 -r fc0f3e398166 server/virtualenv/web/virtualenv.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/server/virtualenv/web/virtualenv.py Fri May 29 02:22:11 2015 +0200 @@ -0,0 +1,2367 @@ +#!/usr/bin/env python +"""Create a "virtual" Python installation +""" + +__version__ = "13.0.1" +virtualenv_version = __version__ # legacy + +import base64 +import sys +import os +import codecs +import optparse +import re +import shutil +import logging +import tempfile +import zlib +import errno +import glob +import distutils.sysconfig +from distutils.util import strtobool +import struct +import subprocess +import tarfile + +if sys.version_info < (2, 6): + print('ERROR: %s' % sys.exc_info()[1]) + print('ERROR: this script requires Python 2.6 or greater.') + sys.exit(101) + +try: + basestring +except NameError: + basestring = str + +try: + import ConfigParser +except ImportError: + import configparser as ConfigParser + +join = os.path.join +py_version = 'python%s.%s' % (sys.version_info[0], sys.version_info[1]) + +is_jython = sys.platform.startswith('java') +is_pypy = hasattr(sys, 'pypy_version_info') +is_win = (sys.platform == 'win32') +is_cygwin = (sys.platform == 'cygwin') +is_darwin = (sys.platform == 'darwin') +abiflags = getattr(sys, 'abiflags', '') + +user_dir = os.path.expanduser('~') +if is_win: + default_storage_dir = os.path.join(user_dir, 'virtualenv') +else: + default_storage_dir = os.path.join(user_dir, '.virtualenv') +default_config_file = os.path.join(default_storage_dir, 'virtualenv.ini') + +if is_pypy: + expected_exe = 'pypy' +elif is_jython: + expected_exe = 'jython' +else: + expected_exe = 'python' + +# Return a mapping of version -> Python executable +# Only provided for Windows, where the information in the registry is used +if not is_win: + def get_installed_pythons(): + return {} +else: + try: + import winreg + except ImportError: + import _winreg as winreg + + def get_installed_pythons(): + try: + python_core = winreg.CreateKey(winreg.HKEY_LOCAL_MACHINE, + "Software\\Python\\PythonCore") + except WindowsError: + # No registered Python installations + return {} + i = 0 + versions = [] + while True: + try: + versions.append(winreg.EnumKey(python_core, i)) + i = i + 1 + except WindowsError: + break + exes = dict() + for ver in versions: + try: + path = winreg.QueryValue(python_core, "%s\\InstallPath" % ver) + except WindowsError: + continue + exes[ver] = join(path, "python.exe") + + winreg.CloseKey(python_core) + + # Add the major versions + # Sort the keys, then repeatedly update the major version entry + # Last executable (i.e., highest version) wins with this approach + for ver in sorted(exes): + exes[ver[0]] = exes[ver] + + return exes + +REQUIRED_MODULES = ['os', 'posix', 'posixpath', 'nt', 'ntpath', 'genericpath', + 'fnmatch', 'locale', 'encodings', 'codecs', + 'stat', 'UserDict', 'readline', 'copy_reg', 'types', + 're', 'sre', 'sre_parse', 'sre_constants', 'sre_compile', + 'zlib'] + +REQUIRED_FILES = ['lib-dynload', 'config'] + +majver, minver = sys.version_info[:2] +if majver == 2: + if minver >= 6: + REQUIRED_MODULES.extend(['warnings', 'linecache', '_abcoll', 'abc']) + if minver >= 7: + REQUIRED_MODULES.extend(['_weakrefset']) +elif majver == 3: + # Some extra modules are needed for Python 3, but different ones + # for different versions. + REQUIRED_MODULES.extend(['_abcoll', 'warnings', 'linecache', 'abc', 'io', + '_weakrefset', 'copyreg', 'tempfile', 'random', + '__future__', 'collections', 'keyword', 'tarfile', + 'shutil', 'struct', 'copy', 'tokenize', 'token', + 'functools', 'heapq', 'bisect', 'weakref', + 'reprlib']) + if minver >= 2: + REQUIRED_FILES[-1] = 'config-%s' % majver + if minver >= 3: + import sysconfig + platdir = sysconfig.get_config_var('PLATDIR') + REQUIRED_FILES.append(platdir) + # The whole list of 3.3 modules is reproduced below - the current + # uncommented ones are required for 3.3 as of now, but more may be + # added as 3.3 development continues. + REQUIRED_MODULES.extend([ + #"aifc", + #"antigravity", + #"argparse", + #"ast", + #"asynchat", + #"asyncore", + "base64", + #"bdb", + #"binhex", + #"bisect", + #"calendar", + #"cgi", + #"cgitb", + #"chunk", + #"cmd", + #"codeop", + #"code", + #"colorsys", + #"_compat_pickle", + #"compileall", + #"concurrent", + #"configparser", + #"contextlib", + #"cProfile", + #"crypt", + #"csv", + #"ctypes", + #"curses", + #"datetime", + #"dbm", + #"decimal", + #"difflib", + #"dis", + #"doctest", + #"dummy_threading", + "_dummy_thread", + #"email", + #"filecmp", + #"fileinput", + #"formatter", + #"fractions", + #"ftplib", + #"functools", + #"getopt", + #"getpass", + #"gettext", + #"glob", + #"gzip", + "hashlib", + #"heapq", + "hmac", + #"html", + #"http", + #"idlelib", + #"imaplib", + #"imghdr", + "imp", + "importlib", + #"inspect", + #"json", + #"lib2to3", + #"logging", + #"macpath", + #"macurl2path", + #"mailbox", + #"mailcap", + #"_markupbase", + #"mimetypes", + #"modulefinder", + #"multiprocessing", + #"netrc", + #"nntplib", + #"nturl2path", + #"numbers", + #"opcode", + #"optparse", + #"os2emxpath", + #"pdb", + #"pickle", + #"pickletools", + #"pipes", + #"pkgutil", + #"platform", + #"plat-linux2", + #"plistlib", + #"poplib", + #"pprint", + #"profile", + #"pstats", + #"pty", + #"pyclbr", + #"py_compile", + #"pydoc_data", + #"pydoc", + #"_pyio", + #"queue", + #"quopri", + #"reprlib", + "rlcompleter", + #"runpy", + #"sched", + #"shelve", + #"shlex", + #"smtpd", + #"smtplib", + #"sndhdr", + #"socket", + #"socketserver", + #"sqlite3", + #"ssl", + #"stringprep", + #"string", + #"_strptime", + #"subprocess", + #"sunau", + #"symbol", + #"symtable", + #"sysconfig", + #"tabnanny", + #"telnetlib", + #"test", + #"textwrap", + #"this", + #"_threading_local", + #"threading", + #"timeit", + #"tkinter", + #"tokenize", + #"token", + #"traceback", + #"trace", + #"tty", + #"turtledemo", + #"turtle", + #"unittest", + #"urllib", + #"uuid", + #"uu", + #"wave", + #"weakref", + #"webbrowser", + #"wsgiref", + #"xdrlib", + #"xml", + #"xmlrpc", + #"zipfile", + ]) + if minver >= 4: + REQUIRED_MODULES.extend([ + 'operator', + '_collections_abc', + '_bootlocale', + ]) + +if is_pypy: + # these are needed to correctly display the exceptions that may happen + # during the bootstrap + REQUIRED_MODULES.extend(['traceback', 'linecache']) + +class Logger(object): + + """ + Logging object for use in command-line script. Allows ranges of + levels, to avoid some redundancy of displayed information. + """ + + DEBUG = logging.DEBUG + INFO = logging.INFO + NOTIFY = (logging.INFO+logging.WARN)/2 + WARN = WARNING = logging.WARN + ERROR = logging.ERROR + FATAL = logging.FATAL + + LEVELS = [DEBUG, INFO, NOTIFY, WARN, ERROR, FATAL] + + def __init__(self, consumers): + self.consumers = consumers + self.indent = 0 + self.in_progress = None + self.in_progress_hanging = False + + def debug(self, msg, *args, **kw): + self.log(self.DEBUG, msg, *args, **kw) + def info(self, msg, *args, **kw): + self.log(self.INFO, msg, *args, **kw) + def notify(self, msg, *args, **kw): + self.log(self.NOTIFY, msg, *args, **kw) + def warn(self, msg, *args, **kw): + self.log(self.WARN, msg, *args, **kw) + def error(self, msg, *args, **kw): + self.log(self.ERROR, msg, *args, **kw) + def fatal(self, msg, *args, **kw): + self.log(self.FATAL, msg, *args, **kw) + def log(self, level, msg, *args, **kw): + if args: + if kw: + raise TypeError( + "You may give positional or keyword arguments, not both") + args = args or kw + rendered = None + for consumer_level, consumer in self.consumers: + if self.level_matches(level, consumer_level): + if (self.in_progress_hanging + and consumer in (sys.stdout, sys.stderr)): + self.in_progress_hanging = False + sys.stdout.write('\n') + sys.stdout.flush() + if rendered is None: + if args: + rendered = msg % args + else: + rendered = msg + rendered = ' '*self.indent + rendered + if hasattr(consumer, 'write'): + consumer.write(rendered+'\n') + else: + consumer(rendered) + + def start_progress(self, msg): + assert not self.in_progress, ( + "Tried to start_progress(%r) while in_progress %r" + % (msg, self.in_progress)) + if self.level_matches(self.NOTIFY, self._stdout_level()): + sys.stdout.write(msg) + sys.stdout.flush() + self.in_progress_hanging = True + else: + self.in_progress_hanging = False + self.in_progress = msg + + def end_progress(self, msg='done.'): + assert self.in_progress, ( + "Tried to end_progress without start_progress") + if self.stdout_level_matches(self.NOTIFY): + if not self.in_progress_hanging: + # Some message has been printed out since start_progress + sys.stdout.write('...' + self.in_progress + msg + '\n') + sys.stdout.flush() + else: + sys.stdout.write(msg + '\n') + sys.stdout.flush() + self.in_progress = None + self.in_progress_hanging = False + + def show_progress(self): + """If we are in a progress scope, and no log messages have been + shown, write out another '.'""" + if self.in_progress_hanging: + sys.stdout.write('.') + sys.stdout.flush() + + def stdout_level_matches(self, level): + """Returns true if a message at this level will go to stdout""" + return self.level_matches(level, self._stdout_level()) + + def _stdout_level(self): + """Returns the level that stdout runs at""" + for level, consumer in self.consumers: + if consumer is sys.stdout: + return level + return self.FATAL + + def level_matches(self, level, consumer_level): + """ + >>> l = Logger([]) + >>> l.level_matches(3, 4) + False + >>> l.level_matches(3, 2) + True + >>> l.level_matches(slice(None, 3), 3) + False + >>> l.level_matches(slice(None, 3), 2) + True + >>> l.level_matches(slice(1, 3), 1) + True + >>> l.level_matches(slice(2, 3), 1) + False + """ + if isinstance(level, slice): + start, stop = level.start, level.stop + if start is not None and start > consumer_level: + return False + if stop is not None and stop <= consumer_level: + return False + return True + else: + return level >= consumer_level + + #@classmethod + def level_for_integer(cls, level): + levels = cls.LEVELS + if level < 0: + return levels[0] + if level >= len(levels): + return levels[-1] + return levels[level] + + level_for_integer = classmethod(level_for_integer) + +# create a silent logger just to prevent this from being undefined +# will be overridden with requested verbosity main() is called. +logger = Logger([(Logger.LEVELS[-1], sys.stdout)]) + +def mkdir(path): + if not os.path.exists(path): + logger.info('Creating %s', path) + os.makedirs(path) + else: + logger.info('Directory %s already exists', path) + +def copyfileordir(src, dest, symlink=True): + if os.path.isdir(src): + shutil.copytree(src, dest, symlink) + else: + shutil.copy2(src, dest) + +def copyfile(src, dest, symlink=True): + if not os.path.exists(src): + # Some bad symlink in the src + logger.warn('Cannot find file %s (bad symlink)', src) + return + if os.path.exists(dest): + logger.debug('File %s already exists', dest) + return + if not os.path.exists(os.path.dirname(dest)): + logger.info('Creating parent directories for %s', os.path.dirname(dest)) + os.makedirs(os.path.dirname(dest)) + if not os.path.islink(src): + srcpath = os.path.abspath(src) + else: + srcpath = os.readlink(src) + if symlink and hasattr(os, 'symlink') and not is_win: + logger.info('Symlinking %s', dest) + try: + os.symlink(srcpath, dest) + except (OSError, NotImplementedError): + logger.info('Symlinking failed, copying to %s', dest) + copyfileordir(src, dest, symlink) + else: + logger.info('Copying to %s', dest) + copyfileordir(src, dest, symlink) + +def writefile(dest, content, overwrite=True): + if not os.path.exists(dest): + logger.info('Writing %s', dest) + f = open(dest, 'wb') + f.write(content.encode('utf-8')) + f.close() + return + else: + f = open(dest, 'rb') + c = f.read() + f.close() + if c != content.encode("utf-8"): + if not overwrite: + logger.notify('File %s exists with different content; not overwriting', dest) + return + logger.notify('Overwriting %s with new content', dest) + f = open(dest, 'wb') + f.write(content.encode('utf-8')) + f.close() + else: + logger.info('Content %s already in place', dest) + +def rmtree(dir): + if os.path.exists(dir): + logger.notify('Deleting tree %s', dir) + shutil.rmtree(dir) + else: + logger.info('Do not need to delete %s; already gone', dir) + +def make_exe(fn): + if hasattr(os, 'chmod'): + oldmode = os.stat(fn).st_mode & 0xFFF # 0o7777 + newmode = (oldmode | 0x16D) & 0xFFF # 0o555, 0o7777 + os.chmod(fn, newmode) + logger.info('Changed mode of %s to %s', fn, oct(newmode)) + +def _find_file(filename, dirs): + for dir in reversed(dirs): + files = glob.glob(os.path.join(dir, filename)) + if files and os.path.isfile(files[0]): + return True, files[0] + return False, filename + +def file_search_dirs(): + here = os.path.dirname(os.path.abspath(__file__)) + dirs = [here, join(here, 'virtualenv_support')] + if os.path.splitext(os.path.dirname(__file__))[0] != 'virtualenv': + # Probably some boot script; just in case virtualenv is installed... + try: + import virtualenv + except ImportError: + pass + else: + dirs.append(os.path.join( + os.path.dirname(virtualenv.__file__), 'virtualenv_support')) + return [d for d in dirs if os.path.isdir(d)] + + +class UpdatingDefaultsHelpFormatter(optparse.IndentedHelpFormatter): + """ + Custom help formatter for use in ConfigOptionParser that updates + the defaults before expanding them, allowing them to show up correctly + in the help listing + """ + def expand_default(self, option): + if self.parser is not None: + self.parser.update_defaults(self.parser.defaults) + return optparse.IndentedHelpFormatter.expand_default(self, option) + + +class ConfigOptionParser(optparse.OptionParser): + """ + Custom option parser which updates its defaults by checking the + configuration files and environmental variables + """ + def __init__(self, *args, **kwargs): + self.config = ConfigParser.RawConfigParser() + self.files = self.get_config_files() + self.config.read(self.files) + optparse.OptionParser.__init__(self, *args, **kwargs) + + def get_config_files(self): + config_file = os.environ.get('VIRTUALENV_CONFIG_FILE', False) + if config_file and os.path.exists(config_file): + return [config_file] + return [default_config_file] + + def update_defaults(self, defaults): + """ + Updates the given defaults with values from the config files and + the environ. Does a little special handling for certain types of + options (lists). + """ + # Then go and look for the other sources of configuration: + config = {} + # 1. config files + config.update(dict(self.get_config_section('virtualenv'))) + # 2. environmental variables + config.update(dict(self.get_environ_vars())) + # Then set the options with those values + for key, val in config.items(): + key = key.replace('_', '-') + if not key.startswith('--'): + key = '--%s' % key # only prefer long opts + option = self.get_option(key) + if option is not None: + # ignore empty values + if not val: + continue + # handle multiline configs + if option.action == 'append': + val = val.split() + else: + option.nargs = 1 + if option.action == 'store_false': + val = not strtobool(val) + elif option.action in ('store_true', 'count'): + val = strtobool(val) + try: + val = option.convert_value(key, val) + except optparse.OptionValueError: + e = sys.exc_info()[1] + print("An error occurred during configuration: %s" % e) + sys.exit(3) + defaults[option.dest] = val + return defaults + + def get_config_section(self, name): + """ + Get a section of a configuration + """ + if self.config.has_section(name): + return self.config.items(name) + return [] + + def get_environ_vars(self, prefix='VIRTUALENV_'): + """ + Returns a generator with all environmental vars with prefix VIRTUALENV + """ + for key, val in os.environ.items(): + if key.startswith(prefix): + yield (key.replace(prefix, '').lower(), val) + + def get_default_values(self): + """ + Overridding to make updating the defaults after instantiation of + the option parser possible, update_defaults() does the dirty work. + """ + if not self.process_default_values: + # Old, pre-Optik 1.5 behaviour. + return optparse.Values(self.defaults) + + defaults = self.update_defaults(self.defaults.copy()) # ours + for option in self._get_all_options(): + default = defaults.get(option.dest) + if isinstance(default, basestring): + opt_str = option.get_opt_string() + defaults[option.dest] = option.check_value(opt_str, default) + return optparse.Values(defaults) + + +def main(): + parser = ConfigOptionParser( + version=virtualenv_version, + usage="%prog [OPTIONS] DEST_DIR", + formatter=UpdatingDefaultsHelpFormatter()) + + parser.add_option( + '-v', '--verbose', + action='count', + dest='verbose', + default=0, + help="Increase verbosity.") + + parser.add_option( + '-q', '--quiet', + action='count', + dest='quiet', + default=0, + help='Decrease verbosity.') + + parser.add_option( + '-p', '--python', + dest='python', + metavar='PYTHON_EXE', + help='The Python interpreter to use, e.g., --python=python2.5 will use the python2.5 ' + 'interpreter to create the new environment. The default is the interpreter that ' + 'virtualenv was installed with (%s)' % sys.executable) + + parser.add_option( + '--clear', + dest='clear', + action='store_true', + help="Clear out the non-root install and start from scratch.") + + parser.set_defaults(system_site_packages=False) + parser.add_option( + '--no-site-packages', + dest='system_site_packages', + action='store_false', + help="DEPRECATED. Retained only for backward compatibility. " + "Not having access to global site-packages is now the default behavior.") + + parser.add_option( + '--system-site-packages', + dest='system_site_packages', + action='store_true', + help="Give the virtual environment access to the global site-packages.") + + parser.add_option( + '--always-copy', + dest='symlink', + action='store_false', + default=True, + help="Always copy files rather than symlinking.") + + parser.add_option( + '--unzip-setuptools', + dest='unzip_setuptools', + action='store_true', + help="Unzip Setuptools when installing it.") + + parser.add_option( + '--relocatable', + dest='relocatable', + action='store_true', + help='Make an EXISTING virtualenv environment relocatable. ' + 'This fixes up scripts and makes all .pth files relative.') + + parser.add_option( + '--no-setuptools', + dest='no_setuptools', + action='store_true', + help='Do not install setuptools (or pip) in the new virtualenv.') + + parser.add_option( + '--no-pip', + dest='no_pip', + action='store_true', + help='Do not install pip in the new virtualenv.') + + parser.add_option( + '--no-wheel', + dest='no_wheel', + action='store_true', + help='Do not install wheel in the new virtualenv.') + + default_search_dirs = file_search_dirs() + parser.add_option( + '--extra-search-dir', + dest="search_dirs", + action="append", + metavar='DIR', + default=default_search_dirs, + help="Directory to look for setuptools/pip distributions in. " + "This option can be used multiple times.") + + parser.add_option( + '--never-download', + dest="never_download", + action="store_true", + default=True, + help="DEPRECATED. Retained only for backward compatibility. This option has no effect. " + "Virtualenv never downloads pip or setuptools.") + + parser.add_option( + '--prompt', + dest='prompt', + help='Provides an alternative prompt prefix for this environment.') + + parser.add_option( + '--setuptools', + dest='setuptools', + action='store_true', + help="DEPRECATED. Retained only for backward compatibility. This option has no effect.") + + parser.add_option( + '--distribute', + dest='distribute', + action='store_true', + help="DEPRECATED. Retained only for backward compatibility. This option has no effect.") + + if 'extend_parser' in globals(): + extend_parser(parser) + + options, args = parser.parse_args() + + global logger + + if 'adjust_options' in globals(): + adjust_options(options, args) + + verbosity = options.verbose - options.quiet + logger = Logger([(Logger.level_for_integer(2 - verbosity), sys.stdout)]) + + if options.python and not os.environ.get('VIRTUALENV_INTERPRETER_RUNNING'): + env = os.environ.copy() + interpreter = resolve_interpreter(options.python) + if interpreter == sys.executable: + logger.warn('Already using interpreter %s' % interpreter) + else: + logger.notify('Running virtualenv with interpreter %s' % interpreter) + env['VIRTUALENV_INTERPRETER_RUNNING'] = 'true' + file = __file__ + if file.endswith('.pyc'): + file = file[:-1] + popen = subprocess.Popen([interpreter, file] + sys.argv[1:], env=env) + raise SystemExit(popen.wait()) + + if not args: + print('You must provide a DEST_DIR') + parser.print_help() + sys.exit(2) + if len(args) > 1: + print('There must be only one argument: DEST_DIR (you gave %s)' % ( + ' '.join(args))) + parser.print_help() + sys.exit(2) + + home_dir = args[0] + + if os.environ.get('WORKING_ENV'): + logger.fatal('ERROR: you cannot run virtualenv while in a workingenv') + logger.fatal('Please deactivate your workingenv, then re-run this script') + sys.exit(3) + + if 'PYTHONHOME' in os.environ: + logger.warn('PYTHONHOME is set. You *must* activate the virtualenv before using it') + del os.environ['PYTHONHOME'] + + if options.relocatable: + make_environment_relocatable(home_dir) + return + + if not options.never_download: + logger.warn('The --never-download option is for backward compatibility only.') + logger.warn('Setting it to false is no longer supported, and will be ignored.') + + create_environment(home_dir, + site_packages=options.system_site_packages, + clear=options.clear, + unzip_setuptools=options.unzip_setuptools, + prompt=options.prompt, + search_dirs=options.search_dirs, + never_download=True, + no_setuptools=options.no_setuptools, + no_pip=options.no_pip, + no_wheel=options.no_wheel, + symlink=options.symlink) + if 'after_install' in globals(): + after_install(options, home_dir) + +def call_subprocess(cmd, show_stdout=True, + filter_stdout=None, cwd=None, + raise_on_returncode=True, extra_env=None, + remove_from_env=None): + cmd_parts = [] + for part in cmd: + if len(part) > 45: + part = part[:20]+"..."+part[-20:] + if ' ' in part or '\n' in part or '"' in part or "'" in part: + part = '"%s"' % part.replace('"', '\\"') + if hasattr(part, 'decode'): + try: + part = part.decode(sys.getdefaultencoding()) + except UnicodeDecodeError: + part = part.decode(sys.getfilesystemencoding()) + cmd_parts.append(part) + cmd_desc = ' '.join(cmd_parts) + if show_stdout: + stdout = None + else: + stdout = subprocess.PIPE + logger.debug("Running command %s" % cmd_desc) + if extra_env or remove_from_env: + env = os.environ.copy() + if extra_env: + env.update(extra_env) + if remove_from_env: + for varname in remove_from_env: + env.pop(varname, None) + else: + env = None + try: + proc = subprocess.Popen( + cmd, stderr=subprocess.STDOUT, stdin=None, stdout=stdout, + cwd=cwd, env=env) + except Exception: + e = sys.exc_info()[1] + logger.fatal( + "Error %s while executing command %s" % (e, cmd_desc)) + raise + all_output = [] + if stdout is not None: + stdout = proc.stdout + encoding = sys.getdefaultencoding() + fs_encoding = sys.getfilesystemencoding() + while 1: + line = stdout.readline() + try: + line = line.decode(encoding) + except UnicodeDecodeError: + line = line.decode(fs_encoding) + if not line: + break + line = line.rstrip() + all_output.append(line) + if filter_stdout: + level = filter_stdout(line) + if isinstance(level, tuple): + level, line = level + logger.log(level, line) + if not logger.stdout_level_matches(level): + logger.show_progress() + else: + logger.info(line) + else: + proc.communicate() + proc.wait() + if proc.returncode: + if raise_on_returncode: + if all_output: + logger.notify('Complete output from command %s:' % cmd_desc) + logger.notify('\n'.join(all_output) + '\n----------------------------------------') + raise OSError( + "Command %s failed with error code %s" + % (cmd_desc, proc.returncode)) + else: + logger.warn( + "Command %s had error code %s" + % (cmd_desc, proc.returncode)) + +def filter_install_output(line): + if line.strip().startswith('running'): + return Logger.INFO + return Logger.DEBUG + +def find_wheels(projects, search_dirs): + """Find wheels from which we can import PROJECTS. + + Scan through SEARCH_DIRS for a wheel for each PROJECT in turn. Return + a list of the first wheel found for each PROJECT + """ + + wheels = [] + + # Look through SEARCH_DIRS for the first suitable wheel. Don't bother + # about version checking here, as this is simply to get something we can + # then use to install the correct version. + for project in projects: + for dirname in search_dirs: + # This relies on only having "universal" wheels available. + # The pattern could be tightened to require -py2.py3-none-any.whl. + files = glob.glob(os.path.join(dirname, project + '-*.whl')) + if files: + wheels.append(os.path.abspath(files[0])) + break + else: + # We're out of luck, so quit with a suitable error + logger.fatal('Cannot find a wheel for %s' % (project,)) + + return wheels + +def install_wheel(project_names, py_executable, search_dirs=None): + if search_dirs is None: + search_dirs = file_search_dirs() + + wheels = find_wheels(['setuptools', 'pip'], search_dirs) + pythonpath = os.pathsep.join(wheels) + findlinks = ' '.join(search_dirs) + + cmd = [ + py_executable, '-c', + 'import sys, pip; sys.exit(pip.main(["install", "--ignore-installed"] + sys.argv[1:]))', + ] + project_names + logger.start_progress('Installing %s...' % (', '.join(project_names))) + logger.indent += 2 + try: + call_subprocess(cmd, show_stdout=False, + extra_env = { + 'PYTHONPATH': pythonpath, + 'JYTHONPATH': pythonpath, # for Jython < 3.x + 'PIP_FIND_LINKS': findlinks, + 'PIP_USE_WHEEL': '1', + 'PIP_PRE': '1', + 'PIP_NO_INDEX': '1' + } + ) + finally: + logger.indent -= 2 + logger.end_progress() + +def create_environment(home_dir, site_packages=False, clear=False, + unzip_setuptools=False, + prompt=None, search_dirs=None, never_download=False, + no_setuptools=False, no_pip=False, no_wheel=False, + symlink=True): + """ + Creates a new environment in ``home_dir``. + + If ``site_packages`` is true, then the global ``site-packages/`` + directory will be on the path. + + If ``clear`` is true (default False) then the environment will + first be cleared. + """ + home_dir, lib_dir, inc_dir, bin_dir = path_locations(home_dir) + + py_executable = os.path.abspath(install_python( + home_dir, lib_dir, inc_dir, bin_dir, + site_packages=site_packages, clear=clear, symlink=symlink)) + + install_distutils(home_dir) + + if not no_setuptools: + to_install = ['setuptools'] + if not no_pip: + to_install.append('pip') + if not no_wheel: + to_install.append('wheel') + install_wheel(to_install, py_executable, search_dirs) + + install_activate(home_dir, bin_dir, prompt) + +def is_executable_file(fpath): + return os.path.isfile(fpath) and os.access(fpath, os.X_OK) + +def path_locations(home_dir): + """Return the path locations for the environment (where libraries are, + where scripts go, etc)""" + # XXX: We'd use distutils.sysconfig.get_python_inc/lib but its + # prefix arg is broken: http://bugs.python.org/issue3386 + if is_win: + # Windows has lots of problems with executables with spaces in + # the name; this function will remove them (using the ~1 + # format): + mkdir(home_dir) + if ' ' in home_dir: + import ctypes + GetShortPathName = ctypes.windll.kernel32.GetShortPathNameW + size = max(len(home_dir)+1, 256) + buf = ctypes.create_unicode_buffer(size) + try: + u = unicode + except NameError: + u = str + ret = GetShortPathName(u(home_dir), buf, size) + if not ret: + print('Error: the path "%s" has a space in it' % home_dir) + print('We could not determine the short pathname for it.') + print('Exiting.') + sys.exit(3) + home_dir = str(buf.value) + lib_dir = join(home_dir, 'Lib') + inc_dir = join(home_dir, 'Include') + bin_dir = join(home_dir, 'Scripts') + if is_jython: + lib_dir = join(home_dir, 'Lib') + inc_dir = join(home_dir, 'Include') + bin_dir = join(home_dir, 'bin') + elif is_pypy: + lib_dir = home_dir + inc_dir = join(home_dir, 'include') + bin_dir = join(home_dir, 'bin') + elif not is_win: + lib_dir = join(home_dir, 'lib', py_version) + multiarch_exec = '/usr/bin/multiarch-platform' + if is_executable_file(multiarch_exec): + # In Mageia (2) and Mandriva distros the include dir must be like: + # virtualenv/include/multiarch-x86_64-linux/python2.7 + # instead of being virtualenv/include/python2.7 + p = subprocess.Popen(multiarch_exec, stdout=subprocess.PIPE, stderr=subprocess.PIPE) + stdout, stderr = p.communicate() + # stdout.strip is needed to remove newline character + inc_dir = join(home_dir, 'include', stdout.strip(), py_version + abiflags) + else: + inc_dir = join(home_dir, 'include', py_version + abiflags) + bin_dir = join(home_dir, 'bin') + return home_dir, lib_dir, inc_dir, bin_dir + + +def change_prefix(filename, dst_prefix): + prefixes = [sys.prefix] + + if is_darwin: + prefixes.extend(( + os.path.join("/Library/Python", sys.version[:3], "site-packages"), + os.path.join(sys.prefix, "Extras", "lib", "python"), + os.path.join("~", "Library", "Python", sys.version[:3], "site-packages"), + # Python 2.6 no-frameworks + os.path.join("~", ".local", "lib","python", sys.version[:3], "site-packages"), + # System Python 2.7 on OSX Mountain Lion + os.path.join("~", "Library", "Python", sys.version[:3], "lib", "python", "site-packages"))) + + if hasattr(sys, 'real_prefix'): + prefixes.append(sys.real_prefix) + if hasattr(sys, 'base_prefix'): + prefixes.append(sys.base_prefix) + prefixes = list(map(os.path.expanduser, prefixes)) + prefixes = list(map(os.path.abspath, prefixes)) + # Check longer prefixes first so we don't split in the middle of a filename + prefixes = sorted(prefixes, key=len, reverse=True) + filename = os.path.abspath(filename) + for src_prefix in prefixes: + if filename.startswith(src_prefix): + _, relpath = filename.split(src_prefix, 1) + if src_prefix != os.sep: # sys.prefix == "/" + assert relpath[0] == os.sep + relpath = relpath[1:] + return join(dst_prefix, relpath) + assert False, "Filename %s does not start with any of these prefixes: %s" % \ + (filename, prefixes) + +def copy_required_modules(dst_prefix, symlink): + import imp + # If we are running under -p, we need to remove the current + # directory from sys.path temporarily here, so that we + # definitely get the modules from the site directory of + # the interpreter we are running under, not the one + # virtualenv.py is installed under (which might lead to py2/py3 + # incompatibility issues) + _prev_sys_path = sys.path + if os.environ.get('VIRTUALENV_INTERPRETER_RUNNING'): + sys.path = sys.path[1:] + try: + for modname in REQUIRED_MODULES: + if modname in sys.builtin_module_names: + logger.info("Ignoring built-in bootstrap module: %s" % modname) + continue + try: + f, filename, _ = imp.find_module(modname) + except ImportError: + logger.info("Cannot import bootstrap module: %s" % modname) + else: + if f is not None: + f.close() + # special-case custom readline.so on OS X, but not for pypy: + if modname == 'readline' and sys.platform == 'darwin' and not ( + is_pypy or filename.endswith(join('lib-dynload', 'readline.so'))): + dst_filename = join(dst_prefix, 'lib', 'python%s' % sys.version[:3], 'readline.so') + elif modname == 'readline' and sys.platform == 'win32': + # special-case for Windows, where readline is not a + # standard module, though it may have been installed in + # site-packages by a third-party package + pass + else: + dst_filename = change_prefix(filename, dst_prefix) + copyfile(filename, dst_filename, symlink) + if filename.endswith('.pyc'): + pyfile = filename[:-1] + if os.path.exists(pyfile): + copyfile(pyfile, dst_filename[:-1], symlink) + finally: + sys.path = _prev_sys_path + + +def subst_path(prefix_path, prefix, home_dir): + prefix_path = os.path.normpath(prefix_path) + prefix = os.path.normpath(prefix) + home_dir = os.path.normpath(home_dir) + if not prefix_path.startswith(prefix): + logger.warn('Path not in prefix %r %r', prefix_path, prefix) + return + return prefix_path.replace(prefix, home_dir, 1) + + +def install_python(home_dir, lib_dir, inc_dir, bin_dir, site_packages, clear, symlink=True): + """Install just the base environment, no distutils patches etc""" + if sys.executable.startswith(bin_dir): + print('Please use the *system* python to run this script') + return + + if clear: + rmtree(lib_dir) + ## FIXME: why not delete it? + ## Maybe it should delete everything with #!/path/to/venv/python in it + logger.notify('Not deleting %s', bin_dir) + + if hasattr(sys, 'real_prefix'): + logger.notify('Using real prefix %r' % sys.real_prefix) + prefix = sys.real_prefix + elif hasattr(sys, 'base_prefix'): + logger.notify('Using base prefix %r' % sys.base_prefix) + prefix = sys.base_prefix + else: + prefix = sys.prefix + mkdir(lib_dir) + fix_lib64(lib_dir, symlink) + stdlib_dirs = [os.path.dirname(os.__file__)] + if is_win: + stdlib_dirs.append(join(os.path.dirname(stdlib_dirs[0]), 'DLLs')) + elif is_darwin: + stdlib_dirs.append(join(stdlib_dirs[0], 'site-packages')) + if hasattr(os, 'symlink'): + logger.info('Symlinking Python bootstrap modules') + else: + logger.info('Copying Python bootstrap modules') + logger.indent += 2 + try: + # copy required files... + for stdlib_dir in stdlib_dirs: + if not os.path.isdir(stdlib_dir): + continue + for fn in os.listdir(stdlib_dir): + bn = os.path.splitext(fn)[0] + if fn != 'site-packages' and bn in REQUIRED_FILES: + copyfile(join(stdlib_dir, fn), join(lib_dir, fn), symlink) + # ...and modules + copy_required_modules(home_dir, symlink) + finally: + logger.indent -= 2 + mkdir(join(lib_dir, 'site-packages')) + import site + site_filename = site.__file__ + if site_filename.endswith('.pyc'): + site_filename = site_filename[:-1] + elif site_filename.endswith('$py.class'): + site_filename = site_filename.replace('$py.class', '.py') + site_filename_dst = change_prefix(site_filename, home_dir) + site_dir = os.path.dirname(site_filename_dst) + writefile(site_filename_dst, SITE_PY) + writefile(join(site_dir, 'orig-prefix.txt'), prefix) + site_packages_filename = join(site_dir, 'no-global-site-packages.txt') + if not site_packages: + writefile(site_packages_filename, '') + + if is_pypy or is_win: + stdinc_dir = join(prefix, 'include') + else: + stdinc_dir = join(prefix, 'include', py_version + abiflags) + if os.path.exists(stdinc_dir): + copyfile(stdinc_dir, inc_dir, symlink) + else: + logger.debug('No include dir %s' % stdinc_dir) + + platinc_dir = distutils.sysconfig.get_python_inc(plat_specific=1) + if platinc_dir != stdinc_dir: + platinc_dest = distutils.sysconfig.get_python_inc( + plat_specific=1, prefix=home_dir) + if platinc_dir == platinc_dest: + # Do platinc_dest manually due to a CPython bug; + # not http://bugs.python.org/issue3386 but a close cousin + platinc_dest = subst_path(platinc_dir, prefix, home_dir) + if platinc_dest: + # PyPy's stdinc_dir and prefix are relative to the original binary + # (traversing virtualenvs), whereas the platinc_dir is relative to + # the inner virtualenv and ignores the prefix argument. + # This seems more evolved than designed. + copyfile(platinc_dir, platinc_dest, symlink) + + # pypy never uses exec_prefix, just ignore it + if sys.exec_prefix != prefix and not is_pypy: + if is_win: + exec_dir = join(sys.exec_prefix, 'lib') + elif is_jython: + exec_dir = join(sys.exec_prefix, 'Lib') + else: + exec_dir = join(sys.exec_prefix, 'lib', py_version) + for fn in os.listdir(exec_dir): + copyfile(join(exec_dir, fn), join(lib_dir, fn), symlink) + + if is_jython: + # Jython has either jython-dev.jar and javalib/ dir, or just + # jython.jar + for name in 'jython-dev.jar', 'javalib', 'jython.jar': + src = join(prefix, name) + if os.path.exists(src): + copyfile(src, join(home_dir, name), symlink) + # XXX: registry should always exist after Jython 2.5rc1 + src = join(prefix, 'registry') + if os.path.exists(src): + copyfile(src, join(home_dir, 'registry'), symlink=False) + copyfile(join(prefix, 'cachedir'), join(home_dir, 'cachedir'), + symlink=False) + + mkdir(bin_dir) + py_executable = join(bin_dir, os.path.basename(sys.executable)) + if 'Python.framework' in prefix: + # OS X framework builds cause validation to break + # https://github.com/pypa/virtualenv/issues/322 + if os.environ.get('__PYVENV_LAUNCHER__'): + del os.environ["__PYVENV_LAUNCHER__"] + if re.search(r'/Python(?:-32|-64)*$', py_executable): + # The name of the python executable is not quite what + # we want, rename it. + py_executable = os.path.join( + os.path.dirname(py_executable), 'python') + + logger.notify('New %s executable in %s', expected_exe, py_executable) + pcbuild_dir = os.path.dirname(sys.executable) + pyd_pth = os.path.join(lib_dir, 'site-packages', 'virtualenv_builddir_pyd.pth') + if is_win and os.path.exists(os.path.join(pcbuild_dir, 'build.bat')): + logger.notify('Detected python running from build directory %s', pcbuild_dir) + logger.notify('Writing .pth file linking to build directory for *.pyd files') + writefile(pyd_pth, pcbuild_dir) + else: + pcbuild_dir = None + if os.path.exists(pyd_pth): + logger.info('Deleting %s (not Windows env or not build directory python)' % pyd_pth) + os.unlink(pyd_pth) + + if sys.executable != py_executable: + ## FIXME: could I just hard link? + executable = sys.executable + shutil.copyfile(executable, py_executable) + make_exe(py_executable) + if is_win or is_cygwin: + pythonw = os.path.join(os.path.dirname(sys.executable), 'pythonw.exe') + if os.path.exists(pythonw): + logger.info('Also created pythonw.exe') + shutil.copyfile(pythonw, os.path.join(os.path.dirname(py_executable), 'pythonw.exe')) + python_d = os.path.join(os.path.dirname(sys.executable), 'python_d.exe') + python_d_dest = os.path.join(os.path.dirname(py_executable), 'python_d.exe') + if os.path.exists(python_d): + logger.info('Also created python_d.exe') + shutil.copyfile(python_d, python_d_dest) + elif os.path.exists(python_d_dest): + logger.info('Removed python_d.exe as it is no longer at the source') + os.unlink(python_d_dest) + # we need to copy the DLL to enforce that windows will load the correct one. + # may not exist if we are cygwin. + py_executable_dll = 'python%s%s.dll' % ( + sys.version_info[0], sys.version_info[1]) + py_executable_dll_d = 'python%s%s_d.dll' % ( + sys.version_info[0], sys.version_info[1]) + pythondll = os.path.join(os.path.dirname(sys.executable), py_executable_dll) + pythondll_d = os.path.join(os.path.dirname(sys.executable), py_executable_dll_d) + pythondll_d_dest = os.path.join(os.path.dirname(py_executable), py_executable_dll_d) + if os.path.exists(pythondll): + logger.info('Also created %s' % py_executable_dll) + shutil.copyfile(pythondll, os.path.join(os.path.dirname(py_executable), py_executable_dll)) + if os.path.exists(pythondll_d): + logger.info('Also created %s' % py_executable_dll_d) + shutil.copyfile(pythondll_d, pythondll_d_dest) + elif os.path.exists(pythondll_d_dest): + logger.info('Removed %s as the source does not exist' % pythondll_d_dest) + os.unlink(pythondll_d_dest) + if is_pypy: + # make a symlink python --> pypy-c + python_executable = os.path.join(os.path.dirname(py_executable), 'python') + if sys.platform in ('win32', 'cygwin'): + python_executable += '.exe' + logger.info('Also created executable %s' % python_executable) + copyfile(py_executable, python_executable, symlink) + + if is_win: + for name in ['libexpat.dll', 'libpypy.dll', 'libpypy-c.dll', + 'libeay32.dll', 'ssleay32.dll', 'sqlite3.dll', + 'tcl85.dll', 'tk85.dll']: + src = join(prefix, name) + if os.path.exists(src): + copyfile(src, join(bin_dir, name), symlink) + + for d in sys.path: + if d.endswith('lib_pypy'): + break + else: + logger.fatal('Could not find lib_pypy in sys.path') + raise SystemExit(3) + logger.info('Copying lib_pypy') + copyfile(d, os.path.join(home_dir, 'lib_pypy'), symlink) + + if os.path.splitext(os.path.basename(py_executable))[0] != expected_exe: + secondary_exe = os.path.join(os.path.dirname(py_executable), + expected_exe) + py_executable_ext = os.path.splitext(py_executable)[1] + if py_executable_ext.lower() == '.exe': + # python2.4 gives an extension of '.4' :P + secondary_exe += py_executable_ext + if os.path.exists(secondary_exe): + logger.warn('Not overwriting existing %s script %s (you must use %s)' + % (expected_exe, secondary_exe, py_executable)) + else: + logger.notify('Also creating executable in %s' % secondary_exe) + shutil.copyfile(sys.executable, secondary_exe) + make_exe(secondary_exe) + + if '.framework' in prefix: + if 'Python.framework' in prefix: + logger.debug('MacOSX Python framework detected') + # Make sure we use the embedded interpreter inside + # the framework, even if sys.executable points to + # the stub executable in ${sys.prefix}/bin + # See http://groups.google.com/group/python-virtualenv/ + # browse_thread/thread/17cab2f85da75951 + original_python = os.path.join( + prefix, 'Resources/Python.app/Contents/MacOS/Python') + if 'EPD' in prefix: + logger.debug('EPD framework detected') + original_python = os.path.join(prefix, 'bin/python') + shutil.copy(original_python, py_executable) + + # Copy the framework's dylib into the virtual + # environment + virtual_lib = os.path.join(home_dir, '.Python') + + if os.path.exists(virtual_lib): + os.unlink(virtual_lib) + copyfile( + os.path.join(prefix, 'Python'), + virtual_lib, + symlink) + + # And then change the install_name of the copied python executable + try: + mach_o_change(py_executable, + os.path.join(prefix, 'Python'), + '@executable_path/../.Python') + except: + e = sys.exc_info()[1] + logger.warn("Could not call mach_o_change: %s. " + "Trying to call install_name_tool instead." % e) + try: + call_subprocess( + ["install_name_tool", "-change", + os.path.join(prefix, 'Python'), + '@executable_path/../.Python', + py_executable]) + except: + logger.fatal("Could not call install_name_tool -- you must " + "have Apple's development tools installed") + raise + + if not is_win: + # Ensure that 'python', 'pythonX' and 'pythonX.Y' all exist + py_exe_version_major = 'python%s' % sys.version_info[0] + py_exe_version_major_minor = 'python%s.%s' % ( + sys.version_info[0], sys.version_info[1]) + py_exe_no_version = 'python' + required_symlinks = [ py_exe_no_version, py_exe_version_major, + py_exe_version_major_minor ] + + py_executable_base = os.path.basename(py_executable) + + if py_executable_base in required_symlinks: + # Don't try to symlink to yourself. + required_symlinks.remove(py_executable_base) + + for pth in required_symlinks: + full_pth = join(bin_dir, pth) + if os.path.exists(full_pth): + os.unlink(full_pth) + if symlink: + os.symlink(py_executable_base, full_pth) + else: + copyfile(py_executable, full_pth, symlink) + + if is_win and ' ' in py_executable: + # There's a bug with subprocess on Windows when using a first + # argument that has a space in it. Instead we have to quote + # the value: + py_executable = '"%s"' % py_executable + # NOTE: keep this check as one line, cmd.exe doesn't cope with line breaks + cmd = [py_executable, '-c', 'import sys;out=sys.stdout;' + 'getattr(out, "buffer", out).write(sys.prefix.encode("utf-8"))'] + logger.info('Testing executable with %s %s "%s"' % tuple(cmd)) + try: + proc = subprocess.Popen(cmd, + stdout=subprocess.PIPE) + proc_stdout, proc_stderr = proc.communicate() + except OSError: + e = sys.exc_info()[1] + if e.errno == errno.EACCES: + logger.fatal('ERROR: The executable %s could not be run: %s' % (py_executable, e)) + sys.exit(100) + else: + raise e + + proc_stdout = proc_stdout.strip().decode("utf-8") + proc_stdout = os.path.normcase(os.path.abspath(proc_stdout)) + norm_home_dir = os.path.normcase(os.path.abspath(home_dir)) + if hasattr(norm_home_dir, 'decode'): + norm_home_dir = norm_home_dir.decode(sys.getfilesystemencoding()) + if proc_stdout != norm_home_dir: + logger.fatal( + 'ERROR: The executable %s is not functioning' % py_executable) + logger.fatal( + 'ERROR: It thinks sys.prefix is %r (should be %r)' + % (proc_stdout, norm_home_dir)) + logger.fatal( + 'ERROR: virtualenv is not compatible with this system or executable') + if is_win: + logger.fatal( + 'Note: some Windows users have reported this error when they ' + 'installed Python for "Only this user" or have multiple ' + 'versions of Python installed. Copying the appropriate ' + 'PythonXX.dll to the virtualenv Scripts/ directory may fix ' + 'this problem.') + sys.exit(100) + else: + logger.info('Got sys.prefix result: %r' % proc_stdout) + + pydistutils = os.path.expanduser('~/.pydistutils.cfg') + if os.path.exists(pydistutils): + logger.notify('Please make sure you remove any previous custom paths from ' + 'your %s file.' % pydistutils) + ## FIXME: really this should be calculated earlier + + fix_local_scheme(home_dir, symlink) + + if site_packages: + if os.path.exists(site_packages_filename): + logger.info('Deleting %s' % site_packages_filename) + os.unlink(site_packages_filename) + + return py_executable + + +def install_activate(home_dir, bin_dir, prompt=None): + home_dir = os.path.abspath(home_dir) + if is_win or is_jython and os._name == 'nt': + files = { + 'activate.bat': ACTIVATE_BAT, + 'deactivate.bat': DEACTIVATE_BAT, + 'activate.ps1': ACTIVATE_PS, + } + + # MSYS needs paths of the form /c/path/to/file + drive, tail = os.path.splitdrive(home_dir.replace(os.sep, '/')) + home_dir_msys = (drive and "/%s%s" or "%s%s") % (drive[:1], tail) + + # Run-time conditional enables (basic) Cygwin compatibility + home_dir_sh = ("""$(if [ "$OSTYPE" "==" "cygwin" ]; then cygpath -u '%s'; else echo '%s'; fi;)""" % + (home_dir, home_dir_msys)) + files['activate'] = ACTIVATE_SH.replace('__VIRTUAL_ENV__', home_dir_sh) + + else: + files = {'activate': ACTIVATE_SH} + + # suppling activate.fish in addition to, not instead of, the + # bash script support. + files['activate.fish'] = ACTIVATE_FISH + + # same for csh/tcsh support... + files['activate.csh'] = ACTIVATE_CSH + + files['activate_this.py'] = ACTIVATE_THIS + if hasattr(home_dir, 'decode'): + home_dir = home_dir.decode(sys.getfilesystemencoding()) + vname = os.path.basename(home_dir) + for name, content in files.items(): + content = content.replace('__VIRTUAL_PROMPT__', prompt or '') + content = content.replace('__VIRTUAL_WINPROMPT__', prompt or '(%s)' % vname) + content = content.replace('__VIRTUAL_ENV__', home_dir) + content = content.replace('__VIRTUAL_NAME__', vname) + content = content.replace('__BIN_NAME__', os.path.basename(bin_dir)) + writefile(os.path.join(bin_dir, name), content) + +def install_distutils(home_dir): + distutils_path = change_prefix(distutils.__path__[0], home_dir) + mkdir(distutils_path) + ## FIXME: maybe this prefix setting should only be put in place if + ## there's a local distutils.cfg with a prefix setting? + home_dir = os.path.abspath(home_dir) + ## FIXME: this is breaking things, removing for now: + #distutils_cfg = DISTUTILS_CFG + "\n[install]\nprefix=%s\n" % home_dir + writefile(os.path.join(distutils_path, '__init__.py'), DISTUTILS_INIT) + writefile(os.path.join(distutils_path, 'distutils.cfg'), DISTUTILS_CFG, overwrite=False) + +def fix_local_scheme(home_dir, symlink=True): + """ + Platforms that use the "posix_local" install scheme (like Ubuntu with + Python 2.7) need to be given an additional "local" location, sigh. + """ + try: + import sysconfig + except ImportError: + pass + else: + if sysconfig._get_default_scheme() == 'posix_local': + local_path = os.path.join(home_dir, 'local') + if not os.path.exists(local_path): + os.mkdir(local_path) + for subdir_name in os.listdir(home_dir): + if subdir_name == 'local': + continue + copyfile(os.path.abspath(os.path.join(home_dir, subdir_name)), \ + os.path.join(local_path, subdir_name), symlink) + +def fix_lib64(lib_dir, symlink=True): + """ + Some platforms (particularly Gentoo on x64) put things in lib64/pythonX.Y + instead of lib/pythonX.Y. If this is such a platform we'll just create a + symlink so lib64 points to lib + """ + if [p for p in distutils.sysconfig.get_config_vars().values() + if isinstance(p, basestring) and 'lib64' in p]: + # PyPy's library path scheme is not affected by this. + # Return early or we will die on the following assert. + if is_pypy: + logger.debug('PyPy detected, skipping lib64 symlinking') + return + + logger.debug('This system uses lib64; symlinking lib64 to lib') + + assert os.path.basename(lib_dir) == 'python%s' % sys.version[:3], ( + "Unexpected python lib dir: %r" % lib_dir) + lib_parent = os.path.dirname(lib_dir) + top_level = os.path.dirname(lib_parent) + lib_dir = os.path.join(top_level, 'lib') + lib64_link = os.path.join(top_level, 'lib64') + assert os.path.basename(lib_parent) == 'lib', ( + "Unexpected parent dir: %r" % lib_parent) + if os.path.lexists(lib64_link): + return + if symlink: + os.symlink('lib', lib64_link) + else: + copyfile('lib', lib64_link) + +def resolve_interpreter(exe): + """ + If the executable given isn't an absolute path, search $PATH for the interpreter + """ + # If the "executable" is a version number, get the installed executable for + # that version + python_versions = get_installed_pythons() + if exe in python_versions: + exe = python_versions[exe] + + if os.path.abspath(exe) != exe: + paths = os.environ.get('PATH', '').split(os.pathsep) + for path in paths: + if os.path.exists(os.path.join(path, exe)): + exe = os.path.join(path, exe) + break + if not os.path.exists(exe): + logger.fatal('The executable %s (from --python=%s) does not exist' % (exe, exe)) + raise SystemExit(3) + if not is_executable(exe): + logger.fatal('The executable %s (from --python=%s) is not executable' % (exe, exe)) + raise SystemExit(3) + return exe + +def is_executable(exe): + """Checks a file is executable""" + return os.access(exe, os.X_OK) + +############################################################ +## Relocating the environment: + +def make_environment_relocatable(home_dir): + """ + Makes the already-existing environment use relative paths, and takes out + the #!-based environment selection in scripts. + """ + home_dir, lib_dir, inc_dir, bin_dir = path_locations(home_dir) + activate_this = os.path.join(bin_dir, 'activate_this.py') + if not os.path.exists(activate_this): + logger.fatal( + 'The environment doesn\'t have a file %s -- please re-run virtualenv ' + 'on this environment to update it' % activate_this) + fixup_scripts(home_dir, bin_dir) + fixup_pth_and_egg_link(home_dir) + ## FIXME: need to fix up distutils.cfg + +OK_ABS_SCRIPTS = ['python', 'python%s' % sys.version[:3], + 'activate', 'activate.bat', 'activate_this.py', + 'activate.fish', 'activate.csh'] + +def fixup_scripts(home_dir, bin_dir): + if is_win: + new_shebang_args = ( + '%s /c' % os.path.normcase(os.environ.get('COMSPEC', 'cmd.exe')), + '', '.exe') + else: + new_shebang_args = ('/usr/bin/env', sys.version[:3], '') + + # This is what we expect at the top of scripts: + shebang = '#!%s' % os.path.normcase(os.path.join( + os.path.abspath(bin_dir), 'python%s' % new_shebang_args[2])) + # This is what we'll put: + new_shebang = '#!%s python%s%s' % new_shebang_args + + for filename in os.listdir(bin_dir): + filename = os.path.join(bin_dir, filename) + if not os.path.isfile(filename): + # ignore subdirs, e.g. .svn ones. + continue + f = open(filename, 'rb') + try: + try: + lines = f.read().decode('utf-8').splitlines() + except UnicodeDecodeError: + # This is probably a binary program instead + # of a script, so just ignore it. + continue + finally: + f.close() + if not lines: + logger.warn('Script %s is an empty file' % filename) + continue + + old_shebang = lines[0].strip() + old_shebang = old_shebang[0:2] + os.path.normcase(old_shebang[2:]) + + if not old_shebang.startswith(shebang): + if os.path.basename(filename) in OK_ABS_SCRIPTS: + logger.debug('Cannot make script %s relative' % filename) + elif lines[0].strip() == new_shebang: + logger.info('Script %s has already been made relative' % filename) + else: + logger.warn('Script %s cannot be made relative (it\'s not a normal script that starts with %s)' + % (filename, shebang)) + continue + logger.notify('Making script %s relative' % filename) + script = relative_script([new_shebang] + lines[1:]) + f = open(filename, 'wb') + f.write('\n'.join(script).encode('utf-8')) + f.close() + +def relative_script(lines): + "Return a script that'll work in a relocatable environment." + activate = "import os; activate_this=os.path.join(os.path.dirname(os.path.realpath(__file__)), 'activate_this.py'); exec(compile(open(activate_this).read(), activate_this, 'exec'), dict(__file__=activate_this)); del os, activate_this" + # Find the last future statement in the script. If we insert the activation + # line before a future statement, Python will raise a SyntaxError. + activate_at = None + for idx, line in reversed(list(enumerate(lines))): + if line.split()[:3] == ['from', '__future__', 'import']: + activate_at = idx + 1 + break + if activate_at is None: + # Activate after the shebang. + activate_at = 1 + return lines[:activate_at] + ['', activate, ''] + lines[activate_at:] + +def fixup_pth_and_egg_link(home_dir, sys_path=None): + """Makes .pth and .egg-link files use relative paths""" + home_dir = os.path.normcase(os.path.abspath(home_dir)) + if sys_path is None: + sys_path = sys.path + for path in sys_path: + if not path: + path = '.' + if not os.path.isdir(path): + continue + path = os.path.normcase(os.path.abspath(path)) + if not path.startswith(home_dir): + logger.debug('Skipping system (non-environment) directory %s' % path) + continue + for filename in os.listdir(path): + filename = os.path.join(path, filename) + if filename.endswith('.pth'): + if not os.access(filename, os.W_OK): + logger.warn('Cannot write .pth file %s, skipping' % filename) + else: + fixup_pth_file(filename) + if filename.endswith('.egg-link'): + if not os.access(filename, os.W_OK): + logger.warn('Cannot write .egg-link file %s, skipping' % filename) + else: + fixup_egg_link(filename) + +def fixup_pth_file(filename): + lines = [] + prev_lines = [] + f = open(filename) + prev_lines = f.readlines() + f.close() + for line in prev_lines: + line = line.strip() + if (not line or line.startswith('#') or line.startswith('import ') + or os.path.abspath(line) != line): + lines.append(line) + else: + new_value = make_relative_path(filename, line) + if line != new_value: + logger.debug('Rewriting path %s as %s (in %s)' % (line, new_value, filename)) + lines.append(new_value) + if lines == prev_lines: + logger.info('No changes to .pth file %s' % filename) + return + logger.notify('Making paths in .pth file %s relative' % filename) + f = open(filename, 'w') + f.write('\n'.join(lines) + '\n') + f.close() + +def fixup_egg_link(filename): + f = open(filename) + link = f.readline().strip() + f.close() + if os.path.abspath(link) != link: + logger.debug('Link in %s already relative' % filename) + return + new_link = make_relative_path(filename, link) + logger.notify('Rewriting link %s in %s as %s' % (link, filename, new_link)) + f = open(filename, 'w') + f.write(new_link) + f.close() + +def make_relative_path(source, dest, dest_is_directory=True): + """ + Make a filename relative, where the filename is dest, and it is + being referred to from the filename source. + + >>> make_relative_path('/usr/share/something/a-file.pth', + ... '/usr/share/another-place/src/Directory') + '../another-place/src/Directory' + >>> make_relative_path('/usr/share/something/a-file.pth', + ... '/home/user/src/Directory') + '../../../home/user/src/Directory' + >>> make_relative_path('/usr/share/a-file.pth', '/usr/share/') + './' + """ + source = os.path.dirname(source) + if not dest_is_directory: + dest_filename = os.path.basename(dest) + dest = os.path.dirname(dest) + dest = os.path.normpath(os.path.abspath(dest)) + source = os.path.normpath(os.path.abspath(source)) + dest_parts = dest.strip(os.path.sep).split(os.path.sep) + source_parts = source.strip(os.path.sep).split(os.path.sep) + while dest_parts and source_parts and dest_parts[0] == source_parts[0]: + dest_parts.pop(0) + source_parts.pop(0) + full_parts = ['..']*len(source_parts) + dest_parts + if not dest_is_directory: + full_parts.append(dest_filename) + if not full_parts: + # Special case for the current directory (otherwise it'd be '') + return './' + return os.path.sep.join(full_parts) + + + +############################################################ +## Bootstrap script creation: + +def create_bootstrap_script(extra_text, python_version=''): + """ + Creates a bootstrap script, which is like this script but with + extend_parser, adjust_options, and after_install hooks. + + This returns a string that (written to disk of course) can be used + as a bootstrap script with your own customizations. The script + will be the standard virtualenv.py script, with your extra text + added (your extra text should be Python code). + + If you include these functions, they will be called: + + ``extend_parser(optparse_parser)``: + You can add or remove options from the parser here. + + ``adjust_options(options, args)``: + You can change options here, or change the args (if you accept + different kinds of arguments, be sure you modify ``args`` so it is + only ``[DEST_DIR]``). + + ``after_install(options, home_dir)``: + + After everything is installed, this function is called. This + is probably the function you are most likely to use. An + example would be:: + + def after_install(options, home_dir): + subprocess.call([join(home_dir, 'bin', 'easy_install'), + 'MyPackage']) + subprocess.call([join(home_dir, 'bin', 'my-package-script'), + 'setup', home_dir]) + + This example immediately installs a package, and runs a setup + script from that package. + + If you provide something like ``python_version='2.5'`` then the + script will start with ``#!/usr/bin/env python2.5`` instead of + ``#!/usr/bin/env python``. You can use this when the script must + be run with a particular Python version. + """ + filename = __file__ + if filename.endswith('.pyc'): + filename = filename[:-1] + f = codecs.open(filename, 'r', encoding='utf-8') + content = f.read() + f.close() + py_exe = 'python%s' % python_version + content = (('#!/usr/bin/env %s\n' % py_exe) + + '## WARNING: This file is generated\n' + + content) + return content.replace('##EXT' 'END##', extra_text) + +##EXTEND## + +def convert(s): + b = base64.b64decode(s.encode('ascii')) + return zlib.decompress(b).decode('utf-8') + +##file site.py +SITE_PY = convert(""" +eJzFPf1z2zaWv/OvwMqToZTKdOJ0e3tO3RsncVrfuYm3yc7m1vXoKAmyWFMkS5C2tTd3f/u9DwAE ++CHb2+6cphNLJPDw8PC+8PAeOhqNTopCZkuxyZd1KoWScblYiyKu1kqs8lJU66Rc7hdxWW3h6eIm +vpZKVLlQWxVhqygInv/GT/BcfF4nyqAA3+K6yjdxlSziNN2KZFPkZSWXYlmXSXYtkiypkjhN/g4t +8iwSz387BsFZJmDmaSJLcStLBXCVyFfiYlut80yM6wLn/DL6Y/xqMhVqUSZFBQ1KjTNQ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UlIXHJS1b9egQW5bvM7X3vfRvN9ymE2n6Bm+w7bkhlmuYNITO+04OQg+E/nq1vgVt +KzL39VCHTt1PtxMgvnvaLahDKrsXcscv0zUmbvpMK0870E85qdb8cjITzCNzUsfi0JzEmffN4YmW +0U5seWjhnPTWrjrR/qq+BXQg7j2xSda0Anhmgvxlj0xMxYwNzLOD0v7ffFBmOFYbmht0QAoX0rnJ +kS5xZFCV//8TKUHZxbi3Y0dxau/mpnZ8PKTspfN49ruQkSGIV+436s7PFfalTAeoEASs8PQ9hYyI +0X/6QNWmHzxT4nKfCov3Udlc2V+4Ztq5/WuCSQaVve9LcYISH7NC41WduokDtk+nAzl9dBqVr5xK +FtB8B0DnRjwVsDf6S6wQ51sRwsZRu2SYHEt01Jf1Ocij3XSwN7R6IfaHyk7dskshXg43XLYqO3WP +Q+6hHuihalPc51hgzNIcqicV3xFkPs4UdMGX53zgGbre9sPX28uXR/ZwAfkdXzuKhLLJRo5hv3Sy +MXdeKul0J2Ypp5Suh3s1JySsW1w5UNknGNrbdEpSBvY/Js+BIY289/0hM9PDu3p/1MbUst4RTEmM +n6kJTcsp4tG42yeT7nQbtdUFwgVJjwDSUYEAC8F0dKOTILrlLO/xC70bnNd0Ha97whQ6UkHJYj5H +cA/j+zX4tbtTIfGjujOKpj83aHOgXnIQbvYduNXEC4UMm4T21Bs+GHABuCa7v//LR/TvpjHa7oe7 +/Grb6lVvHSD7spj5iplBLRKZxxEYGdCbY9LWWC5hBB2voWno6DJUMzfkC3T8KJsWL9umDQY5szPt +AVijEPwfucjncQ== +""") + +##file activate.sh +ACTIVATE_SH = convert(""" +eJytVVFvokAQfudXTLEPtTlLeo9tvMSmJpq02hSvl7u2wRUG2QR2DSxSe7n/frOACEVNLlceRHa+ +nfl25pvZDswCnoDPQ4QoTRQsENIEPci4CsBMZBq7CAsuLOYqvmYKTTj3YxnBgiXBudGBjUzBZUJI +BXEqgCvweIyuCjeG4eF2F5x14bcB9KQiQQWrjSddI1/oQIx6SYY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RV1ack8cOdhysI0CYzIPzjSiH5X +0QcvC8Lfaj0emsVKYF2rhL5L3fCkVjV76kShi59NHwDniAHzkgDgqBcwOgTMx+gDQQqXCw== +""") + +##file deactivate.bat +DEACTIVATE_BAT = convert(""" +eJxzSE3OyFfIT0vj4ipOLVEI8wwKCXX0iXf1C7Pl4spMU0hJTcvMS01RiPf3cYmHyQYE+fsGhCho +cCkAAUibEkTEVhWLMlUlLk6QGixStlyaeCyJDPHw9/Pw93VFsQguim4ZXAJoIUw5DhX47XUM8UCx +EchHtwsohN1bILUgw61c/Vy4AJYPYm4= +""") + +##file activate.ps1 +ACTIVATE_PS = convert(""" +eJylWdmO41hyfW+g/0FTU7C7IXeJIqmtB/3AnZRIStxF2kaBm7gv4ipyMF/mB3+Sf8GXVGVl1tLT +43ECSqR4b5wbETeWE8z/+a///vNCDaN6cYtSf5G1dbNw/IVXNIu6aCvX9xa3qsgWl0IJ/7IYinbh +2nkOVqs2X0TNjz/8eeFFle826fBhQRaLBkD9uviw+LCy3Sbq7Mb/UNbrH3+YNtLcVaB+Xbipb+eL +tly0eVsD/M6u6g8//vC+dquobH5VWU75eMFUdvHb4n02RHlXuHYTFfmHbHCLLLNz70NpN+GrBI4p +1EeSk4FAXaZR88u0vPip8usi7fznt3fvP+OuPnx49/Pil4td+XnzigIAPoqYQH2J8v4z+C+8b98m +Q25t7k76LIK0cOz0V89/MXXx0+Lf6z5q3PA/F+/FIif9uqnaadFf/PzXSXYBfqIb2NeApecJwPzI +dlL/149nnvyoc7KqYfzTAT8v/voUmX7e+3n364tffl/oVaDyswKY/7J18e6bve8Wv9RuUfqfLHmK +/u139Hwx+9ePRep97KKqae30YwmCo2y+0vTz1k+rv7159B3pb1SOGj97Pe8/flfkC1Vn/7xYR4n6 +lypNEGDDV5f7lcjil3S+4++p881Wv6qKyn5GQg1yJwcp4BZ5E+Wt/z1P/umbiHir4J8Xip/eFt6n +9T/9gU9eY+7zUX97Jlmb136ziKrKT/3OzpvP8VX/+MObS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Kx3vgP+XnkX0QW9pLy/NsXgdN24dD3LxO2Nwil7Zlc1dqtP3d7/h +kzp1/+7hGBuY4pk0XD/0Ao/oTe/XGrfyM773aB7iUhgkpy+dwAMalxMP0DrBcsVw/6p25+/hobP9 +GBknrWExDhLJ1bwt1NcCNblaFbMKCyvmX0PeRaQ= +""") + +##file distutils.cfg +DISTUTILS_CFG = convert(""" +eJxNj00KwkAMhfc9xYNuxe4Ft57AjYiUtDO1wXSmNJnK3N5pdSEEAu8nH6lxHVlRhtDHMPATA4uH +xJ4EFmGbvfJiicSHFRzUSISMY6hq3GLCRLnIvSTnEefN0FIjw5tF0Hkk9Q5dRunBsVoyFi24aaLg +9FDOlL0FPGluf4QjcInLlxd6f6rqkgPu/5nHLg0cXCscXoozRrP51DRT3j9QNl99AP53T2Q= +""") + +##file activate_this.py +ACTIVATE_THIS = convert(""" +eJyNU01v2zAMvetXEB4K21jnDOstQA4dMGCHbeihlyEIDMWmE62yJEiKE//7kXKdpEWLzYBt8evx +kRSzLPs6wiEoswM8YdMpjUXcq1Dz6RZa1cSiTkJdr86GsoTRHuCotBayiWqQEYGtMCgfD1KjGYBe +5a3p0cRKiEe2NtLAFikftnDco0ko/SFEVgEZ8aRCZDIPY9xbA8pE9M4jfW/B2CjiHq9zbJVZuOQq +siwTIvpxKYCembPAU4Muwi/Z4zfvrZ/MXipKeB8C+qisSZYiWfjJfs+0/MFMdWn1hJcO5U7G/SLa +xVx8zU6VG/PXLXvfsyyzUqjeWR8hjGE+2iCE1W1tQ82hsCJN9dzKaoexyB/uH79TnjwvxcW0ntSb +yZ8jq1Z5Q1UXsyy3gf9nbjTEj7NzQMfCJa/YSmrQ+2D/BqfiOi6sclrGzvoeVivIj8rcfcmnIQRF +7XCyeZI7DFe5/lhlCs5PRf5QW66VXT/NrlQ46oD/D6InkOmi3IQcbhKxAX2g4a+Xd5s3UtCtG2py +m8eg6WYWqR6SL5OjKMGfSrYt/6kxxQtOpeAgj1LXBNmpE2ElmCSIy5H0zFd8gJ924HWijWhb2hRC +6wNEm1QdDZtuSZcEprIUBo/XRNcbQe1OUbQ/r3hPTaPJJDNtFLu8KHV5XoNr3Eo6h6YtOKw8e8yw +VF5PnJ+ts3a9/Mz38RpG/AUSzYUW +""") + +MH_MAGIC = 0xfeedface +MH_CIGAM = 0xcefaedfe +MH_MAGIC_64 = 0xfeedfacf +MH_CIGAM_64 = 0xcffaedfe +FAT_MAGIC = 0xcafebabe +BIG_ENDIAN = '>' +LITTLE_ENDIAN = '<' +LC_LOAD_DYLIB = 0xc +maxint = majver == 3 and getattr(sys, 'maxsize') or getattr(sys, 'maxint') + + +class fileview(object): + """ + A proxy for file-like objects that exposes a given view of a file. + Modified from macholib. + """ + + def __init__(self, fileobj, start=0, size=maxint): + if isinstance(fileobj, fileview): + self._fileobj = fileobj._fileobj + else: + self._fileobj = fileobj + self._start = start + self._end = start + size + self._pos = 0 + + def __repr__(self): + return '' % ( + self._start, self._end, self._fileobj) + + def tell(self): + return self._pos + + def _checkwindow(self, seekto, op): + if not (self._start <= seekto <= self._end): + raise IOError("%s to offset %d is outside window [%d, %d]" % ( + op, seekto, self._start, self._end)) + + def seek(self, offset, whence=0): + seekto = offset + if whence == os.SEEK_SET: + seekto += self._start + elif whence == os.SEEK_CUR: + seekto += self._start + self._pos + elif whence == os.SEEK_END: + seekto += self._end + else: + raise IOError("Invalid whence argument to seek: %r" % (whence,)) + self._checkwindow(seekto, 'seek') + self._fileobj.seek(seekto) + self._pos = seekto - self._start + + def write(self, bytes): + here = self._start + self._pos + self._checkwindow(here, 'write') + self._checkwindow(here + len(bytes), 'write') + self._fileobj.seek(here, os.SEEK_SET) + self._fileobj.write(bytes) + self._pos += len(bytes) + + def read(self, size=maxint): + assert size >= 0 + here = self._start + self._pos + self._checkwindow(here, 'read') + size = min(size, self._end - here) + self._fileobj.seek(here, os.SEEK_SET) + bytes = self._fileobj.read(size) + self._pos += len(bytes) + return bytes + + +def read_data(file, endian, num=1): + """ + Read a given number of 32-bits unsigned integers from the given file + with the given endianness. + """ + res = struct.unpack(endian + 'L' * num, file.read(num * 4)) + if len(res) == 1: + return res[0] + return res + + +def mach_o_change(path, what, value): + """ + Replace a given name (what) in any LC_LOAD_DYLIB command found in + the given binary with a new name (value), provided it's shorter. + """ + + def do_macho(file, bits, endian): + # Read Mach-O header (the magic number is assumed read by the caller) + cputype, cpusubtype, filetype, ncmds, sizeofcmds, flags = read_data(file, endian, 6) + # 64-bits header has one more field. + if bits == 64: + read_data(file, endian) + # The header is followed by ncmds commands + for n in range(ncmds): + where = file.tell() + # Read command header + cmd, cmdsize = read_data(file, endian, 2) + if cmd == LC_LOAD_DYLIB: + # The first data field in LC_LOAD_DYLIB commands is the + # offset of the name, starting from the beginning of the + # command. + name_offset = read_data(file, endian) + file.seek(where + name_offset, os.SEEK_SET) + # Read the NUL terminated string + load = file.read(cmdsize - name_offset).decode() + load = load[:load.index('\0')] + # If the string is what is being replaced, overwrite it. + if load == what: + file.seek(where + name_offset, os.SEEK_SET) + file.write(value.encode() + '\0'.encode()) + # Seek to the next command + file.seek(where + cmdsize, os.SEEK_SET) + + def do_file(file, offset=0, size=maxint): + file = fileview(file, offset, size) + # Read magic number + magic = read_data(file, BIG_ENDIAN) + if magic == FAT_MAGIC: + # Fat binaries contain nfat_arch Mach-O binaries + nfat_arch = read_data(file, BIG_ENDIAN) + for n in range(nfat_arch): + # Read arch header + cputype, cpusubtype, offset, size, align = read_data(file, BIG_ENDIAN, 5) + do_file(file, offset, size) + elif magic == MH_MAGIC: + do_macho(file, 32, BIG_ENDIAN) + elif magic == MH_CIGAM: + do_macho(file, 32, LITTLE_ENDIAN) + elif magic == MH_MAGIC_64: + do_macho(file, 64, BIG_ENDIAN) + elif magic == MH_CIGAM_64: + do_macho(file, 64, LITTLE_ENDIAN) + + assert(len(what) >= len(value)) + do_file(open(path, 'r+b')) + + +if __name__ == '__main__': + main() + +## TODO: +## Copy python.exe.manifest +## Monkeypatch distutils.sysconfig diff -r a2f733f900c0 -r fc0f3e398166 server/virtualenv/web/virtualenv_support/__init__.py diff -r a2f733f900c0 -r fc0f3e398166 server/virtualenv/web/virtualenv_support/argparse-1.3.0-py2.py3-none-any.whl Binary file server/virtualenv/web/virtualenv_support/argparse-1.3.0-py2.py3-none-any.whl has changed diff -r a2f733f900c0 -r fc0f3e398166 server/virtualenv/web/virtualenv_support/pip-7.0.1-py2.py3-none-any.whl Binary file server/virtualenv/web/virtualenv_support/pip-7.0.1-py2.py3-none-any.whl has changed diff -r a2f733f900c0 -r fc0f3e398166 server/virtualenv/web/virtualenv_support/setuptools-16.0-py2.py3-none-any.whl Binary file server/virtualenv/web/virtualenv_support/setuptools-16.0-py2.py3-none-any.whl has changed diff -r a2f733f900c0 -r fc0f3e398166 server/virtualenv/web/virtualenv_support/wheel-0.24.0-py2.py3-none-any.whl Binary file server/virtualenv/web/virtualenv_support/wheel-0.24.0-py2.py3-none-any.whl has changed diff -r a2f733f900c0 -r fc0f3e398166 server/web/static/media/thumbnails/users/user_default_icon.png Binary file server/web/static/media/thumbnails/users/user_default_icon.png has changed