Browse Source

allow a two step patch process compatible with Travis CI

Damien ACCORSI 9 years ago
parent
commit
24f8bc1f0b
3 changed files with 55 additions and 45 deletions
  1. 2 1
      .travis.yml
  2. 5 3
      README.md
  3. 48 41
      bin/tg2env-patch

+ 2 - 1
.travis.yml View File

@@ -16,8 +16,9 @@ addons:
16 16
 install:
17 17
   - "cd tracim && python setup.py develop; cd -"
18 18
   - "pip install -r install/requirements.txt; echo"
19
+  - "./bin/tg2env-patch 1 /home/travis/virtualenv/python3.2.5/lib/python3.2/site-packages"
19 20
   - "pip install -r install/requirements.txt; echo"
20
-  - "./bin/tg2env-patch /home/travis/virtualenv/python3.2.5"
21
+  - "./bin/tg2env-patch 2 /home/travis/virtualenv/python3.2.5/lib/python3.2/site-packages"
21 22
   
22 23
 before_script:
23 24
   - "psql -c 'create database tracim_test;' -U postgres"

+ 5 - 3
README.md View File

@@ -142,14 +142,16 @@ conflict between system-wide python installation and Tracim required ones.
142 142
     source tg2env/bin/activate
143 143
     cd tracim && python setup.py develop && cd -
144 144
     pip install -r install/requirements.txt
145
-    ./bin/tg2env-patch tg2env/
145
+    ./bin/tg2env-patch 1 tg2env/lib/python3.2/site-packages
146
+    pip install -r install/requirements.txt
147
+    ./bin/tg2env-patch 2 tg2env/lib/python3.2/site-packages
146 148
     
147 149
 Notes:
148 150
 
151
+* Patchs are applied in a two-step process because some dependencies require to be patched before other packages installation
149 152
 * Debian: you may get errors with stevedore/pbr which is not supported by python 3.2
150 153
 (debian version of python 3). This is not a real problem
151
-* Ubuntu (at least 14.04): you should remove _distribute_ and _wsgiref _
152
-  from the requirements.txt file
154
+* Ubuntu (at least 14.04): please update the site-package path with your version of python
153 155
 
154 156
 ## Database Setup ##
155 157
 

+ 48 - 41
bin/tg2env-patch View File

@@ -7,7 +7,7 @@ import sys
7 7
 
8 8
 def usage():
9 9
     print('')
10
-    print('USAGE: '+__file__+' <virtualenv_folder_path>')
10
+    print('USAGE: '+__file__+' <step_1_or2> <site_packages_folder_path> ')
11 11
     print('')
12 12
     print('')
13 13
 
@@ -30,7 +30,7 @@ def on_result_and_exit(error_code):
30 30
 #######
31 31
 
32 32
 
33
-if len(sys.argv)<=1:
33
+if len(sys.argv)<=2:
34 34
     show_help_and_exit()
35 35
 
36 36
 ########################################
@@ -39,53 +39,60 @@ if len(sys.argv)<=1:
39 39
 #
40 40
 ########################################
41 41
 
42
-tg2env_path = sys.argv[1]
42
+patch_step = sys.argv[1]
43
+sitepackages_path = sys.argv[2]
43 44
 
44 45
 print('PATCHING PYTHON CODE')
45 46
 print('--------------------')
46
-print('tg2env path:    %s'%(tg2env_path))
47
+print('site packages path:    %s'%(sitepackages_path))
47 48
 print('')
48 49
 
