417 |
|
|
418 |
user_options = [ |
user_options = [ |
419 |
('skip-build', None, "skip the build steps"), |
('skip-build', None, "skip the build steps"), |
420 |
|
('create-init-module', None, |
421 |
|
"Create the thubaninit.py module to ease use of Thuban as a library"), |
422 |
|
('dont-create-init-module', None, |
423 |
|
"Do not create the thubaninit.py module"), |
424 |
] |
] |
425 |
|
|
426 |
|
boolean_options = ["create-init-module"] |
427 |
|
negative_opt = {'dont-create-init-module' : 'create-init-module'} |
428 |
|
|
429 |
|
|
430 |
def initialize_options (self): |
def initialize_options (self): |
431 |
self.extensions = None |
self.extensions = None |
432 |
self.build_dir = None |
self.build_dir = None |
433 |
self.skip_build = None |
self.skip_build = None |
434 |
|
self.create_init_module = None |
435 |
|
|
436 |
def finalize_options (self): |
def finalize_options (self): |
437 |
self.set_undefined_options("install", |
self.set_undefined_options("install", |
438 |
("build_lib", "build_dir"), |
("build_lib", "build_dir"), |
439 |
('skip_build', 'skip_build')) |
('skip_build', 'skip_build')) |
440 |
self.extensions = self.distribution.ext_modules |
self.extensions = self.distribution.ext_modules |
441 |
|
if self.create_init_module is None: |
442 |
|
# by default we create the init module |
443 |
|
self.create_init_module = 1 |
444 |
|
|
445 |
def run(self): |
def run(self): |
446 |
# Make sure we have built everything we need first |
# Make sure we have built everything we need first |
454 |
else: |
else: |
455 |
self.copy_tree(libdir, "Lib") |
self.copy_tree(libdir, "Lib") |
456 |
|
|
457 |
|
# create the init module if desired |
458 |
|
if self.create_init_module: |
459 |
|
# create the init module |
460 |
|
initfilename = "thubaninit.py" |
461 |
|
contents = thubaninit_contents("") |
462 |
|
self.execute(write_file, (initfilename, contents), |
463 |
|
"Create %s" % initfilename) |
464 |
|
|
465 |
def link_dir(self, src, dest): |
def link_dir(self, src, dest): |
466 |
"""Create a symbolic link dest pointing to src""" |
"""Create a symbolic link dest pointing to src""" |
467 |
if self.verbose: |
if self.verbose: |
539 |
return modules |
return modules |
540 |
|
|
541 |
|
|
542 |
thubaninit_contents = """ |
thubaninit_contents_start = """ |
543 |
# This module was automatically generated by Thuban's install script |
# This module was automatically generated by Thuban's install script |
544 |
'''Import this module once per program (best place is probably the file |
'''Import this module once per program (best place is probably the file |
545 |
that ends up as your __main__ module) to be able to import Thuban |
that ends up as your __main__ module) to be able to import Thuban |
551 |
import Thuban |
import Thuban |
552 |
''' |
''' |
553 |
import sys, os |
import sys, os |
554 |
sys.path.insert(0, %(thubandir)s) |
""" |
555 |
|
|
556 |
|
thubaninit_contents_thubaninitdir = """ |
557 |
|
sys.path.insert(0, %(thubandir)s) |
558 |
|
""" |
559 |
|
thubaninit_contents_otherdirs = """ |
560 |
# Put the Lib dir into the path. The Lib dir contains some extra Python |
# Put the Lib dir into the path. The Lib dir contains some extra Python |
561 |
# modules |
# modules |
562 |
import Thuban |
import Thuban |
566 |
sys.path.insert(0, dir) |
sys.path.insert(0, dir) |
567 |
""" |
""" |
568 |
|
|
569 |
|
def thubaninit_contents(thubandir): |
570 |
|
"""Return the contents of the the thubaninit file as a list of lines. |
571 |
|
|
572 |
|
The parameter thubandir is the parent directory where the Thuban/ |
573 |
|
package or the empty string if the thubaninit file itself will be |
574 |
|
located in that direcory as well. |
575 |
|
""" |
576 |
|
contents = thubaninit_contents_start |
577 |
|
if thubandir: |
578 |
|
thubandir = repr(thubandir) |
579 |
|
contents += thubaninit_contents_thubaninitdir % locals() |
580 |
|
contents += thubaninit_contents_otherdirs |
581 |
|
return contents.split("\n") |
582 |
|
|
583 |
|
|
584 |
class ThubanInstall(install): |
class ThubanInstall(install): |
585 |
|
|
607 |
("init-module-dir=", None, |
("init-module-dir=", None, |
608 |
"Directory in which to create the init module." |
"Directory in which to create the init module." |
609 |
" Defaults to Python's site-packages directory."), |
" Defaults to Python's site-packages directory."), |
|
|
|
610 |
]) |
]) |
611 |
|
|
612 |
boolean_options = install.boolean_options[:] |
boolean_options = install.boolean_options[:] |
671 |
src, dest = item |
src, dest = item |
672 |
else: |
else: |
673 |
src = dest = item |
src = dest = item |
674 |
self.copy_file(convert_path(src), |
self.copy_file(convert_path(src), |
675 |
os.path.join(self.root, convert_path(dest))) |
os.path.join(self.root, convert_path(dest))) |
676 |
|
|
677 |
if os.name == "posix" and self.do_symlink: |
if os.name == "posix" and self.do_symlink: |
691 |
initfilename = self.thuban_init_filename() |
initfilename = self.thuban_init_filename() |
692 |
if self.root: |
if self.root: |
693 |
initfilename = change_root(self.root, initfilename) |
initfilename = change_root(self.root, initfilename) |
694 |
contents = thubaninit_contents % { |
contents = thubaninit_contents(self.install_lib_orig) |
|
"thubandir": repr(self.install_lib_orig) |
|
|
} |
|
695 |
self.mkpath(os.path.dirname(initfilename)) |
self.mkpath(os.path.dirname(initfilename)) |
696 |
self.execute(write_file, (initfilename, split(contents, "\n")), |
self.execute(write_file, (initfilename, contents), |
697 |
"Create %s" % initfilename) |
"Create %s" % initfilename) |
698 |
|
|
699 |
def link_file(self, src, dest): |
def link_file(self, src, dest): |
753 |
--prefix=%(prefix)s |
--prefix=%(prefix)s |
754 |
''' |
''' |
755 |
|
|
756 |
|
|
757 |
class thuban_bdist_rpm(bdist_rpm): |
class thuban_bdist_rpm(bdist_rpm): |
758 |
|
|
759 |
"""Thuban specific RPM distribution command""" |
"""Thuban specific RPM distribution command""" |
887 |
self.execute(write_file, (iss_file, self.generate_iss()), |
self.execute(write_file, (iss_file, self.generate_iss()), |
888 |
"Create Inno Setup script file %s" % iss_file) |
"Create Inno Setup script file %s" % iss_file) |
889 |
|
|
890 |
# and invoke |
# and invoke |
891 |
if self.run_inno: |
if self.run_inno: |
892 |
self.spawn(["iscc", iss_file]) |
self.spawn(["iscc", iss_file]) |
893 |
|
|
953 |
line = 'Name: "{group}\\%s"; Filename: "%s";' \ |
line = 'Name: "{group}\\%s"; Filename: "%s";' \ |
954 |
% (icon.title, icon.install_name) |
% (icon.title, icon.install_name) |
955 |
iss.append(line) |
iss.append(line) |
956 |
|
|
957 |
return iss |
return iss |
958 |
|
|
959 |
|
|
969 |
else: |
else: |
970 |
self.install_name = filename |
self.install_name = filename |
971 |
|
|
972 |
|
|
973 |
class thuban_bdist_inno(bdist_inno): |
class thuban_bdist_inno(bdist_inno): |
974 |
|
|
975 |
"""Thuban specific Inno Setup stuff""" |
"""Thuban specific Inno Setup stuff""" |
985 |
# that we can generate the iss-file even on Linux |
# that we can generate the iss-file even on Linux |
986 |
install_options["do_symlink"] = 0 |
install_options["do_symlink"] = 0 |
987 |
bdist_inno.run(self, install_options) |
bdist_inno.run(self, install_options) |
988 |
|
|
989 |
|
|
990 |
# |
# |
991 |
# Run the script |
# Run the script |
992 |
# |
# |
997 |
""" |
""" |
998 |
|
|
999 |
setup(name = "Thuban", |
setup(name = "Thuban", |
1000 |
version = "0.1.3cvs", |
version = "0.1.3", |
1001 |
description = "Geographic data viewer", |
description = "Geographic data viewer", |
1002 |
long_description = long_description, |
long_description = long_description, |
1003 |
licence = "GPL", |
licence = "GPL", |