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 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159
|
#!/usr/bin/env python
# If you didn't know already, this is a Python distutils setup script. It borrows
# heavily from Phatch's (see: http://photobatch.stani.be/).
#
# There's a lot of comments here (on purpose) so people can actually learn from
# this and don't have to figure out everything on their own.
#
# This setup script is used to build distribution specific packages.
#
# For more information see: http://docs.python.org/dist/dist.html
#
# TODO: this all feels just a little too shell scripty, refactoring it later
# might be a good idea.
# NOTES:
# System-wide directories:
# Scalable emblems go in: /usr/share/icons/hicolor/scalable/emblems
#
# User-specific directories:
# Scalable emblems go in: ~/.icons/hicolor/scalable
#
# Common directories
# See: http://standards.freedesktop.org/basedir-spec/basedir-spec-0.6.html
# Configuration information goes in: ~/.config/rabbitvcs/
# Data goes in: ~/.local/share/rabbitvcs
import sys
import os
import os.path
import subprocess
from distutils.core import setup
import distutils.sysconfig
PREFIX = sys.prefix
# If the user passed --prefix=... then use the new prefix
for c in sys.argv:
if c.startswith("--prefix"):
PREFIX = c.split("=")[1].lstrip().rstrip()
#==============================================================================
# Variables
#==============================================================================
# Some descriptive variables
# This will eventually be passed to the setup function, but we already need them
# for doing some other stuff so we have to declare them here.
name = "rabbitvcs"
version = "0.15.0.5"
description = "Easy version control"
long_description = """RabbitVCS is a set of graphical tools written to provide simple and straightforward access to the version control systems you use."""
author = "Bruce van der Kooij"
author_email = "brucevdkooij@gmail.com"
url = "http://www.rabbitvcs.org"
license = "GNU General Public License version 2 or later"
#==============================================================================
# Paths
#==============================================================================
icon_theme_directory = "share/icons/hicolor"
locale_directory = "share/locale"
#==============================================================================
# Helper functions
#==============================================================================
def include_by_pattern(directory, directory_to_install, pattern):
files_to_include = []
for root, dirs, files in os.walk(directory):
for file in files:
if file.endswith(pattern):
files_to_include.append((
root.replace(directory, directory_to_install),
[os.path.join(root, file)]
))
return files_to_include
#==============================================================================
# Gather all the files that need to be included
#==============================================================================
# Packages
packages = []
for root, dirs, files in os.walk("rabbitvcs"):
if "__init__.py" in files:
packages.append(root.replace(os.path.sep, "."))
# Translation
translations = include_by_pattern("locale", locale_directory, ".mo")
# Icons
icons = include_by_pattern("data/icons/hicolor", icon_theme_directory, ".svg")
icons += include_by_pattern("data/icons/hicolor", icon_theme_directory, ".png")
# Config parsing specification
config_spec = [(
"share/rabbitvcs",
["rabbitvcs/util/configspec/configspec.ini"]
)]
# Documentation
documentation = [("share/doc/rabbitvcs", [
"AUTHORS",
"MAINTAINERS"
])]
# Save build information so we can access the prefix later
path = "rabbitvcs/buildinfo.py"
buildinfo = '''rabbitvcs_prefix = "%s"
icon_path = "%s/%s"
''' % (PREFIX, PREFIX, icon_theme_directory)
fh = open(path, "w")
fh.write(buildinfo)
fh.close()
#==============================================================================
# Ready to install
#==============================================================================
# Calling the setup function will actually install RabbitVCS and also creates
# an .egg-info file in /usr/lib/python<version>/site-packages/ or
# /usr/share/python-support/rabbitvcs when generating a Debian package.
dist = setup(
# The following arguments will be included in the .egg.info file,
# for a list of available arguments and their descriptions see:
# - http://docs.python.org/dist/module-distutils.core.html
name=name,
version=version,
description=description,
long_description=long_description,
author=author,
author_email=author_email,
url=url,
license=license,
# There are actually several arguments that are used to install files:
# - py_modules: installs specific modules to site-packages
# - packages: install complete packages (directories with an __init__.py
# file) into site-packages
# - data_files: any file you want, anywhere you want it
packages=packages,
package_data={
"rabbitvcs": [
# Include our GtkBuilder UI files right into the package
"ui/xml/*.xml",
"ui/xml/dialogs/*.xml"
]
},
data_files=translations + icons + documentation + config_spec
)
#
# Post installation
#
# Icon cache rebuilding not needed
|