|
Lines 77-160
Link Here
|
| 77 |
# we put the global pyxrc into the share directory as well. |
77 |
# we put the global pyxrc into the share directory as well. |
| 78 |
adddatafiles("pyxrcdir", os.name != "nt" and "/etc" or "share/pyx", ["pyxrc"]) |
78 |
adddatafiles("pyxrcdir", os.name != "nt" and "/etc" or "share/pyx", ["pyxrc"]) |
| 79 |
|
79 |
|
| 80 |
################################################################################ |
|
|
| 81 |
# extend install commands to overwrite siteconfig.py during build and install |
| 82 |
# |
| 83 |
|
| 84 |
|
| 85 |
class pyx_build_py(build_py): |
| 86 |
|
| 87 |
def build_module(self, module, module_file, package): |
| 88 |
if package == "pyx" and module == "siteconfig": |
| 89 |
# generate path information as the original build_module does it |
| 90 |
outfile = self.get_module_outfile(self.build_lib, [package], module) |
| 91 |
outdir = os.path.dirname(outfile) |
| 92 |
self.mkpath(outdir) |
| 93 |
|
| 94 |
if log: |
| 95 |
log.info("creating proper %s" % outfile) |
| 96 |
|
| 97 |
# create the additional relative path parts to be inserted into the |
| 98 |
# os.path.join methods in the original siteconfig.py |
| 99 |
indir = os.path.dirname(module_file) |
| 100 |
addjoinstring = ", ".join(["'..'" for d in outdir.split(os.path.sep)] + |
| 101 |
["'%s'" % d for d in indir.split(os.path.sep)]) |
| 102 |
|
| 103 |
# write a modifed version of siteconfig.py |
| 104 |
fin = open(module_file, "r") |
| 105 |
fout = open(outfile, "w") |
| 106 |
for line in fin.readlines(): |
| 107 |
fout.write(line.replace("os.path.join(os.path.dirname(__file__), ", |
| 108 |
"os.path.join(os.path.dirname(__file__), %s, " % addjoinstring)) |
| 109 |
fin.close() |
| 110 |
fout.close() |
| 111 |
else: |
| 112 |
return build_py.build_module(self, module, module_file, package) |
| 113 |
|
| 114 |
|
| 115 |
class pyx_install_data(install_data): |
| 116 |
|
| 117 |
def run(self): |
| 118 |
self.siteconfiglines = [] |
| 119 |
for dir, files in self.data_files: |
| 120 |
# append siteconfiglines by "<siteconfigname> = <dir>" |
| 121 |
|
| 122 |
# get the install directory |
| 123 |
# (the following four lines are copied from within the install_data.run loop) |
| 124 |
dir = convert_path(dir) |
| 125 |
if not os.path.isabs(dir): |
| 126 |
dir = os.path.join(self.install_dir, dir) |
| 127 |
elif self.root: |
| 128 |
dir = change_root(self.root, dir) |
| 129 |
|
| 130 |
self.siteconfiglines.append("%s = '%s'\n" % (siteconfignames[files], dir)) |
| 131 |
|
| 132 |
install_data.run(self) |
| 133 |
|
| 134 |
|
| 135 |
class pyx_install_lib(install_lib): |
| 136 |
|
| 137 |
def run(self): |
| 138 |
# siteconfig.py depends on install_data: |
| 139 |
self.run_command('install_data') |
| 140 |
install_lib.run(self) |
| 141 |
|
| 142 |
def install(self): |
| 143 |
# first we perform the tree_copy |
| 144 |
result = install_lib.install(self) |
| 145 |
|
| 146 |
# siteconfiglines have been created by install_data |
| 147 |
siteconfiglines = self.distribution.command_obj["install_data"].siteconfiglines |
| 148 |
|
| 149 |
# such that we can easily overwrite siteconfig.py |
| 150 |
outfile = os.path.join(self.install_dir, "pyx", "siteconfig.py") |
| 151 |
if log: |
| 152 |
log.info("creating proper %s" % outfile) |
| 153 |
f = open(outfile, "w") |
| 154 |
f.writelines(siteconfiglines) |
| 155 |
f.close() |
| 156 |
|
| 157 |
return result |
| 158 |
|
80 |
|
| 159 |
################################################################################ |
81 |
################################################################################ |
| 160 |
# additional package metadata (only available in Python 2.3 and above) |
82 |
# additional package metadata (only available in Python 2.3 and above) |
|
Lines 193-199
Link Here
|
| 193 |
packages=["pyx", "pyx/graph", "pyx/graph/axis", "pyx/t1strip", "pyx/pykpathsea"], |
115 |
packages=["pyx", "pyx/graph", "pyx/graph/axis", "pyx/t1strip", "pyx/pykpathsea"], |
| 194 |
ext_modules=ext_modules, |
116 |
ext_modules=ext_modules, |
| 195 |
data_files=data_files, |
117 |
data_files=data_files, |
| 196 |
cmdclass = {"build_py": pyx_build_py, |
|
|
| 197 |
"install_data": pyx_install_data, |
| 198 |
"install_lib": pyx_install_lib}, |
| 199 |
**addargs) |
118 |
**addargs) |