annotate setup.py @ 2237:fd4111075e00

jp: fixed progress
author Goffi <goffi@goffi.org>
date Thu, 04 May 2017 00:36:03 +0200
parents e0f91efa404a
children e572482f6cbd
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
884
4054cf716322 setup.py fixes and improvments
Goffi <goffi@goffi.org>
parents: 881
diff changeset
1 #!/usr/bin/env python2
225
fd9b7834d98a distutils installation script, draft
Goffi <goffi@goffi.org>
parents:
diff changeset
2 # -*- coding: utf-8 -*-
fd9b7834d98a distutils installation script, draft
Goffi <goffi@goffi.org>
parents:
diff changeset
3
609
84a6e83157c2 fixed licences in docstrings (they are now in comments)
Goffi <goffi@goffi.org>
parents: 607
diff changeset
4 # SAT: a jabber client
1766
d17772b0fe22 copyright update
Goffi <goffi@goffi.org>
parents: 1720
diff changeset
5 # Copyright (C) 2009-2016 Jérôme Poisson (goffi@goffi.org)
d17772b0fe22 copyright update
Goffi <goffi@goffi.org>
parents: 1720
diff changeset
6 # Copyright (C) 2013-2016 Adrien Cossa (souliane@mailoo.org)
238
83d2bc0abf2a version, README, CHANGELOG and INSTALL updates
Goffi <goffi@goffi.org>
parents: 237
diff changeset
7
609
84a6e83157c2 fixed licences in docstrings (they are now in comments)
Goffi <goffi@goffi.org>
parents: 607
diff changeset
8 # This program is free software: you can redistribute it and/or modify
84a6e83157c2 fixed licences in docstrings (they are now in comments)
Goffi <goffi@goffi.org>
parents: 607
diff changeset
9 # it under the terms of the GNU Affero General Public License as published by
84a6e83157c2 fixed licences in docstrings (they are now in comments)
Goffi <goffi@goffi.org>
parents: 607
diff changeset
10 # the Free Software Foundation, either version 3 of the License, or
84a6e83157c2 fixed licences in docstrings (they are now in comments)
Goffi <goffi@goffi.org>
parents: 607
diff changeset
11 # (at your option) any later version.
238
83d2bc0abf2a version, README, CHANGELOG and INSTALL updates
Goffi <goffi@goffi.org>
parents: 237
diff changeset
12
609
84a6e83157c2 fixed licences in docstrings (they are now in comments)
Goffi <goffi@goffi.org>
parents: 607
diff changeset
13 # This program is distributed in the hope that it will be useful,
84a6e83157c2 fixed licences in docstrings (they are now in comments)
Goffi <goffi@goffi.org>
parents: 607
diff changeset
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
84a6e83157c2 fixed licences in docstrings (they are now in comments)
Goffi <goffi@goffi.org>
parents: 607
diff changeset
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
84a6e83157c2 fixed licences in docstrings (they are now in comments)
Goffi <goffi@goffi.org>
parents: 607
diff changeset
16 # GNU Affero General Public License for more details.
238
83d2bc0abf2a version, README, CHANGELOG and INSTALL updates
Goffi <goffi@goffi.org>
parents: 237
diff changeset
17
609
84a6e83157c2 fixed licences in docstrings (they are now in comments)
Goffi <goffi@goffi.org>
parents: 607
diff changeset
18 # You should have received a copy of the GNU Affero General Public License
84a6e83157c2 fixed licences in docstrings (they are now in comments)
Goffi <goffi@goffi.org>
parents: 607
diff changeset
19 # along with this program. If not, see <http://www.gnu.org/licenses/>.
238
83d2bc0abf2a version, README, CHANGELOG and INSTALL updates
Goffi <goffi@goffi.org>
parents: 237
diff changeset
20
1155
a1d47760df3f misc (install): updated old distribute_setup.py to new setuptools' ez_setup.py
Goffi <goffi@goffi.org>
parents: 1154
diff changeset
21 from ez_setup import use_setuptools
230
b25cbec73c1e distutils: removes build and dist from manifest's prune
Goffi <goffi@goffi.org>
parents: 227
diff changeset
22 use_setuptools()
b25cbec73c1e distutils: removes build and dist from manifest's prune
Goffi <goffi@goffi.org>
parents: 227
diff changeset
23 from setuptools.command.install import install
b25cbec73c1e distutils: removes build and dist from manifest's prune
Goffi <goffi@goffi.org>
parents: 227
diff changeset
24 from setuptools import setup
225
fd9b7834d98a distutils installation script, draft
Goffi <goffi@goffi.org>
parents:
diff changeset
25 from distutils.file_util import copy_file
586
6a718ede8be1 Fix coding style in setup.py.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 581
diff changeset
26 import os
1153
25a16df15ae2 misc (installation): --root option is ignored for _final destinations
Goffi <goffi@goffi.org>
parents: 1150
diff changeset
27 import os.path
586
6a718ede8be1 Fix coding style in setup.py.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 581
diff changeset
28 import sys
6a718ede8be1 Fix coding style in setup.py.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 581
diff changeset
29 import subprocess
225
fd9b7834d98a distutils installation script, draft
Goffi <goffi@goffi.org>
parents:
diff changeset
30 from stat import ST_MODE
1100
2be46f391cfa setup: SAT_INSTALL environment variable handles "clean" and "purge" options
souliane <souliane@mailoo.org>
parents: 1054
diff changeset
31 import shutil
1150
beaf8d4475e4 misc (D-Bus, installation): added a .service file for D-Bus auto-launch feature + installation from setup.py (path adaptation now use regex).
Goffi <goffi@goffi.org>
parents: 1138
diff changeset
32 import re
1100
2be46f391cfa setup: SAT_INSTALL environment variable handles "clean" and "purge" options
souliane <souliane@mailoo.org>
parents: 1054
diff changeset
33
1123
e89bd3a26c86 installation: setup.py update:
Goffi <goffi@goffi.org>
parents: 1115
diff changeset
34 # seen here: http://stackoverflow.com/questions/7275295
e89bd3a26c86 installation: setup.py update:
Goffi <goffi@goffi.org>
parents: 1115
diff changeset
35 try:
e89bd3a26c86 installation: setup.py update:
Goffi <goffi@goffi.org>
parents: 1115
diff changeset
36 from setuptools.command import egg_info
e89bd3a26c86 installation: setup.py update:
Goffi <goffi@goffi.org>
parents: 1115
diff changeset
37 egg_info.write_toplevel_names
e89bd3a26c86 installation: setup.py update:
Goffi <goffi@goffi.org>
parents: 1115
diff changeset
38 except (ImportError, AttributeError):
e89bd3a26c86 installation: setup.py update:
Goffi <goffi@goffi.org>
parents: 1115
diff changeset
39 pass
e89bd3a26c86 installation: setup.py update:
Goffi <goffi@goffi.org>
parents: 1115
diff changeset
40 else:
e89bd3a26c86 installation: setup.py update:
Goffi <goffi@goffi.org>
parents: 1115
diff changeset
41 def _top_level_package(name):
e89bd3a26c86 installation: setup.py update:
Goffi <goffi@goffi.org>
parents: 1115
diff changeset
42 return name.split('.', 1)[0]
e89bd3a26c86 installation: setup.py update:
Goffi <goffi@goffi.org>
parents: 1115
diff changeset
43
e89bd3a26c86 installation: setup.py update:
Goffi <goffi@goffi.org>
parents: 1115
diff changeset
44 def _hacked_write_toplevel_names(cmd, basename, filename):
e89bd3a26c86 installation: setup.py update:
Goffi <goffi@goffi.org>
parents: 1115
diff changeset
45 pkgs = dict.fromkeys(
e89bd3a26c86 installation: setup.py update:
Goffi <goffi@goffi.org>
parents: 1115
diff changeset
46 [_top_level_package(k)
e89bd3a26c86 installation: setup.py update:
Goffi <goffi@goffi.org>
parents: 1115
diff changeset
47 for k in cmd.distribution.iter_distribution_names()
e89bd3a26c86 installation: setup.py update:
Goffi <goffi@goffi.org>
parents: 1115
diff changeset
48 if _top_level_package(k) != "twisted"
e89bd3a26c86 installation: setup.py update:
Goffi <goffi@goffi.org>
parents: 1115
diff changeset
49 ]
e89bd3a26c86 installation: setup.py update:
Goffi <goffi@goffi.org>
parents: 1115
diff changeset
50 )
e89bd3a26c86 installation: setup.py update:
Goffi <goffi@goffi.org>
parents: 1115
diff changeset
51 cmd.write_file("top-level names", filename, '\n'.join(pkgs) + '\n')
e89bd3a26c86 installation: setup.py update:
Goffi <goffi@goffi.org>
parents: 1115
diff changeset
52
e89bd3a26c86 installation: setup.py update:
Goffi <goffi@goffi.org>
parents: 1115
diff changeset
53 egg_info.write_toplevel_names = _hacked_write_toplevel_names
e89bd3a26c86 installation: setup.py update:
Goffi <goffi@goffi.org>
parents: 1115
diff changeset
54
225
fd9b7834d98a distutils installation script, draft
Goffi <goffi@goffi.org>
parents:
diff changeset
55
fd9b7834d98a distutils installation script, draft
Goffi <goffi@goffi.org>
parents:
diff changeset
56 NAME = 'sat'
fd9b7834d98a distutils installation script, draft
Goffi <goffi@goffi.org>
parents:
diff changeset
57 LAUNCH_DAEMON_COMMAND = 'sat'
fd9b7834d98a distutils installation script, draft
Goffi <goffi@goffi.org>
parents:
diff changeset
58
1100
2be46f391cfa setup: SAT_INSTALL environment variable handles "clean" and "purge" options
souliane <souliane@mailoo.org>
parents: 1054
diff changeset
59 ENV_SAT_INSTALL = "SAT_INSTALL" # environment variable to customise installation
2be46f391cfa setup: SAT_INSTALL environment variable handles "clean" and "purge" options
souliane <souliane@mailoo.org>
parents: 1054
diff changeset
60 NO_PREINSTALL_OPT = 'nopreinstall' # skip all preinstallation checks
2be46f391cfa setup: SAT_INSTALL environment variable handles "clean" and "purge" options
souliane <souliane@mailoo.org>
parents: 1054
diff changeset
61 AUTO_DEB_OPT = 'autodeb' # automaticaly install debs
2be46f391cfa setup: SAT_INSTALL environment variable handles "clean" and "purge" options
souliane <souliane@mailoo.org>
parents: 1054
diff changeset
62 CLEAN_OPT = 'clean' # remove previous installation directories
2be46f391cfa setup: SAT_INSTALL environment variable handles "clean" and "purge" options
souliane <souliane@mailoo.org>
parents: 1054
diff changeset
63 PURGE_OPT = 'purge' # remove building and previous installation directories
1150
beaf8d4475e4 misc (D-Bus, installation): added a .service file for D-Bus auto-launch feature + installation from setup.py (path adaptation now use regex).
Goffi <goffi@goffi.org>
parents: 1138
diff changeset
64 DBUS_DIR = 'dbus-1/services'
beaf8d4475e4 misc (D-Bus, installation): added a .service file for D-Bus auto-launch feature + installation from setup.py (path adaptation now use regex).
Goffi <goffi@goffi.org>
parents: 1138
diff changeset
65 DBUS_FILE = 'misc/org.goffi.SAT.service'
beaf8d4475e4 misc (D-Bus, installation): added a .service file for D-Bus auto-launch feature + installation from setup.py (path adaptation now use regex).
Goffi <goffi@goffi.org>
parents: 1138
diff changeset
66
beaf8d4475e4 misc (D-Bus, installation): added a .service file for D-Bus auto-launch feature + installation from setup.py (path adaptation now use regex).
Goffi <goffi@goffi.org>
parents: 1138
diff changeset
67 # Following map describe file to adapt with installation path:
beaf8d4475e4 misc (D-Bus, installation): added a .service file for D-Bus auto-launch feature + installation from setup.py (path adaptation now use regex).
Goffi <goffi@goffi.org>
parents: 1138
diff changeset
68 # key is the self attribute to get (e.g.: sh_script_path will modify self.sh_script_path file)
beaf8d4475e4 misc (D-Bus, installation): added a .service file for D-Bus auto-launch feature + installation from setup.py (path adaptation now use regex).
Goffi <goffi@goffi.org>
parents: 1138
diff changeset
69 # value is a dict where key is the regex of the part to change, and value is either the string
beaf8d4475e4 misc (D-Bus, installation): added a .service file for D-Bus auto-launch feature + installation from setup.py (path adaptation now use regex).
Goffi <goffi@goffi.org>
parents: 1138
diff changeset
70 # to replace or a tuple with a template and values to replace (if value to replace is a string,
beaf8d4475e4 misc (D-Bus, installation): added a .service file for D-Bus auto-launch feature + installation from setup.py (path adaptation now use regex).
Goffi <goffi@goffi.org>
parents: 1138
diff changeset
71 # the attribute from self with that name will be used).
beaf8d4475e4 misc (D-Bus, installation): added a .service file for D-Bus auto-launch feature + installation from setup.py (path adaptation now use regex).
Goffi <goffi@goffi.org>
parents: 1138
diff changeset
72 FILE_ADJ = {'sh_script_path': {r'PYTHON *=.*': 'PYTHON="{}"'.format(sys.executable)},
1153
25a16df15ae2 misc (installation): --root option is ignored for _final destinations
Goffi <goffi@goffi.org>
parents: 1150
diff changeset
73 'dbus_service_path': {r'Exec *=.*': ('Exec={}', 'sh_script_path_final')},
1150
beaf8d4475e4 misc (D-Bus, installation): added a .service file for D-Bus auto-launch feature + installation from setup.py (path adaptation now use regex).
Goffi <goffi@goffi.org>
parents: 1138
diff changeset
74 }
1100
2be46f391cfa setup: SAT_INSTALL environment variable handles "clean" and "purge" options
souliane <souliane@mailoo.org>
parents: 1054
diff changeset
75
586
6a718ede8be1 Fix coding style in setup.py.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 581
diff changeset
76
232
0cd5b3c4513f Distutils: added custom wokkel checking/building
Goffi <goffi@goffi.org>
parents: 230
diff changeset
77 class MercurialException(Exception):
0cd5b3c4513f Distutils: added custom wokkel checking/building
Goffi <goffi@goffi.org>
parents: 230
diff changeset
78 pass
225
fd9b7834d98a distutils installation script, draft
Goffi <goffi@goffi.org>
parents:
diff changeset
79
586
6a718ede8be1 Fix coding style in setup.py.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 581
diff changeset
80
235
7a2ef5fe4e8d distutils: added preinstall_check hack + some tuning while testing
Goffi <goffi@goffi.org>
parents: 233
diff changeset
81 def module_installed(module_name):
547
8b5e142354ca installation: added wokkel to dependencies, and removed custom wokkel installation in setup.py (muc branch is now merged mainstream)
Goffi <goffi@goffi.org>
parents: 480
diff changeset
82 """Try to import module_name, and return False if it failed
235
7a2ef5fe4e8d distutils: added preinstall_check hack + some tuning while testing
Goffi <goffi@goffi.org>
parents: 233
diff changeset
83 @param module_name: name of the module to test
7a2ef5fe4e8d distutils: added preinstall_check hack + some tuning while testing
Goffi <goffi@goffi.org>
parents: 233
diff changeset
84 @return: True if successful"""
7a2ef5fe4e8d distutils: added preinstall_check hack + some tuning while testing
Goffi <goffi@goffi.org>
parents: 233
diff changeset
85 try:
7a2ef5fe4e8d distutils: added preinstall_check hack + some tuning while testing
Goffi <goffi@goffi.org>
parents: 233
diff changeset
86 __import__(module_name)
586
6a718ede8be1 Fix coding style in setup.py.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 581
diff changeset
87 except ImportError:
235
7a2ef5fe4e8d distutils: added preinstall_check hack + some tuning while testing
Goffi <goffi@goffi.org>
parents: 233
diff changeset
88 return False
7a2ef5fe4e8d distutils: added preinstall_check hack + some tuning while testing
Goffi <goffi@goffi.org>
parents: 233
diff changeset
89 return True
7a2ef5fe4e8d distutils: added preinstall_check hack + some tuning while testing
Goffi <goffi@goffi.org>
parents: 233
diff changeset
90
586
6a718ede8be1 Fix coding style in setup.py.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 581
diff changeset
91
6a718ede8be1 Fix coding style in setup.py.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 581
diff changeset
92 class CustomInstall(install):
6a718ede8be1 Fix coding style in setup.py.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 581
diff changeset
93
1150
beaf8d4475e4 misc (D-Bus, installation): added a .service file for D-Bus auto-launch feature + installation from setup.py (path adaptation now use regex).
Goffi <goffi@goffi.org>
parents: 1138
diff changeset
94 def adapt_files(self):
beaf8d4475e4 misc (D-Bus, installation): added a .service file for D-Bus auto-launch feature + installation from setup.py (path adaptation now use regex).
Goffi <goffi@goffi.org>
parents: 1138
diff changeset
95 """Adapt files to installed environments
586
6a718ede8be1 Fix coding style in setup.py.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 581
diff changeset
96
1150
beaf8d4475e4 misc (D-Bus, installation): added a .service file for D-Bus auto-launch feature + installation from setup.py (path adaptation now use regex).
Goffi <goffi@goffi.org>
parents: 1138
diff changeset
97 Mainly change the paths
beaf8d4475e4 misc (D-Bus, installation): added a .service file for D-Bus auto-launch feature + installation from setup.py (path adaptation now use regex).
Goffi <goffi@goffi.org>
parents: 1138
diff changeset
98 """
beaf8d4475e4 misc (D-Bus, installation): added a .service file for D-Bus auto-launch feature + installation from setup.py (path adaptation now use regex).
Goffi <goffi@goffi.org>
parents: 1138
diff changeset
99 def adapter(ordered_replace, match_obj):
beaf8d4475e4 misc (D-Bus, installation): added a .service file for D-Bus auto-launch feature + installation from setup.py (path adaptation now use regex).
Goffi <goffi@goffi.org>
parents: 1138
diff changeset
100 """do file adjustment, getting self attribute when needed"""
beaf8d4475e4 misc (D-Bus, installation): added a .service file for D-Bus auto-launch feature + installation from setup.py (path adaptation now use regex).
Goffi <goffi@goffi.org>
parents: 1138
diff changeset
101 idx = match_obj.lastindex - 1
beaf8d4475e4 misc (D-Bus, installation): added a .service file for D-Bus auto-launch feature + installation from setup.py (path adaptation now use regex).
Goffi <goffi@goffi.org>
parents: 1138
diff changeset
102 repl_data = ordered_replace[idx][1]
beaf8d4475e4 misc (D-Bus, installation): added a .service file for D-Bus auto-launch feature + installation from setup.py (path adaptation now use regex).
Goffi <goffi@goffi.org>
parents: 1138
diff changeset
103 if isinstance(repl_data, tuple):
beaf8d4475e4 misc (D-Bus, installation): added a .service file for D-Bus auto-launch feature + installation from setup.py (path adaptation now use regex).
Goffi <goffi@goffi.org>
parents: 1138
diff changeset
104 template = repl_data[0]
beaf8d4475e4 misc (D-Bus, installation): added a .service file for D-Bus auto-launch feature + installation from setup.py (path adaptation now use regex).
Goffi <goffi@goffi.org>
parents: 1138
diff changeset
105 args = [getattr(self, arg) if isinstance(arg, basestring) else arg for arg in repl_data[1:]]
beaf8d4475e4 misc (D-Bus, installation): added a .service file for D-Bus auto-launch feature + installation from setup.py (path adaptation now use regex).
Goffi <goffi@goffi.org>
parents: 1138
diff changeset
106 return template.format(*args)
beaf8d4475e4 misc (D-Bus, installation): added a .service file for D-Bus auto-launch feature + installation from setup.py (path adaptation now use regex).
Goffi <goffi@goffi.org>
parents: 1138
diff changeset
107 return repl_data
beaf8d4475e4 misc (D-Bus, installation): added a .service file for D-Bus auto-launch feature + installation from setup.py (path adaptation now use regex).
Goffi <goffi@goffi.org>
parents: 1138
diff changeset
108
beaf8d4475e4 misc (D-Bus, installation): added a .service file for D-Bus auto-launch feature + installation from setup.py (path adaptation now use regex).
Goffi <goffi@goffi.org>
parents: 1138
diff changeset
109 for file_attr, replace_data in FILE_ADJ.iteritems():
beaf8d4475e4 misc (D-Bus, installation): added a .service file for D-Bus auto-launch feature + installation from setup.py (path adaptation now use regex).
Goffi <goffi@goffi.org>
parents: 1138
diff changeset
110 file_path = getattr(self, file_attr)
beaf8d4475e4 misc (D-Bus, installation): added a .service file for D-Bus auto-launch feature + installation from setup.py (path adaptation now use regex).
Goffi <goffi@goffi.org>
parents: 1138
diff changeset
111 ordered_replace = [(regex, repl) for regex, repl in replace_data.iteritems()]
beaf8d4475e4 misc (D-Bus, installation): added a .service file for D-Bus auto-launch feature + installation from setup.py (path adaptation now use regex).
Goffi <goffi@goffi.org>
parents: 1138
diff changeset
112 regex = '|'.join(('({})'.format(regex) for regex, dummy in ordered_replace))
beaf8d4475e4 misc (D-Bus, installation): added a .service file for D-Bus auto-launch feature + installation from setup.py (path adaptation now use regex).
Goffi <goffi@goffi.org>
parents: 1138
diff changeset
113 with open(file_path, 'r') as f:
beaf8d4475e4 misc (D-Bus, installation): added a .service file for D-Bus auto-launch feature + installation from setup.py (path adaptation now use regex).
Goffi <goffi@goffi.org>
parents: 1138
diff changeset
114 buff = f.read()
beaf8d4475e4 misc (D-Bus, installation): added a .service file for D-Bus auto-launch feature + installation from setup.py (path adaptation now use regex).
Goffi <goffi@goffi.org>
parents: 1138
diff changeset
115 buff = re.sub(regex, lambda match_obj: adapter(ordered_replace, match_obj), buff)
beaf8d4475e4 misc (D-Bus, installation): added a .service file for D-Bus auto-launch feature + installation from setup.py (path adaptation now use regex).
Goffi <goffi@goffi.org>
parents: 1138
diff changeset
116 with open(file_path, 'w') as f:
beaf8d4475e4 misc (D-Bus, installation): added a .service file for D-Bus auto-launch feature + installation from setup.py (path adaptation now use regex).
Goffi <goffi@goffi.org>
parents: 1138
diff changeset
117 f.write(buff)
225
fd9b7834d98a distutils installation script, draft
Goffi <goffi@goffi.org>
parents:
diff changeset
118
fd9b7834d98a distutils installation script, draft
Goffi <goffi@goffi.org>
parents:
diff changeset
119 def custom_create_links(self):
fd9b7834d98a distutils installation script, draft
Goffi <goffi@goffi.org>
parents:
diff changeset
120 """Create symbolic links to executables"""
586
6a718ede8be1 Fix coding style in setup.py.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 581
diff changeset
121 # the script which launch the daemon
1100
2be46f391cfa setup: SAT_INSTALL environment variable handles "clean" and "purge" options
souliane <souliane@mailoo.org>
parents: 1054
diff changeset
122 for source, dest in self.sh_script_links:
1154
6365e6826831 misc (install): use os.symlink instead of distutils.file_util.copy_file to avoid error when --root is used
Goffi <goffi@goffi.org>
parents: 1153
diff changeset
123 if self.root is None:
6365e6826831 misc (install): use os.symlink instead of distutils.file_util.copy_file to avoid error when --root is used
Goffi <goffi@goffi.org>
parents: 1153
diff changeset
124 if os.path.islink(dest) and os.readlink(dest) != source:
6365e6826831 misc (install): use os.symlink instead of distutils.file_util.copy_file to avoid error when --root is used
Goffi <goffi@goffi.org>
parents: 1153
diff changeset
125 os.remove(dest) # copy_file doesn't force the link update
6365e6826831 misc (install): use os.symlink instead of distutils.file_util.copy_file to avoid error when --root is used
Goffi <goffi@goffi.org>
parents: 1153
diff changeset
126 dest_name, copied = copy_file(source, dest, link='sym')
6365e6826831 misc (install): use os.symlink instead of distutils.file_util.copy_file to avoid error when --root is used
Goffi <goffi@goffi.org>
parents: 1153
diff changeset
127 assert copied
6365e6826831 misc (install): use os.symlink instead of distutils.file_util.copy_file to avoid error when --root is used
Goffi <goffi@goffi.org>
parents: 1153
diff changeset
128 # we change the perm in the same way as in the original install_scripts
6365e6826831 misc (install): use os.symlink instead of distutils.file_util.copy_file to avoid error when --root is used
Goffi <goffi@goffi.org>
parents: 1153
diff changeset
129 mode = ((os.stat(dest_name)[ST_MODE]) | 0555) & 07777
6365e6826831 misc (install): use os.symlink instead of distutils.file_util.copy_file to avoid error when --root is used
Goffi <goffi@goffi.org>
parents: 1153
diff changeset
130 os.chmod(dest_name, mode)
6365e6826831 misc (install): use os.symlink instead of distutils.file_util.copy_file to avoid error when --root is used
Goffi <goffi@goffi.org>
parents: 1153
diff changeset
131 else:
6365e6826831 misc (install): use os.symlink instead of distutils.file_util.copy_file to avoid error when --root is used
Goffi <goffi@goffi.org>
parents: 1153
diff changeset
132 # if root is not None, source probably doesn't exist yet
6365e6826831 misc (install): use os.symlink instead of distutils.file_util.copy_file to avoid error when --root is used
Goffi <goffi@goffi.org>
parents: 1153
diff changeset
133 # this is not managed by copy_file, so we must use os.symlink directly
6365e6826831 misc (install): use os.symlink instead of distutils.file_util.copy_file to avoid error when --root is used
Goffi <goffi@goffi.org>
parents: 1153
diff changeset
134 if os.path.islink(dest):
6365e6826831 misc (install): use os.symlink instead of distutils.file_util.copy_file to avoid error when --root is used
Goffi <goffi@goffi.org>
parents: 1153
diff changeset
135 os.remove(dest) # symlink doesn't force the link update
6365e6826831 misc (install): use os.symlink instead of distutils.file_util.copy_file to avoid error when --root is used
Goffi <goffi@goffi.org>
parents: 1153
diff changeset
136 os.symlink(source, dest)
225
fd9b7834d98a distutils installation script, draft
Goffi <goffi@goffi.org>
parents:
diff changeset
137
fd9b7834d98a distutils installation script, draft
Goffi <goffi@goffi.org>
parents:
diff changeset
138 def run(self):
1156
cc022c1cc09f misc (install): fixed self.root access when it's not used
Goffi <goffi@goffi.org>
parents: 1155
diff changeset
139 if not self.root:
cc022c1cc09f misc (install): fixed self.root access when it's not used
Goffi <goffi@goffi.org>
parents: 1155
diff changeset
140 ignore_idx = 0
cc022c1cc09f misc (install): fixed self.root access when it's not used
Goffi <goffi@goffi.org>
parents: 1155
diff changeset
141 else:
cc022c1cc09f misc (install): fixed self.root access when it's not used
Goffi <goffi@goffi.org>
parents: 1155
diff changeset
142 ignore_idx = len(self.root)
cc022c1cc09f misc (install): fixed self.root access when it's not used
Goffi <goffi@goffi.org>
parents: 1155
diff changeset
143 if self.root[-1] == '/':
cc022c1cc09f misc (install): fixed self.root access when it's not used
Goffi <goffi@goffi.org>
parents: 1155
diff changeset
144 ignore_idx-=1 # we dont want to remove the first '/' in _final paths
1153
25a16df15ae2 misc (installation): --root option is ignored for _final destinations
Goffi <goffi@goffi.org>
parents: 1150
diff changeset
145 # _final suffixed attributes are the ones without the self.root prefix path
25a16df15ae2 misc (installation): --root option is ignored for _final destinations
Goffi <goffi@goffi.org>
parents: 1150
diff changeset
146 # it's used at least on Arch linux installation as install is made on a local $pkgdir
25a16df15ae2 misc (installation): --root option is ignored for _final destinations
Goffi <goffi@goffi.org>
parents: 1150
diff changeset
147 # which is later moved to user's FS root
25a16df15ae2 misc (installation): --root option is ignored for _final destinations
Goffi <goffi@goffi.org>
parents: 1150
diff changeset
148 self.install_lib_final = self.install_lib[ignore_idx:]
1100
2be46f391cfa setup: SAT_INSTALL environment variable handles "clean" and "purge" options
souliane <souliane@mailoo.org>
parents: 1054
diff changeset
149 self.sh_script_path = os.path.join(self.install_lib, NAME, 'sat.sh')
1153
25a16df15ae2 misc (installation): --root option is ignored for _final destinations
Goffi <goffi@goffi.org>
parents: 1150
diff changeset
150 self.sh_script_path_final = os.path.join(self.install_lib_final, NAME, 'sat.sh')
25a16df15ae2 misc (installation): --root option is ignored for _final destinations
Goffi <goffi@goffi.org>
parents: 1150
diff changeset
151 self.sh_script_links = [(self.sh_script_path_final, os.path.join(self.install_scripts, LAUNCH_DAEMON_COMMAND))]
1150
beaf8d4475e4 misc (D-Bus, installation): added a .service file for D-Bus auto-launch feature + installation from setup.py (path adaptation now use regex).
Goffi <goffi@goffi.org>
parents: 1138
diff changeset
152 self.dbus_service_path = os.path.join(self.install_data, 'share', DBUS_DIR, os.path.basename(DBUS_FILE))
1100
2be46f391cfa setup: SAT_INSTALL environment variable handles "clean" and "purge" options
souliane <souliane@mailoo.org>
parents: 1054
diff changeset
153 sys.stdout.write('running pre installation stuff\n')
2be46f391cfa setup: SAT_INSTALL environment variable handles "clean" and "purge" options
souliane <souliane@mailoo.org>
parents: 1054
diff changeset
154 sys.stdout.flush()
2be46f391cfa setup: SAT_INSTALL environment variable handles "clean" and "purge" options
souliane <souliane@mailoo.org>
parents: 1054
diff changeset
155 if PURGE_OPT in install_opt:
2be46f391cfa setup: SAT_INSTALL environment variable handles "clean" and "purge" options
souliane <souliane@mailoo.org>
parents: 1054
diff changeset
156 self.purge()
2be46f391cfa setup: SAT_INSTALL environment variable handles "clean" and "purge" options
souliane <souliane@mailoo.org>
parents: 1054
diff changeset
157 elif CLEAN_OPT in install_opt:
2be46f391cfa setup: SAT_INSTALL environment variable handles "clean" and "purge" options
souliane <souliane@mailoo.org>
parents: 1054
diff changeset
158 self.clean()
225
fd9b7834d98a distutils installation script, draft
Goffi <goffi@goffi.org>
parents:
diff changeset
159 install.run(self)
586
6a718ede8be1 Fix coding style in setup.py.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 581
diff changeset
160 sys.stdout.write('running post installation stuff\n')
349
3ec237e82aed setup.py update:
Goffi <goffi@goffi.org>
parents: 335
diff changeset
161 sys.stdout.flush()
1150
beaf8d4475e4 misc (D-Bus, installation): added a .service file for D-Bus auto-launch feature + installation from setup.py (path adaptation now use regex).
Goffi <goffi@goffi.org>
parents: 1138
diff changeset
162 self.adapt_files()
225
fd9b7834d98a distutils installation script, draft
Goffi <goffi@goffi.org>
parents:
diff changeset
163 self.custom_create_links()
fd9b7834d98a distutils installation script, draft
Goffi <goffi@goffi.org>
parents:
diff changeset
164
1100
2be46f391cfa setup: SAT_INSTALL environment variable handles "clean" and "purge" options
souliane <souliane@mailoo.org>
parents: 1054
diff changeset
165 def confirm(self, message):
2be46f391cfa setup: SAT_INSTALL environment variable handles "clean" and "purge" options
souliane <souliane@mailoo.org>
parents: 1054
diff changeset
166 """Ask the user for a confirmation"""
2be46f391cfa setup: SAT_INSTALL environment variable handles "clean" and "purge" options
souliane <souliane@mailoo.org>
parents: 1054
diff changeset
167 message += 'Proceed'
2be46f391cfa setup: SAT_INSTALL environment variable handles "clean" and "purge" options
souliane <souliane@mailoo.org>
parents: 1054
diff changeset
168 while True:
2be46f391cfa setup: SAT_INSTALL environment variable handles "clean" and "purge" options
souliane <souliane@mailoo.org>
parents: 1054
diff changeset
169 res = raw_input("%s (y/n)? " % message)
2be46f391cfa setup: SAT_INSTALL environment variable handles "clean" and "purge" options
souliane <souliane@mailoo.org>
parents: 1054
diff changeset
170 if res not in ['y', 'Y', 'n', 'N']:
2be46f391cfa setup: SAT_INSTALL environment variable handles "clean" and "purge" options
souliane <souliane@mailoo.org>
parents: 1054
diff changeset
171 print "Your response ('%s') was not one of the expected responses: y, n" % res
2be46f391cfa setup: SAT_INSTALL environment variable handles "clean" and "purge" options
souliane <souliane@mailoo.org>
parents: 1054
diff changeset
172 message = 'Proceed'
2be46f391cfa setup: SAT_INSTALL environment variable handles "clean" and "purge" options
souliane <souliane@mailoo.org>
parents: 1054
diff changeset
173 continue
2be46f391cfa setup: SAT_INSTALL environment variable handles "clean" and "purge" options
souliane <souliane@mailoo.org>
parents: 1054
diff changeset
174 if res in ('y', 'Y'):
2be46f391cfa setup: SAT_INSTALL environment variable handles "clean" and "purge" options
souliane <souliane@mailoo.org>
parents: 1054
diff changeset
175 return True
2be46f391cfa setup: SAT_INSTALL environment variable handles "clean" and "purge" options
souliane <souliane@mailoo.org>
parents: 1054
diff changeset
176 return False
2be46f391cfa setup: SAT_INSTALL environment variable handles "clean" and "purge" options
souliane <souliane@mailoo.org>
parents: 1054
diff changeset
177
2be46f391cfa setup: SAT_INSTALL environment variable handles "clean" and "purge" options
souliane <souliane@mailoo.org>
parents: 1054
diff changeset
178 def clean(self, message=None, to_remove=None):
2be46f391cfa setup: SAT_INSTALL environment variable handles "clean" and "purge" options
souliane <souliane@mailoo.org>
parents: 1054
diff changeset
179 """Clean previous installation directories
2be46f391cfa setup: SAT_INSTALL environment variable handles "clean" and "purge" options
souliane <souliane@mailoo.org>
parents: 1054
diff changeset
180
2be46f391cfa setup: SAT_INSTALL environment variable handles "clean" and "purge" options
souliane <souliane@mailoo.org>
parents: 1054
diff changeset
181 @param message (str): to use a non-default confirmation message
2be46f391cfa setup: SAT_INSTALL environment variable handles "clean" and "purge" options
souliane <souliane@mailoo.org>
parents: 1054
diff changeset
182 @param to_remove (str): extra files/directories to remove
2be46f391cfa setup: SAT_INSTALL environment variable handles "clean" and "purge" options
souliane <souliane@mailoo.org>
parents: 1054
diff changeset
183 """
2be46f391cfa setup: SAT_INSTALL environment variable handles "clean" and "purge" options
souliane <souliane@mailoo.org>
parents: 1054
diff changeset
184 if message is None:
2be46f391cfa setup: SAT_INSTALL environment variable handles "clean" and "purge" options
souliane <souliane@mailoo.org>
parents: 1054
diff changeset
185 message = "Cleaning previous installation directories"
2be46f391cfa setup: SAT_INSTALL environment variable handles "clean" and "purge" options
souliane <souliane@mailoo.org>
parents: 1054
diff changeset
186 if to_remove is None:
2be46f391cfa setup: SAT_INSTALL environment variable handles "clean" and "purge" options
souliane <souliane@mailoo.org>
parents: 1054
diff changeset
187 to_remove = []
1107
8e15eeb3cfc3 setup: cleaning also handles egg filenames not containing the python version
souliane <souliane@mailoo.org>
parents: 1100
diff changeset
188 for path in [os.path.join(self.install_lib, NAME),
1138
a7cdf03c00e9 setup: sat_frontends was omitted by the cleaning method
souliane <souliane@mailoo.org>
parents: 1128
diff changeset
189 os.path.join(self.install_lib, "%s_frontends" % NAME),
1107
8e15eeb3cfc3 setup: cleaning also handles egg filenames not containing the python version
souliane <souliane@mailoo.org>
parents: 1100
diff changeset
190 os.path.join(self.install_data, 'share', 'doc', NAME),
8e15eeb3cfc3 setup: cleaning also handles egg filenames not containing the python version
souliane <souliane@mailoo.org>
parents: 1100
diff changeset
191 os.path.join(self.install_lib, "%s.egg-info" % self.config_vars['dist_fullname']),
8e15eeb3cfc3 setup: cleaning also handles egg filenames not containing the python version
souliane <souliane@mailoo.org>
parents: 1100
diff changeset
192 os.path.join(self.install_lib, "%s-py%s.egg-info" % (self.config_vars['dist_fullname'], self.config_vars['py_version_short'])),
8e15eeb3cfc3 setup: cleaning also handles egg filenames not containing the python version
souliane <souliane@mailoo.org>
parents: 1100
diff changeset
193 ]:
8e15eeb3cfc3 setup: cleaning also handles egg filenames not containing the python version
souliane <souliane@mailoo.org>
parents: 1100
diff changeset
194 if os.path.isdir(path):
8e15eeb3cfc3 setup: cleaning also handles egg filenames not containing the python version
souliane <souliane@mailoo.org>
parents: 1100
diff changeset
195 to_remove.append(path)
1100
2be46f391cfa setup: SAT_INSTALL environment variable handles "clean" and "purge" options
souliane <souliane@mailoo.org>
parents: 1054
diff changeset
196 for source, dest in self.sh_script_links:
2be46f391cfa setup: SAT_INSTALL environment variable handles "clean" and "purge" options
souliane <souliane@mailoo.org>
parents: 1054
diff changeset
197 if os.path.islink(dest):
2be46f391cfa setup: SAT_INSTALL environment variable handles "clean" and "purge" options
souliane <souliane@mailoo.org>
parents: 1054
diff changeset
198 to_remove.append(dest)
2be46f391cfa setup: SAT_INSTALL environment variable handles "clean" and "purge" options
souliane <souliane@mailoo.org>
parents: 1054
diff changeset
199
1291
0db0013c59dd remove remaining references to Wix
souliane <souliane@mailoo.org>
parents: 1208
diff changeset
200 for script in ('jp', 'primitivus'):
1100
2be46f391cfa setup: SAT_INSTALL environment variable handles "clean" and "purge" options
souliane <souliane@mailoo.org>
parents: 1054
diff changeset
201 dest = os.path.join(self.install_scripts, script)
2be46f391cfa setup: SAT_INSTALL environment variable handles "clean" and "purge" options
souliane <souliane@mailoo.org>
parents: 1054
diff changeset
202 if os.path.exists(dest):
2be46f391cfa setup: SAT_INSTALL environment variable handles "clean" and "purge" options
souliane <souliane@mailoo.org>
parents: 1054
diff changeset
203 to_remove.append(dest)
2be46f391cfa setup: SAT_INSTALL environment variable handles "clean" and "purge" options
souliane <souliane@mailoo.org>
parents: 1054
diff changeset
204
2be46f391cfa setup: SAT_INSTALL environment variable handles "clean" and "purge" options
souliane <souliane@mailoo.org>
parents: 1054
diff changeset
205 message = "%s:\n%s\n" % (message, "\n".join([" %s" % path for path in to_remove]))
2be46f391cfa setup: SAT_INSTALL environment variable handles "clean" and "purge" options
souliane <souliane@mailoo.org>
parents: 1054
diff changeset
206 if not self.confirm(message):
2be46f391cfa setup: SAT_INSTALL environment variable handles "clean" and "purge" options
souliane <souliane@mailoo.org>
parents: 1054
diff changeset
207 return
2be46f391cfa setup: SAT_INSTALL environment variable handles "clean" and "purge" options
souliane <souliane@mailoo.org>
parents: 1054
diff changeset
208 sys.stdout.write('cleaning previous installation directories...\n')
2be46f391cfa setup: SAT_INSTALL environment variable handles "clean" and "purge" options
souliane <souliane@mailoo.org>
parents: 1054
diff changeset
209 sys.stdout.flush()
2be46f391cfa setup: SAT_INSTALL environment variable handles "clean" and "purge" options
souliane <souliane@mailoo.org>
parents: 1054
diff changeset
210 for path in to_remove:
2be46f391cfa setup: SAT_INSTALL environment variable handles "clean" and "purge" options
souliane <souliane@mailoo.org>
parents: 1054
diff changeset
211 if os.path.isdir(path):
2be46f391cfa setup: SAT_INSTALL environment variable handles "clean" and "purge" options
souliane <souliane@mailoo.org>
parents: 1054
diff changeset
212 shutil.rmtree(path, ignore_errors=True)
2be46f391cfa setup: SAT_INSTALL environment variable handles "clean" and "purge" options
souliane <souliane@mailoo.org>
parents: 1054
diff changeset
213 else:
2be46f391cfa setup: SAT_INSTALL environment variable handles "clean" and "purge" options
souliane <souliane@mailoo.org>
parents: 1054
diff changeset
214 os.remove(path)
2be46f391cfa setup: SAT_INSTALL environment variable handles "clean" and "purge" options
souliane <souliane@mailoo.org>
parents: 1054
diff changeset
215
2be46f391cfa setup: SAT_INSTALL environment variable handles "clean" and "purge" options
souliane <souliane@mailoo.org>
parents: 1054
diff changeset
216 def purge(self):
2be46f391cfa setup: SAT_INSTALL environment variable handles "clean" and "purge" options
souliane <souliane@mailoo.org>
parents: 1054
diff changeset
217 """Clean building and previous installation directories"""
2be46f391cfa setup: SAT_INSTALL environment variable handles "clean" and "purge" options
souliane <souliane@mailoo.org>
parents: 1054
diff changeset
218 message = "Cleaning building and previous installation directories"
2be46f391cfa setup: SAT_INSTALL environment variable handles "clean" and "purge" options
souliane <souliane@mailoo.org>
parents: 1054
diff changeset
219 to_remove = [os.path.join(os.getcwd(), 'build')]
2be46f391cfa setup: SAT_INSTALL environment variable handles "clean" and "purge" options
souliane <souliane@mailoo.org>
parents: 1054
diff changeset
220 self.clean(message, to_remove)
2be46f391cfa setup: SAT_INSTALL environment variable handles "clean" and "purge" options
souliane <souliane@mailoo.org>
parents: 1054
diff changeset
221
225
fd9b7834d98a distutils installation script, draft
Goffi <goffi@goffi.org>
parents:
diff changeset
222
884
4054cf716322 setup.py fixes and improvments
Goffi <goffi@goffi.org>
parents: 881
diff changeset
223 def preinstall_check(install_opt):
235
7a2ef5fe4e8d distutils: added preinstall_check hack + some tuning while testing
Goffi <goffi@goffi.org>
parents: 233
diff changeset
224 """Check presence of problematic dependencies, and try to install them with package manager
7a2ef5fe4e8d distutils: added preinstall_check hack + some tuning while testing
Goffi <goffi@goffi.org>
parents: 233
diff changeset
225 This ugly stuff is necessary as distributions are not installed correctly with setuptools/distribute
7a2ef5fe4e8d distutils: added preinstall_check hack + some tuning while testing
Goffi <goffi@goffi.org>
parents: 233
diff changeset
226 Hope to remove this at some point"""
7a2ef5fe4e8d distutils: added preinstall_check hack + some tuning while testing
Goffi <goffi@goffi.org>
parents: 233
diff changeset
227
1464
fecd502743b3 setup: wx is not more a dependency since wix has been deprecated
souliane <souliane@mailoo.org>
parents: 1443
diff changeset
228 #modules_tocheck = ['twisted', 'twisted.words', 'twisted.web', 'urwid']
884
4054cf716322 setup.py fixes and improvments
Goffi <goffi@goffi.org>
parents: 881
diff changeset
229 modules_tocheck = ['gobject'] # XXX: python-gobject is not up-to-date in PyPi
235
7a2ef5fe4e8d distutils: added preinstall_check hack + some tuning while testing
Goffi <goffi@goffi.org>
parents: 233
diff changeset
230
586
6a718ede8be1 Fix coding style in setup.py.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 581
diff changeset
231 package = {'twisted': 'python-twisted-core',
6a718ede8be1 Fix coding style in setup.py.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 581
diff changeset
232 'twisted.words': 'python-twisted-words',
6a718ede8be1 Fix coding style in setup.py.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 581
diff changeset
233 'twisted.web': 'python-twisted-web',
6a718ede8be1 Fix coding style in setup.py.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 581
diff changeset
234 'urwid': 'python-urwid',
6a718ede8be1 Fix coding style in setup.py.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 581
diff changeset
235 'gobject': 'python-gobject',
6a718ede8be1 Fix coding style in setup.py.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 581
diff changeset
236 'mercurial': 'mercurial'} # this dict map dependencies to packages names for debian distributions
235
7a2ef5fe4e8d distutils: added preinstall_check hack + some tuning while testing
Goffi <goffi@goffi.org>
parents: 233
diff changeset
237
586
6a718ede8be1 Fix coding style in setup.py.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 581
diff changeset
238 sys.stdout.write("Running pre-installation dependencies check\n")
6a718ede8be1 Fix coding style in setup.py.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 581
diff changeset
239
6a718ede8be1 Fix coding style in setup.py.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 581
diff changeset
240 # which modules are not installed ?
6a718ede8be1 Fix coding style in setup.py.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 581
diff changeset
241 modules_toinstall = [mod for mod in modules_tocheck if not module_installed(mod)]
6a718ede8be1 Fix coding style in setup.py.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 581
diff changeset
242 """# is mercurial available ?
235
7a2ef5fe4e8d distutils: added preinstall_check hack + some tuning while testing
Goffi <goffi@goffi.org>
parents: 233
diff changeset
243 hg_installed = subprocess.call('which hg', stdout=open('/dev/null', 'w'), shell=True) == 0
7a2ef5fe4e8d distutils: added preinstall_check hack + some tuning while testing
Goffi <goffi@goffi.org>
parents: 233
diff changeset
244 if not hg_installed:
586
6a718ede8be1 Fix coding style in setup.py.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 581
diff changeset
245 modules_toinstall.append('mercurial')""" # hg can be installed from pypi
6a718ede8be1 Fix coding style in setup.py.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 581
diff changeset
246
235
7a2ef5fe4e8d distutils: added preinstall_check hack + some tuning while testing
Goffi <goffi@goffi.org>
parents: 233
diff changeset
247 if modules_toinstall:
1100
2be46f391cfa setup: SAT_INSTALL environment variable handles "clean" and "purge" options
souliane <souliane@mailoo.org>
parents: 1054
diff changeset
248 if AUTO_DEB_OPT in install_opt: # auto debian installation is requested
884
4054cf716322 setup.py fixes and improvments
Goffi <goffi@goffi.org>
parents: 881
diff changeset
249 # are we on a distribution using apt ?
4054cf716322 setup.py fixes and improvments
Goffi <goffi@goffi.org>
parents: 881
diff changeset
250 apt_path = subprocess.Popen('which apt-get', stdout=subprocess.PIPE, shell=True).communicate()[0][:-1]
4054cf716322 setup.py fixes and improvments
Goffi <goffi@goffi.org>
parents: 881
diff changeset
251 else:
4054cf716322 setup.py fixes and improvments
Goffi <goffi@goffi.org>
parents: 881
diff changeset
252 apt_path = None
4054cf716322 setup.py fixes and improvments
Goffi <goffi@goffi.org>
parents: 881
diff changeset
253
586
6a718ede8be1 Fix coding style in setup.py.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 581
diff changeset
254 not_installed = set()
235
7a2ef5fe4e8d distutils: added preinstall_check hack + some tuning while testing
Goffi <goffi@goffi.org>
parents: 233
diff changeset
255 if apt_path:
586
6a718ede8be1 Fix coding style in setup.py.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 581
diff changeset
256 # we have apt, we'll try to use it
235
7a2ef5fe4e8d distutils: added preinstall_check hack + some tuning while testing
Goffi <goffi@goffi.org>
parents: 233
diff changeset
257 for module_name in modules_toinstall:
7a2ef5fe4e8d distutils: added preinstall_check hack + some tuning while testing
Goffi <goffi@goffi.org>
parents: 233
diff changeset
258 package_name = package[module_name]
586
6a718ede8be1 Fix coding style in setup.py.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 581
diff changeset
259 sys.stdout.write("Installing %s\n" % package_name)
1937
14a33c2b1b2a core (installation): minor comment in setup.py
Goffi <goffi@goffi.org>
parents: 1935
diff changeset
260 # TODO: use sudo to get root rights
586
6a718ede8be1 Fix coding style in setup.py.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 581
diff changeset
261 success = subprocess.call('%s -qy install %s' % (apt_path, package_name), shell=True) == 0
235
7a2ef5fe4e8d distutils: added preinstall_check hack + some tuning while testing
Goffi <goffi@goffi.org>
parents: 233
diff changeset
262 if not success:
7a2ef5fe4e8d distutils: added preinstall_check hack + some tuning while testing
Goffi <goffi@goffi.org>
parents: 233
diff changeset
263 not_installed.add(module_name)
7a2ef5fe4e8d distutils: added preinstall_check hack + some tuning while testing
Goffi <goffi@goffi.org>
parents: 233
diff changeset
264 else:
586
6a718ede8be1 Fix coding style in setup.py.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 581
diff changeset
265 not_installed = set(modules_toinstall)
235
7a2ef5fe4e8d distutils: added preinstall_check hack + some tuning while testing
Goffi <goffi@goffi.org>
parents: 233
diff changeset
266
7a2ef5fe4e8d distutils: added preinstall_check hack + some tuning while testing
Goffi <goffi@goffi.org>
parents: 233
diff changeset
267 if not_installed:
586
6a718ede8be1 Fix coding style in setup.py.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 581
diff changeset
268 # some packages can't be automatically installed, we print their name for manual installation
6a718ede8be1 Fix coding style in setup.py.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 581
diff changeset
269 sys.stdout.write("You should install the following dependencies with your distribution recommanded tool before installing %s:\n" % NAME)
235
7a2ef5fe4e8d distutils: added preinstall_check hack + some tuning while testing
Goffi <goffi@goffi.org>
parents: 233
diff changeset
270 for module_name in not_installed:
586
6a718ede8be1 Fix coding style in setup.py.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 581
diff changeset
271 sys.stdout.write("- %s (Debian name: %s)\n" % (module_name, package[module_name]))
235
7a2ef5fe4e8d distutils: added preinstall_check hack + some tuning while testing
Goffi <goffi@goffi.org>
parents: 233
diff changeset
272 sys.exit(2)
586
6a718ede8be1 Fix coding style in setup.py.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 581
diff changeset
273
1100
2be46f391cfa setup: SAT_INSTALL environment variable handles "clean" and "purge" options
souliane <souliane@mailoo.org>
parents: 1054
diff changeset
274
586
6a718ede8be1 Fix coding style in setup.py.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 581
diff changeset
275 if sys.argv[1].lower() in ['egg_info', 'install']:
6a718ede8be1 Fix coding style in setup.py.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 581
diff changeset
276 # we only check dependencies if egg_info or install is used
884
4054cf716322 setup.py fixes and improvments
Goffi <goffi@goffi.org>
parents: 881
diff changeset
277 install_opt = os.environ.get(ENV_SAT_INSTALL, "").split()
4054cf716322 setup.py fixes and improvments
Goffi <goffi@goffi.org>
parents: 881
diff changeset
278 if not NO_PREINSTALL_OPT in install_opt: # user can force preinstall skipping
4054cf716322 setup.py fixes and improvments
Goffi <goffi@goffi.org>
parents: 881
diff changeset
279 preinstall_check(install_opt)
225
fd9b7834d98a distutils installation script, draft
Goffi <goffi@goffi.org>
parents:
diff changeset
280
fd9b7834d98a distutils installation script, draft
Goffi <goffi@goffi.org>
parents:
diff changeset
281 setup(name=NAME,
2003
b075c5a576ef installation (setup.py): changed version to 0.6.1.1 so new archive with fixed MANIFEST can be uploaded on pypi
Goffi <goffi@goffi.org>
parents: 1997
diff changeset
282 version='0.6.1.1',
225
fd9b7834d98a distutils installation script, draft
Goffi <goffi@goffi.org>
parents:
diff changeset
283 description=u'Salut à Toi multi-frontend XMPP client',
580
07d7c496ece9 misc: setup.py long description update
Goffi <goffi@goffi.org>
parents: 575
diff changeset
284 long_description=u'Salut à Toi (SàT) is a XMPP client based on a daemon/frontend architecture. Its multi-frontends (desktop, web, console interface, CLI, etc) and multi-purposes (instant messaging, microblogging, games, file sharing, etc).',
1123
e89bd3a26c86 installation: setup.py update:
Goffi <goffi@goffi.org>
parents: 1115
diff changeset
285 author='Association « Salut à Toi »',
e89bd3a26c86 installation: setup.py update:
Goffi <goffi@goffi.org>
parents: 1115
diff changeset
286 author_email='contact@goffi.org',
e89bd3a26c86 installation: setup.py update:
Goffi <goffi@goffi.org>
parents: 1115
diff changeset
287 url='http://salut-a-toi.org',
225
fd9b7834d98a distutils installation script, draft
Goffi <goffi@goffi.org>
parents:
diff changeset
288 classifiers=['Development Status :: 3 - Alpha',
fd9b7834d98a distutils installation script, draft
Goffi <goffi@goffi.org>
parents:
diff changeset
289 'Environment :: Console',
fd9b7834d98a distutils installation script, draft
Goffi <goffi@goffi.org>
parents:
diff changeset
290 'Environment :: X11 Applications :: GTK',
fd9b7834d98a distutils installation script, draft
Goffi <goffi@goffi.org>
parents:
diff changeset
291 'Framework :: Twisted',
480
2a072735e459 Licence modification: the full project is now under AGPL v3+ instead of GPL v3+
Goffi <goffi@goffi.org>
parents: 473
diff changeset
292 'License :: OSI Approved :: GNU Affero General Public License v3 or later (AGPLv3+)',
225
fd9b7834d98a distutils installation script, draft
Goffi <goffi@goffi.org>
parents:
diff changeset
293 'Operating System :: POSIX :: Linux',
fd9b7834d98a distutils installation script, draft
Goffi <goffi@goffi.org>
parents:
diff changeset
294 'Topic :: Communications :: Chat'],
1123
e89bd3a26c86 installation: setup.py update:
Goffi <goffi@goffi.org>
parents: 1115
diff changeset
295 package_dir={'sat': 'src', 'sat_frontends': 'frontends/src', 'twisted.plugins': 'src/twisted/plugins'},
1928
6a8b26754f0d setup: added sat.tools.common in packages
Goffi <goffi@goffi.org>
parents: 1896
diff changeset
296 packages=['sat', 'sat.tools', 'sat.tools.common', 'sat.bridge', 'sat.plugins', 'sat.test', 'sat.core', 'sat.memory',
848
d40306d1da70 misc: setup.py was not installing sat_frontends.jp
souliane <souliane@mailoo.org>
parents: 774
diff changeset
297 'sat_frontends', 'sat_frontends.bridge', 'sat_frontends.quick_frontend', 'sat_frontends.jp',
1367
f71a0fc26886 merged branch frontends_multi_profiles
Goffi <goffi@goffi.org>
parents: 1280 1291
diff changeset
298 'sat_frontends.primitivus', 'sat_frontends.tools', 'sat.stdui','sat.tmp', 'sat.tmp.wokkel',
f71a0fc26886 merged branch frontends_multi_profiles
Goffi <goffi@goffi.org>
parents: 1280 1291
diff changeset
299 'twisted.plugins'],
1291
0db0013c59dd remove remaining references to Wix
souliane <souliane@mailoo.org>
parents: 1208
diff changeset
300 package_data={'sat': ['sat.sh'], },
586
6a718ede8be1 Fix coding style in setup.py.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 581
diff changeset
301 data_files=[(os.path.join(sys.prefix, 'share/locale/fr/LC_MESSAGES'), ['i18n/fr/LC_MESSAGES/sat.mo']),
227
533507bb4e32 distutils wix installation
Goffi <goffi@goffi.org>
parents: 225
diff changeset
302 ('share/doc/%s' % NAME, ['CHANGELOG', 'COPYING', 'INSTALL', 'README', 'README4TRANSLATORS']),
1150
beaf8d4475e4 misc (D-Bus, installation): added a .service file for D-Bus auto-launch feature + installation from setup.py (path adaptation now use regex).
Goffi <goffi@goffi.org>
parents: 1138
diff changeset
303 (os.path.join('share', DBUS_DIR), (DBUS_FILE,)),
227
533507bb4e32 distutils wix installation
Goffi <goffi@goffi.org>
parents: 225
diff changeset
304 ],
1291
0db0013c59dd remove remaining references to Wix
souliane <souliane@mailoo.org>
parents: 1208
diff changeset
305 scripts=['frontends/src/jp/jp', 'frontends/src/primitivus/primitivus', ],
230
b25cbec73c1e distutils: removes build and dist from manifest's prune
Goffi <goffi@goffi.org>
parents: 227
diff changeset
306 zip_safe=False,
2184
e0f91efa404a plugin invitations: first draft:
Goffi <goffi@goffi.org>
parents: 2003
diff changeset
307 install_requires=['twisted >= 15.2.0', 'wokkel >= 0.7.1', 'progressbar', 'urwid >= 1.2.0', 'urwid-satext >= 0.6.1', 'mutagen', 'pillow', 'lxml >= 3.1.0', 'pyxdg', 'markdown', 'html2text', 'pycrypto >= 2.6.1', 'python-potr', 'PyOpenSSL', 'service_identity', 'shortuuid'],
586
6a718ede8be1 Fix coding style in setup.py.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 581
diff changeset
308 cmdclass={'install': CustomInstall},
1846
fdc1dfcee35e install: removed "nox" option as there is no more X dependency since WIX has been deprecated
Goffi <goffi@goffi.org>
parents: 1809
diff changeset
309 )