1 | """Built bbftp embedded in python. |
---|
2 | """ |
---|
3 | |
---|
4 | import ez_setup |
---|
5 | ez_setup.use_setuptools() |
---|
6 | |
---|
7 | from setuptools import setup, Extension, Command |
---|
8 | import sys, os |
---|
9 | |
---|
10 | bbftpd_home = './src/bbftp-server-3.2.0' |
---|
11 | bbftpc_home = './src/bbftp-client-3.2.0' |
---|
12 | # Get the version from ./VERSION |
---|
13 | version = open('./VERSION').read() |
---|
14 | |
---|
15 | |
---|
16 | # Not all *.c files are compiled into *.o files in bbftpd |
---|
17 | bbftpd_src = [ |
---|
18 | 'bbftpd.c', |
---|
19 | 'bbftpd_cd.c', |
---|
20 | 'bbftpd_check.c', |
---|
21 | 'bbftpd_crypt.c', |
---|
22 | 'bbftpd_daemon.c', |
---|
23 | 'bbftpd_list.c', |
---|
24 | 'bbftpd_login.c', |
---|
25 | 'bbftpd_message.c', |
---|
26 | 'bbftpd_mkdir.c', |
---|
27 | 'bbftpd_rm.c', |
---|
28 | 'bbftpd_stat.c', |
---|
29 | 'bbftpd_statfs.c', |
---|
30 | 'bbftpd_readcontrol.c', |
---|
31 | 'bbftpd_retr.c', |
---|
32 | 'bbftpd_signals.c', |
---|
33 | 'bbftpd_socket.c', |
---|
34 | 'bbftpd_store.c', |
---|
35 | 'bbftpd_utils.c', |
---|
36 | 'changetodir.c', |
---|
37 | 'createadir.c', |
---|
38 | 'createreceivesock.c', |
---|
39 | 'readcontrol.c', |
---|
40 | 'sendafile.c', |
---|
41 | 'sendlist.c', |
---|
42 | 'signals_routines.c', |
---|
43 | 'storeafile.c', |
---|
44 | 'bbftpd_private.c', |
---|
45 | 'bbftpd_private_user.c', |
---|
46 | 'bbftpd_private_log.c', |
---|
47 | 'bbftpd_private_fork.c' |
---|
48 | ] |
---|
49 | |
---|
50 | server_sources = ['%s/bbftpd/%s' % (bbftpd_home, x) for x in bbftpd_src] + ['./src/python_ext/bbftpd.c', |
---|
51 | './src/python_ext/util.c', |
---|
52 | ] |
---|
53 | |
---|
54 | bbftpc_src = [ |
---|
55 | 'bbftp_cd.c', |
---|
56 | 'bbftp_get.c', |
---|
57 | 'bbftp_lcd.c', |
---|
58 | 'bbftp_list.c', |
---|
59 | 'bbftp_mget.c', |
---|
60 | 'bbftp_mkdir.c', |
---|
61 | 'bbftp_mput.c', |
---|
62 | 'bbftp_put.c', |
---|
63 | 'bbftp_rm.c', |
---|
64 | 'bbftp_stat.c', |
---|
65 | 'bbftp_statfs.c', |
---|
66 | 'bbftp_dir.c', |
---|
67 | 'bbftp_retr.c', |
---|
68 | 'bbftp_setremotecos.c', |
---|
69 | 'bbftp_setremoteumask.c', |
---|
70 | 'bbftp_store.c', |
---|
71 | 'bbftp_socket.c', |
---|
72 | 'bbftp_utils.c', |
---|
73 | 'connecttoserver.c', |
---|
74 | 'getdatasock.c', |
---|
75 | 'readmessage.c', |
---|
76 | 'sendproto.c', |
---|
77 | 'treatcommand.c', |
---|
78 | 'bbftp_turl.c', |
---|
79 | 'writemessage.c', |
---|
80 | 'setsignals.c', |
---|
81 | 'bbftp_private.c', |
---|
82 | 'bbftp_private_user.c', |
---|
83 | 'ndg_client.c' |
---|
84 | ] |
---|
85 | |
---|
86 | client_sources = ['%s/bbftpc/%s' % (bbftpc_home, x) for x in bbftpc_src] + ['./src/python_ext/bbftpc.c', |
---|
87 | './src/python_ext/util.c', |
---|
88 | './src/python_ext/bbftpc_main.c'] |
---|
89 | |
---|
90 | #------------------------------------------------------------------------------------------- |
---|
91 | |
---|
92 | class Doc(Command): |
---|
93 | """Build epydoc and doxygen documentation. |
---|
94 | """ |
---|
95 | |
---|
96 | user_options = [] |
---|
97 | |
---|
98 | def initialize_options(self): |
---|
99 | pass |
---|
100 | def finalize_options(self): |
---|
101 | pass |
---|
102 | |
---|
103 | def run(self): |
---|
104 | cmd = ('epydoc -o doc/epydoc -v --docformat javadoc ' |
---|
105 | '--name "NDG Delivery Service" build/lib*/pybbftp/') |
---|
106 | self.execute(os.system, (cmd,)) |
---|
107 | self.execute(os.system, ('doxygen',)) |
---|
108 | |
---|
109 | from setuptools.command.bdist_egg import bdist_egg |
---|
110 | |
---|
111 | class MyBuild(bdist_egg): |
---|
112 | def run(self): |
---|
113 | # We make the stand-alone client/server here for 2 reasons: The source must be |
---|
114 | # configured by the respective bbftp configure scripts and some test cases use |
---|
115 | # the stand-alone client. |
---|
116 | self.spawn(['make', '-C', 'src']) |
---|
117 | bdist_egg.run(self) |
---|
118 | |
---|
119 | #------------------------------------------------------------------------------------------- |
---|
120 | |
---|
121 | bbftpd = Extension('ndg.delivery.server.bbftpd', |
---|
122 | define_macros = [('NDG_AUTH', 1), |
---|
123 | ('LOCAL_SYSLOG_FACILITY', 1), |
---|
124 | ('_LARGEFILE64_SOURCE', 1), |
---|
125 | ('_FILE_OFFSET_BITS', 64), |
---|
126 | ('NDG_PYTHON_EMBED', 1), |
---|
127 | ('PRIVATE_LOGGING', 1), |
---|
128 | ('NDG_DELIVERY_VERSION', version)], |
---|
129 | include_dirs = [bbftpd_home+'/includes', bbftpd_home+'/bbftpd'], |
---|
130 | libraries = ['crypt', 'crypto'], |
---|
131 | extra_compile_args = ["-O1", "-Wno-strict-prototypes"], |
---|
132 | sources = server_sources) |
---|
133 | |
---|
134 | bbftpc = Extension('ndg.delivery.client.bbftpc', |
---|
135 | define_macros = [('NDG_AUTH', 1), ('LOCAL_SYSLOG_FACILITY', 1), |
---|
136 | ('_LARGEFILE64_SOURCE', 1), |
---|
137 | ('_FILE_OFFSET_BITS', 64), |
---|
138 | ('NDG_PYTHON_EMBED', 1), |
---|
139 | ('NDG_DELIVERY_VERSION', version)], |
---|
140 | include_dirs = [bbftpc_home+'/includes', bbftpc_home+'/bbftpc'], |
---|
141 | libraries = ['crypt', 'crypto'], |
---|
142 | extra_compile_args = ["-O1", "-Wno-strict-prototypes"], |
---|
143 | sources = client_sources) |
---|
144 | |
---|
145 | setup(name = 'ndg_delivery_server', |
---|
146 | version = version, |
---|
147 | description = 'Embedded bbftp server', |
---|
148 | author = 'Stephen Pascoe', |
---|
149 | author_email = 'S.Pascoe@rl.ac.uk', |
---|
150 | |
---|
151 | zip_safe = True, |
---|
152 | install_requires = ['setuptools'], |
---|
153 | |
---|
154 | packages = ['ndg', 'ndg.delivery', 'ndg.delivery.server'], |
---|
155 | namespace_packages = ['ndg', 'ndg.delivery'], |
---|
156 | package_dir = {'': 'lib/python'}, |
---|
157 | scripts=['examples/deliveryd.py'], |
---|
158 | ext_modules = [bbftpd], |
---|
159 | cmdclass = {'doc': Doc, 'bdist_egg': MyBuild} |
---|
160 | ) |
---|
161 | |
---|
162 | setup(name = 'ndg_delivery_client', |
---|
163 | version = version, |
---|
164 | description = 'Embedded bbftp client', |
---|
165 | author = 'Stephen Pascoe', |
---|
166 | author_email = 'S.Pascoe@rl.ac.uk', |
---|
167 | |
---|
168 | zip_safe = True, |
---|
169 | install_requires = ['setuptools'], |
---|
170 | |
---|
171 | packages = ['ndg', 'ndg.delivery', 'ndg.delivery.client'], |
---|
172 | namespace_packages = ['ndg', 'ndg.delivery'], |
---|
173 | package_dir = {'': 'lib/python'}, |
---|
174 | scripts=['examples/deliveryclient.py'], |
---|
175 | ext_modules = [bbftpc], |
---|
176 | cmdclass = {'doc': Doc, 'bdist_egg': MyBuild} |
---|
177 | ) |
---|