Bonjour,
Je souhaite généré un fichier .ini durant l'install stokant les informations relatives au chemin d'installation des données.
En effet si un utilisateur ne stocke pas a un endroit prévue notamment en utilisant --home-dir .... le programme n'a aucun moyen post installation de connaitre la localisation
Donc l'idée était de stocker ces chemin dans un fichier, voilà ce que ça donne:
et la sortie
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109 from distutils.command.build import build as _build from distutils.command.build_py import build_py as _build_py from distutils.command.install_data import install_data as _install_data from distutils.command.install_lib import install_lib as _install_lib from distutils.command.install import install as _install from distutils.core import setup, Command from distutils.errors import DistutilsFileError import subprocess, shutil, os, fileinput, sys, re, glob from os.path import * sys.path.insert(0, join(dirname(__file__), "src")) class package_ini(Command): """ Locate "package.ini" in all installed packages and patch it as requested by wildcard references to install process. """ user_options = [] def initialize_options(self): pass def finalize_options(self): pass def visit(self, dirname, names): packages = self.distribution.get_command_obj(_build_py.__name__).packages if basename(dirname) in packages: if "package.ini" in names: self.patch(join(dirname, "package.ini")) def patch(self, ini_file): print "patching file" + ini_file with open(ini_file,"r") as infile: file_data = infile.readlines() with open(ini_file,"w") as outfile: for line in file_data: _line = self.patch_line(line) if _line: line = _line outfile.write(line) def patch_line(self, line): """ Patch an installed package.ini with setup"s variables """ match = re.match("(?P<identifier>\w+)\s*=.*##SETUP_PATCH\\((?P<command>.*)\.(?P<variable>.*)\\)", line) if not match: return line print "Replacing:"+line line = match.group("identifier") line += " = " data = "(self).distribution.get_command_obj(\""+\ match.group("command")+"\")"+"."+\ match.group("variable") line += "\""+ eval(data)+ "\"" + "\n" print "With:" + line return line def run(self): """ Patch package.ini files in distribution package with variables from setup """ walk( self.distribution.get_command_obj(install.__name__).install_lib, package_ini.visit, self ) class install(_install): sub_commands = _install.sub_commands + [ (package_ini.__name__, None) ] setup( cmdclass = { "build_py" : _build_py , "install_data" : _install_data , "install_lib" : _install_lib , "install" : install , "package_ini" : package_ini }, name = "libbbcf", version = "1.9rc1", description = "Utility modules for deploying workflows in the BBCF", long_description= open("README").read(), keywords = "bioinformatic genomic chipseq", author = "EPFL BBCF,Jonathan Mercier, Fred Ross, Jacques Rougemont", author_email = "webmaster.bbcf@epfl.ch", license = "GPLv3", packages = ["bbcf", "bbcf.core", "bbcf.binding"], package_dir = {"bbcf": "src/bbcf"}, package_data = {"bbcf":["package.ini"]}, data_files = [ ( "share/bbcf/", glob.glob("data/bbcf.sql") ), ( "share/bbcf/", ["README"] ), ( "share/bbcf/", ["LICENSE"] ) ], install_requires= ["bein", "pysqlite"], classifiers = [ "Topic :: Scientific/Engineering :: Bio-Informatics", "Intended Audience :: Developers" , "Programming Language :: Python" , "Environment :: Console" , "License :: OSI Approved :: GNU GPLv3" , "Operating System :: MacOS :: MacOS X" , "Operating System :: Microsoft :: Windows" , "Operating System :: POSIX" ] )
Merci par avance de toute aide
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80 # python setup.py -v install --record files.txt /usr/lib64/python2.7/distutils/dist.py:267: UserWarning: Unknown distribution option: 'install_requires' warnings.warn(msg) running install running build running build_py copying src/bbcf/__init__.py -> build/lib/bbcf copying src/bbcf/core/matrix.py -> build/lib/bbcf/core copying src/bbcf/core/pattern.py -> build/lib/bbcf/core copying src/bbcf/core/generic.py -> build/lib/bbcf/core copying src/bbcf/core/exception.py -> build/lib/bbcf/core copying src/bbcf/core/format.py -> build/lib/bbcf/core copying src/bbcf/core/sequence.py -> build/lib/bbcf/core copying src/bbcf/core/data.py -> build/lib/bbcf/core copying src/bbcf/core/common.py -> build/lib/bbcf/core copying src/bbcf/core/__init__.py -> build/lib/bbcf/core copying src/bbcf/binding/genrep.py -> build/lib/bbcf/binding copying src/bbcf/binding/__init__.py -> build/lib/bbcf/binding copying src/bbcf/binding/database.py -> build/lib/bbcf/binding copying src/bbcf/binding/gdv.py -> build/lib/bbcf/binding copying src/bbcf/binding/meme.py -> build/lib/bbcf/binding copying src/bbcf/binding/hts.py -> build/lib/bbcf/binding running install_lib not copying build/lib/bbcf/__init__.py (output up-to-date) not copying build/lib/bbcf/binding/genrep.py (output up-to-date) not copying build/lib/bbcf/binding/__init__.py (output up-to-date) not copying build/lib/bbcf/binding/database.py (output up-to-date) not copying build/lib/bbcf/binding/gdv.py (output up-to-date) not copying build/lib/bbcf/binding/meme.py (output up-to-date) not copying build/lib/bbcf/binding/hts.py (output up-to-date) not copying build/lib/bbcf/core/matrix.py (output up-to-date) not copying build/lib/bbcf/core/pattern.py (output up-to-date) not copying build/lib/bbcf/core/generic.py (output up-to-date) not copying build/lib/bbcf/core/exception.py (output up-to-date) not copying build/lib/bbcf/core/format.py (output up-to-date) not copying build/lib/bbcf/core/sequence.py (output up-to-date) not copying build/lib/bbcf/core/data.py (output up-to-date) not copying build/lib/bbcf/core/common.py (output up-to-date) not copying build/lib/bbcf/core/__init__.py (output up-to-date) skipping byte-compilation of /usr/lib/python2.7/site-packages/bbcf/__init__.py to __init__.pyc skipping byte-compilation of /usr/lib/python2.7/site-packages/bbcf/binding/genrep.py to genrep.pyc skipping byte-compilation of /usr/lib/python2.7/site-packages/bbcf/binding/__init__.py to __init__.pyc skipping byte-compilation of /usr/lib/python2.7/site-packages/bbcf/binding/database.py to database.pyc skipping byte-compilation of /usr/lib/python2.7/site-packages/bbcf/binding/gdv.py to gdv.pyc skipping byte-compilation of /usr/lib/python2.7/site-packages/bbcf/binding/meme.py to meme.pyc skipping byte-compilation of /usr/lib/python2.7/site-packages/bbcf/binding/hts.py to hts.pyc skipping byte-compilation of /usr/lib/python2.7/site-packages/bbcf/core/matrix.py to matrix.pyc skipping byte-compilation of /usr/lib/python2.7/site-packages/bbcf/core/pattern.py to pattern.pyc skipping byte-compilation of /usr/lib/python2.7/site-packages/bbcf/core/generic.py to generic.pyc skipping byte-compilation of /usr/lib/python2.7/site-packages/bbcf/core/exception.py to exception.pyc skipping byte-compilation of /usr/lib/python2.7/site-packages/bbcf/core/format.py to format.pyc skipping byte-compilation of /usr/lib/python2.7/site-packages/bbcf/core/sequence.py to sequence.pyc skipping byte-compilation of /usr/lib/python2.7/site-packages/bbcf/core/data.py to data.pyc skipping byte-compilation of /usr/lib/python2.7/site-packages/bbcf/core/common.py to common.pyc skipping byte-compilation of /usr/lib/python2.7/site-packages/bbcf/core/__init__.py to __init__.pyc running install_data copying data/bbcf.sql -> /usr/share/bbcf/ copying README -> /usr/share/bbcf/ copying LICENSE -> /usr/share/bbcf/ running install_egg_info Removing /usr/lib/python2.7/site-packages/libbbcf-1.9rc1-py2.7.egg-info Writing /usr/lib/python2.7/site-packages/libbbcf-1.9rc1-py2.7.egg-info running package_ini Traceback (most recent call last): File "setup.py", line 107, in <module> "Operating System :: POSIX" File "/usr/lib64/python2.7/distutils/core.py", line 152, in setup dist.run_commands() File "/usr/lib64/python2.7/distutils/dist.py", line 953, in run_commands self.run_command(cmd) File "/usr/lib64/python2.7/distutils/dist.py", line 972, in run_command cmd_obj.run() File "/usr/lib64/python2.7/distutils/command/install.py", line 582, in run outputs = self.get_outputs() File "/usr/lib64/python2.7/distutils/command/install.py", line 625, in get_outputs for filename in cmd.get_outputs(): File "/usr/lib64/python2.7/distutils/cmd.py", line 105, in __getattr__ raise AttributeError, attr AttributeError: get_outputs
Partager