1 |
# Copyright (c) 2001 by Intevation GmbH |
# Copyright (c) 2001, 2002 by Intevation GmbH |
2 |
# Authors: |
# Authors: |
3 |
# Bernhard Herzog <[email protected]> |
# Bernhard Herzog <[email protected]> |
4 |
# |
# |
22 |
from distutils.command.build_py import build_py |
from distutils.command.build_py import build_py |
23 |
from distutils.command.bdist_rpm import bdist_rpm |
from distutils.command.bdist_rpm import bdist_rpm |
24 |
from distutils.file_util import write_file |
from distutils.file_util import write_file |
25 |
|
from distutils.filelist import FileList |
26 |
from distutils.util import convert_path, change_root |
from distutils.util import convert_path, change_root |
27 |
|
|
28 |
|
from distutils import archive_util, dir_util |
29 |
import distutils |
import distutils |
30 |
|
|
31 |
from string import split |
from string import split |
200 |
# |
# |
201 |
|
|
202 |
extensions.append(Extension("Lib.wxproj", |
extensions.append(Extension("Lib.wxproj", |
203 |
[ext_dir + "/thuban/wxproj.cpp", |
[ext_dir + "/thuban/wxproj.cpp"], |
204 |
shp_dir + "/shpopen.c"], |
include_dirs = ([shp_dir, proj4_incdir, |
205 |
include_dirs = [shp_dir, proj4_incdir] +wx_incdirs, |
ext_dir + "/pyshapelib/"] |
206 |
|
+ wx_incdirs), |
207 |
define_macros = wx_defs, |
define_macros = wx_defs, |
208 |
library_dirs = [proj4_libdir] + wx_libdirs, |
library_dirs = [proj4_libdir] + wx_libdirs, |
209 |
libraries = [proj4_lib] + wx_libs)) |
libraries = [proj4_lib] + wx_libs)) |
214 |
|
|
215 |
extensions.append(Extension("Lib.shapelibc", |
extensions.append(Extension("Lib.shapelibc", |
216 |
[ext_dir + "/pyshapelib/shapelib_wrap.c", |
[ext_dir + "/pyshapelib/shapelib_wrap.c", |
217 |
shp_dir + "/shpopen.c"], |
shp_dir + "/shpopen.c", |
218 |
|
shp_dir + "/shptree.c"], |
219 |
|
include_dirs = [shp_dir])) |
220 |
|
extensions.append(Extension("Lib.shptree", |
221 |
|
[ext_dir + "/pyshapelib/shptreemodule.c"], |
222 |
include_dirs = [shp_dir])) |
include_dirs = [shp_dir])) |
223 |
extensions.append(Extension("Lib.dbflibc", |
extensions.append(Extension("Lib.dbflibc", |
224 |
[ext_dir + "/pyshapelib/dbflib_wrap.c", |
[ext_dir + "/pyshapelib/dbflib_wrap.c", |
257 |
# |
# |
258 |
# So far distutils are only meant to distribute python extensions, not |
# So far distutils are only meant to distribute python extensions, not |
259 |
# complete applications, so we have to redefine a few commands |
# complete applications, so we have to redefine a few commands |
260 |
|
# |
261 |
|
|
262 |
|
|
263 |
|
# Much of the data_dist command is directly copied from the distutils' |
264 |
|
# sdist command |
265 |
|
class data_dist(Command): |
266 |
|
|
267 |
|
description = "create a data distribution (tarball, zip file, etc.)" |
268 |
|
|
269 |
|
user_options = [ |
270 |
|
('formats=', None, |
271 |
|
"formats for source distribution (comma-separated list)"), |
272 |
|
('keep-temp', 'k', |
273 |
|
"keep the distribution tree around after creating " + |
274 |
|
"archive file(s)"), |
275 |
|
('dist-dir=', 'd', |
276 |
|
"directory to put the source distribution archive(s) in " |
277 |
|
"[default: dist]"), |
278 |
|
] |
279 |
|
|
280 |
|
boolean_options = ['keep-temp'] |
281 |
|
|
282 |
|
def initialize_options (self): |
283 |
|
self.formats = None |
284 |
|
self.keep_temp = 0 |
285 |
|
self.dist_dir = None |
286 |
|
|
287 |
|
def finalize_options (self): |
288 |
|
self.ensure_string_list('formats') |
289 |
|
if self.formats is None: |
290 |
|
self.formats = ["zip"] |
291 |
|
bad_format = archive_util.check_archive_formats(self.formats) |
292 |
|
if bad_format: |
293 |
|
raise DistutilsOptionError, \ |
294 |
|
"unknown archive format '%s'" % bad_format |
295 |
|
|
296 |
|
if self.dist_dir is None: |
297 |
|
self.dist_dir = "dist" |
298 |
|
|
299 |
|
|
300 |
|
def run(self): |
301 |
|
# 'filelist' contains the list of files that will make up the |
302 |
|
# manifest |
303 |
|
self.filelist = FileList() |
304 |
|
|
305 |
|
# Do whatever it takes to get the list of files to process. |
306 |
|
# File list is accumulated in 'self.filelist'. |
307 |
|
self.get_file_list() |
308 |
|
|
309 |
|
# Otherwise, go ahead and create the source distribution tarball, |
310 |
|
# or zipfile, or whatever. |
311 |
|
self.make_distribution() |
312 |
|
|
313 |
|
def get_file_list(self): |
314 |
|
"""Figure out the list of files to include in the data |
315 |
|
distribution, and put it in 'self.filelist'. |
316 |
|
""" |
317 |
|
self.filelist.findall("Data") |
318 |
|
self.filelist.include_pattern("*", anchor = 0) |
319 |
|
self.filelist.exclude_pattern(r'/(RCS|CVS)/.*', is_regex=1) |
320 |
|
self.filelist.sort() |
321 |
|
self.filelist.remove_duplicates() |
322 |
|
|
323 |
|
def make_release_tree(self, base_dir, files): |
324 |
|
"""Create the directory tree that will become the source |
325 |
|
distribution archive. All directories implied by the filenames in |
326 |
|
'files' are created under 'base_dir', and then we hard link or copy |
327 |
|
(if hard linking is unavailable) those files into place. |
328 |
|
Essentially, this duplicates the developer's source tree, but in a |
329 |
|
directory named after the distribution, containing only the files |
330 |
|
to be distributed. |
331 |
|
""" |
332 |
|
# Create all the directories under 'base_dir' necessary to |
333 |
|
# put 'files' there; the 'mkpath()' is just so we don't die |
334 |
|
# if the manifest happens to be empty. |
335 |
|
self.mkpath(base_dir) |
336 |
|
dir_util.create_tree(base_dir, files, |
337 |
|
verbose=self.verbose, dry_run=self.dry_run) |
338 |
|
|
339 |
|
# And walk over the list of files, either making a hard link (if |
340 |
|
# os.link exists) to each one that doesn't already exist in its |
341 |
|
# corresponding location under 'base_dir', or copying each file |
342 |
|
# that's out-of-date in 'base_dir'. (Usually, all files will be |
343 |
|
# out-of-date, because by default we blow away 'base_dir' when |
344 |
|
# we're done making the distribution archives.) |
345 |
|
|
346 |
|
if hasattr(os, 'link'): # can make hard links on this system |
347 |
|
link = 'hard' |
348 |
|
msg = "making hard links in %s..." % base_dir |
349 |
|
else: # nope, have to copy |
350 |
|
link = None |
351 |
|
msg = "copying files to %s..." % base_dir |
352 |
|
|
353 |
|
if not files: |
354 |
|
self.warn("no files to distribute -- empty manifest?") |
355 |
|
else: |
356 |
|
self.announce(msg) |
357 |
|
for file in files: |
358 |
|
if not os.path.isfile(file): |
359 |
|
self.warn("'%s' not a regular file -- skipping" % file) |
360 |
|
else: |
361 |
|
dest = os.path.join(base_dir, file) |
362 |
|
self.copy_file(file, dest, link=link) |
363 |
|
|
364 |
|
|
365 |
|
def make_distribution (self): |
366 |
|
"""Create the source distribution(s). First, we create the release |
367 |
|
tree with 'make_release_tree()'; then, we create all required |
368 |
|
archive files (according to 'self.formats') from the release tree. |
369 |
|
Finally, we clean up by blowing away the release tree (unless |
370 |
|
'self.keep_temp' is true). The list of archive files created is |
371 |
|
stored so it can be retrieved later by 'get_archive_files()'. |
372 |
|
""" |
373 |
|
# Don't warn about missing meta-data here -- should be (and is!) |
374 |
|
# done elsewhere. |
375 |
|
base_dir = "Thuban-data-" + self.distribution.get_version() |
376 |
|
base_name = os.path.join(self.dist_dir, base_dir) |
377 |
|
|
378 |
|
self.make_release_tree(base_dir, self.filelist.files) |
379 |
|
archive_files = [] # remember names of files we create |
380 |
|
for fmt in self.formats: |
381 |
|
file = self.make_archive(base_name, fmt, base_dir=base_dir) |
382 |
|
archive_files.append(file) |
383 |
|
|
384 |
|
self.archive_files = archive_files |
385 |
|
|
386 |
|
if not self.keep_temp: |
387 |
|
dir_util.remove_tree(base_dir, self.verbose, self.dry_run) |
388 |
|
|
389 |
|
|
390 |
|
|
397 |
""" |
""" |
398 |
|
|
399 |
description =\ |
description =\ |
400 |
"Create some symlink so you can run thubanfrom the source directory" |
"Create some symlinks so you can run thuban from the source directory" |
401 |
|
|
402 |
user_options = [ |
user_options = [ |
403 |
('skip-build', None, "skip the build steps"), |
('skip-build', None, "skip the build steps"), |
421 |
# now do the work. Simply link or copy the Lib dir |
# now do the work. Simply link or copy the Lib dir |
422 |
libdir = os.path.join(self.build_dir, "Lib") |
libdir = os.path.join(self.build_dir, "Lib") |
423 |
if os.name == "posix": |
if os.name == "posix": |
424 |
# on posix, just lilnk the Lib dir |
# on posix, just link the Lib dir |
425 |
self.link_dir(libdir, "Lib") |
self.link_dir(libdir, "Lib") |
426 |
else: |
else: |
427 |
self.copy_tree(libdir, "Lib") |
self.copy_tree(libdir, "Lib") |
607 |
|
|
608 |
"""Thuban specific RPM distribution command""" |
"""Thuban specific RPM distribution command""" |
609 |
|
|
610 |
def run(self): |
def initialize_options(self): |
611 |
# create the prep script for the spec-file |
# create the prep script for the spec-file |
612 |
open("bdist_rpm_prep", "w").write(bdist_rpm_prep_script) |
open("bdist_rpm_prep", "w").write(bdist_rpm_prep_script) |
613 |
|
|
614 |
bdist_rpm.run(self) |
bdist_rpm.initialize_options(self) |
615 |
|
|
616 |
|
|
617 |
class bdist_inno(Command): |
class bdist_inno(Command): |
705 |
if os.name != 'nt': |
if os.name != 'nt': |
706 |
# Must force install to use the 'nt' scheme; |
# Must force install to use the 'nt' scheme; |
707 |
install.select_scheme('nt') |
install.select_scheme('nt') |
|
# don't make a symlink because we're simulating windows, so |
|
|
# that we can generate the iss-file even on Linux |
|
|
install.do_symlink = 0 |
|
708 |
|
|
709 |
self.announce("installing to %s" % self.bdist_dir) |
self.announce("installing to %s" % self.bdist_dir) |
710 |
install.ensure_finalized() |
install.ensure_finalized() |
787 |
|
|
788 |
class InnoIconItem: |
class InnoIconItem: |
789 |
|
|
790 |
"""Describe one item for he start menu for the Inno Setup installer""" |
"""Describe one item for the start menu for the Inno Setup installer""" |
791 |
|
|
792 |
def __init__(self, filename, title, install_name = None): |
def __init__(self, filename, title, install_name = None): |
793 |
self.filename = filename |
self.filename = filename |
797 |
else: |
else: |
798 |
self.install_name = filename |
self.install_name = filename |
799 |
|
|
800 |
|
|
801 |
class thuban_bdist_inno(bdist_inno): |
class thuban_bdist_inno(bdist_inno): |
802 |
|
|
803 |
"""Thuban specific Inno Setup stuff""" |
"""Thuban specific Inno Setup stuff""" |
809 |
"warn_dir": 0, |
"warn_dir": 0, |
810 |
"extra_files": ["COPYING", "Lib/proj.dll"], |
"extra_files": ["COPYING", "Lib/proj.dll"], |
811 |
} |
} |
812 |
|
# don't make a symlink because we're simulating windows, so |
813 |
|
# that we can generate the iss-file even on Linux |
814 |
|
install_options["do_symlink"] = 0 |
815 |
bdist_inno.run(self, install_options) |
bdist_inno.run(self, install_options) |
816 |
|
|
817 |
|
|
825 |
""" |
""" |
826 |
|
|
827 |
setup(name = "Thuban", |
setup(name = "Thuban", |
828 |
version = "0.0.3", |
version = "0.1.2", |
829 |
description = "Geographic data viewer", |
description = "Geographic data viewer", |
830 |
long_description = long_description, |
long_description = long_description, |
831 |
licence = "GPL", |
licence = "GPL", |
845 |
{"prefix": prefix, |
{"prefix": prefix, |
846 |
# make sure both libs and scripts are installed in the |
# make sure both libs and scripts are installed in the |
847 |
# same directory. |
# same directory. |
848 |
"install_lib": "$base/thuban", |
"install_lib": "$base/lib/thuban", |
849 |
"install_scripts": "$base/thuban", |
"install_scripts": "$base/lib/thuban", |
850 |
"install_data": "$base/thuban", |
"install_data": "$base/lib/thuban", |
851 |
|
|
852 |
# Don't print warning messages about the lib dir not |
# Don't print warning messages about the lib dir not |
853 |
# being on Python's path. The libraries are Thuban |
# being on Python's path. The libraries are Thuban |
866 |
"install_local": InstallLocal, |
"install_local": InstallLocal, |
867 |
"install": ThubanInstall, |
"install": ThubanInstall, |
868 |
"bdist_rpm": thuban_bdist_rpm, |
"bdist_rpm": thuban_bdist_rpm, |
869 |
"bdist_inno": thuban_bdist_inno |
"bdist_inno": thuban_bdist_inno, |
870 |
|
"data_dist": data_dist |
871 |
}) |
}) |
872 |
|
|
873 |
|
|