49
-patchable_paths = [
50
-    tg2env_path+'/lib/python3*/site-packages/tgext/pluggable',
51
-    tg2env_path+'/lib/python3*/site-packages/resetpassword',
52
-    tg2env_path+'/lib/python3*/site-packages/babel'
53
-]
50
+if patch_step=='1':
51
+
52
+    patchable_paths = [
53
+        sitepackages_path+'/tgext/pluggable',
54
+        sitepackages_path+'/resetpassword',
55
+        sitepackages_path+'/babel'
56
+    ]
57
+
58
+    for patchable_path in patchable_paths:
59
+        print('2to3 conversion for %s...' % (patchable_path))
60
+        os.system('2to3 -w %s'%(patchable_path))
61
+        print('-> done')
62
+
63
+    babel_source_code_patch_content = """--- tg2env/lib/python3.2/site-packages/babel/messages/pofile.py 2014-11-07 15:35:14.039913184 +0100
64
+    +++ tg2env/lib/python3.2/site-packages/babel/messages/pofile.py 2014-10-30 17:37:36.295091573 +0100
65
+    @@ -384,8 +384,13 @@
66
+     
67
+         def _write(text):
68
+             if isinstance(text, text_type):
69
+    -            text = text.encode(catalog.charset, 'backslashreplace')
70
+    -        fileobj.write(text)
71
+    +            pass
72
+    +            # text = text.encode(catalog.charset, 'backslashreplace')
73
+    +        try:
74
+    +            fileobj.write(text.encode('UTF-8'))
75
+    +        except Exception as e:
76
+    +            fileobj.write(text)
77
+    +        
78
+     
79
+         def _write_comment(comment, prefix=''):
80
+             # xgettext always wraps comments even if --no-wrap is passed;
81
+    """
82
+
83
+    babel_patchable_file_path = sitepackages_path+'/babel/messages/pofile.py'
84
+    print('Patching code in file %s...'%(babel_patchable_file_path))
85
+    os.system('echo "%s"|patch -p1 %s'%(babel_source_code_patch_content, babel_patchable_file_path))
86
+    print('-> done')
54 87
 
55
-for patchable_path in patchable_paths:
56
-    print('2to3 conversion for %s...' % (patchable_path))
57
-    os.system('2to3 -w %s'%(patchable_path))
88
+elif patch_step=='2':
89
+    resetpassword_patchable_file_path = sitepackages_path+'/resetpassword/lib/__init__.py'
90
+    print('Patching code in file %s...'%(resetpassword_patchable_file_path))
91
+    os.system("sed -i 's/body\.encode/body/g' %s" % (resetpassword_patchable_file_path))
58 92
     print('-> done')
59 93
 
60
-babel_source_code_patch_content = """--- tg2env/lib/python3.2/site-packages/babel/messages/pofile.py 2014-11-07 15:35:14.039913184 +0100
61
-+++ tg2env/lib/python3.2/site-packages/babel/messages/pofile.py 2014-10-30 17:37:36.295091573 +0100
62
-@@ -384,8 +384,13 @@
63
- 
64
-     def _write(text):
65
-         if isinstance(text, text_type):
66
--            text = text.encode(catalog.charset, 'backslashreplace')
67
--        fileobj.write(text)
68
-+            pass
69
-+            # text = text.encode(catalog.charset, 'backslashreplace')
70
-+        try:
71
-+            fileobj.write(text.encode('UTF-8'))
72
-+        except Exception as e:
73
-+            fileobj.write(text)
74
-+        
75
- 
76
-     def _write_comment(comment, prefix=''):
77
-         # xgettext always wraps comments even if --no-wrap is passed;
78
-"""
79
-
80
-babel_patchable_file_path = tg2env_path+'/lib/python*/site-packages/babel/messages/pofile.py'
81
-print('Patching code in file %s...'%(babel_patchable_file_path))
82
-os.system('echo "%s"|patch -p1 %s'%(babel_source_code_patch_content, babel_patchable_file_path))
83
-print('-> done')
84
-
85
-resetpassword_patchable_file_path = tg2env_path+'/lib/python*/site-packages/resetpassword/lib/__init__.py'
86
-print('Patching code in file %s...'%(resetpassword_patchable_file_path))
87
-os.system("sed -i 's/body\.encode/body/g' %s" % (resetpassword_patchable_file_path))
88
-print('-> done')
94
+else:
95
+    show_help_and_exit()
89 96
 
90 97
 print('')
91 98
 print('')