]> git.lizzy.rs Git - torbrowser-launcher.git/blob - setup.py
Allow url_list
[torbrowser-launcher.git] / setup.py
1 """
2 Tor Browser Launcher
3 https://github.com/micahflee/torbrowser-launcher/
4
5 Copyright (c) 2013-2017 Micah Lee <micah@micahflee.com>
6
7 Permission is hereby granted, free of charge, to any person
8 obtaining a copy of this software and associated documentation
9 files (the "Software"), to deal in the Software without
10 restriction, including without limitation the rights to use,
11 copy, modify, merge, publish, distribute, sublicense, and/or sell
12 copies of the Software, and to permit persons to whom the
13 Software is furnished to do so, subject to the following
14 conditions:
15
16 The above copyright notice and this permission notice shall be
17 included in all copies or substantial portions of the Software.
18
19 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
20 EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
21 OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
22 NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
23 HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
24 WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
25 FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
26 OTHER DEALINGS IN THE SOFTWARE.
27 """
28
29 import os
30 import sys
31 import distro
32 import subprocess
33 from distutils.core import setup
34
35 SHARE = "share"
36
37 # detect linux distribution
38 distro = distro.linux_distribution()[0]
39
40
41 def file_list(path):
42     files = []
43     for filename in os.listdir(path):
44         if os.path.isfile(path + "/" + filename):
45             files.append(path + "/" + filename)
46     return files
47
48
49 def create_mo_files():
50     po_dir = "po/"
51     if not os.path.exists(po_dir):
52         return []
53     domain = "torbrowser-launcher"
54     mo_files = []
55     po_files = sorted(
56         [f for f in next(os.walk(po_dir))[2] if os.path.splitext(f)[1] == ".po"]
57     )
58     for po_file in po_files:
59         filename, extension = os.path.splitext(po_file)
60         mo_file = domain + ".mo"
61         mo_dir = "share/locale/" + filename + "/LC_MESSAGES/"
62         subprocess.call("mkdir -p " + mo_dir, shell=True)
63         msgfmt_cmd = "msgfmt {} -o {}".format(po_dir + po_file, mo_dir + mo_file)
64         subprocess.call(msgfmt_cmd, shell=True)
65         mo_files.append(mo_dir + mo_file)
66     return mo_files
67
68
69 with open(os.path.join(SHARE, "torbrowser-launcher/version")) as buf:
70     version = buf.read().strip()
71
72 datafiles = []
73 for root, dirs, files in os.walk(SHARE):
74     if files:
75         datafiles.append((root, [os.path.join(root, f) for f in files]))
76
77 # disable shipping apparmor profiles until they work in ubuntu (#128)
78 if distro != "Ubuntu":
79     if not hasattr(sys, "real_prefix"):
80         # we're not in a virtualenv, so we can probably write to /etc
81         datafiles += [
82             (
83                 "/etc/apparmor.d/",
84                 ["apparmor/torbrowser.Browser.firefox", "apparmor/torbrowser.Tor.tor"],
85             ),
86             (
87                 "/etc/apparmor.d/local/",
88                 [
89                     "apparmor/local/torbrowser.Browser.firefox",
90                     "apparmor/local/torbrowser.Tor.tor",
91                 ],
92             ),
93             ("/etc/apparmor.d/tunables/", ["apparmor/tunables/torbrowser"]),
94         ]
95
96 datafiles += [(os.path.dirname(f), [f]) for f in create_mo_files()]
97
98 setup(
99     name="torbrowser-launcher",
100     version=version,
101     author="Micah Lee",
102     author_email="micah@micahflee.com",
103     url="https://www.github.com/micahflee/torbrowser-launcher",
104     platforms=["GNU/Linux"],
105     license="MIT",
106     description="A program to help you securely download and run Tor Browser",
107     long_description="""
108 Tor Browser Launcher is intended to make Tor Browser easier to install and use
109 for GNU/Linux users. You install torbrowser-launcher from your distribution's
110 package manager and it handles securely downloading the most recent version of
111 Tor Browser for you, in your language and for your architecture. It also adds a
112 "Tor Browser" application launcher to your operating system's menu. When you
113 first launch Tor Browser Launcher, it will download Tor Browser from
114 https://www.torproject.org/, verify the PGP signature, extract it in your home
115 directory, and launch it. When you run it after that it will just launch Tor
116 Browser.
117 """,
118     packages=["torbrowser_launcher"],
119     scripts=["torbrowser-launcher"],
120     data_files=datafiles,
121     install_requires=[
122         'gpg',
123         'packaging',
124         'PyQt5',
125         'requests',
126         'PySocks',
127     ],
128 )