1 | """Built bbftp embedded in python. |
---|
2 | """ |
---|
3 | |
---|
4 | from distutils.core import setup, Extension, Command |
---|
5 | import sys, os |
---|
6 | |
---|
7 | bbftpd_home = './src/bbftp-server-3.2.0' |
---|
8 | bbftpc_home = './src/bbftp-client-3.2.0' |
---|
9 | # Get the version from ./VERSION |
---|
10 | version = open('./VERSION').read() |
---|
11 | |
---|
12 | |
---|
13 | # Not all *.c files are compiled into *.o files in bbftpd |
---|
14 | bbftpd_src = [ |
---|
15 | 'bbftpd.c', |
---|
16 | 'bbftpd_cd.c', |
---|
17 | 'bbftpd_check.c', |
---|
18 | 'bbftpd_crypt.c', |
---|
19 | 'bbftpd_daemon.c', |
---|
20 | 'bbftpd_list.c', |
---|
21 | 'bbftpd_login.c', |
---|
22 | 'bbftpd_message.c', |
---|
23 | 'bbftpd_mkdir.c', |
---|
24 | 'bbftpd_rm.c', |
---|
25 | 'bbftpd_stat.c', |
---|
26 | 'bbftpd_statfs.c', |
---|
27 | 'bbftpd_readcontrol.c', |
---|
28 | 'bbftpd_retr.c', |
---|
29 | 'bbftpd_signals.c', |
---|
30 | 'bbftpd_socket.c', |
---|
31 | 'bbftpd_store.c', |
---|
32 | 'bbftpd_utils.c', |
---|
33 | 'changetodir.c', |
---|
34 | 'createadir.c', |
---|
35 | 'createreceivesock.c', |
---|
36 | 'readcontrol.c', |
---|
37 | 'sendafile.c', |
---|
38 | 'sendlist.c', |
---|
39 | 'signals_routines.c', |
---|
40 | 'storeafile.c', |
---|
41 | 'bbftpd_private.c', |
---|
42 | 'bbftpd_private_user.c', |
---|
43 | 'bbftpd_private_log.c' |
---|
44 | ] |
---|
45 | |
---|
46 | server_sources = ['%s/bbftpd/%s' % (bbftpd_home, x) for x in bbftpd_src] + ['./src/python_ext/bbftpd.c', |
---|
47 | './src/python_ext/util.c', |
---|
48 | ] |
---|
49 | |
---|
50 | bbftpc_src = [ |
---|
51 | 'bbftp_cd.c', |
---|
52 | 'bbftp_get.c', |
---|
53 | 'bbftp_lcd.c', |
---|
54 | 'bbftp_list.c', |
---|
55 | 'bbftp_mget.c', |
---|
56 | 'bbftp_mkdir.c', |
---|
57 | 'bbftp_mput.c', |
---|
58 | 'bbftp_put.c', |
---|
59 | 'bbftp_rm.c', |
---|
60 | 'bbftp_stat.c', |
---|
61 | 'bbftp_statfs.c', |
---|
62 | 'bbftp_dir.c', |
---|
63 | 'bbftp_retr.c', |
---|
64 | 'bbftp_setremotecos.c', |
---|
65 | 'bbftp_setremoteumask.c', |
---|
66 | 'bbftp_store.c', |
---|
67 | 'bbftp_socket.c', |
---|
68 | 'bbftp_utils.c', |
---|
69 | 'connecttoserver.c', |
---|
70 | 'getdatasock.c', |
---|
71 | 'readmessage.c', |
---|
72 | 'sendproto.c', |
---|
73 | 'treatcommand.c', |
---|
74 | 'bbftp_turl.c', |
---|
75 | 'writemessage.c', |
---|
76 | 'setsignals.c', |
---|
77 | 'bbftp_private.c', |
---|
78 | 'bbftp_private_user.c', |
---|
79 | 'ndg_client.c' |
---|
80 | ] |
---|
81 | |
---|
82 | client_sources = ['%s/bbftpc/%s' % (bbftpc_home, x) for x in bbftpc_src] + ['./src/python_ext/bbftpc.c', |
---|
83 | './src/python_ext/util.c', |
---|
84 | './src/python_ext/bbftpc_main.c'] |
---|
85 | |
---|
86 | #------------------------------------------------------------------------------------------- |
---|
87 | |
---|
88 | class Doc(Command): |
---|
89 | """Build epydoc and doxygen documentation. |
---|
90 | """ |
---|
91 | |
---|
92 | user_options = [] |
---|
93 | |
---|
94 | def initialize_options(self): |
---|
95 | pass |
---|
96 | def finalize_options(self): |
---|
97 | pass |
---|
98 | |
---|
99 | def run(self): |
---|
100 | cmd = ('epydoc -o doc/epydoc -v --docformat javadoc ' |
---|
101 | '--name "NDG Delivery Service" build/lib*/pybbftp/') |
---|
102 | self.execute(os.system, (cmd,)) |
---|
103 | self.execute(os.system, ('doxygen',)) |
---|
104 | |
---|
105 | from distutils.command.build import build |
---|
106 | |
---|
107 | class MyBuild(build): |
---|
108 | def run(self): |
---|
109 | self.execute(os.system, ('make -C src',)) |
---|
110 | build.run(self) |
---|
111 | |
---|
112 | #------------------------------------------------------------------------------------------- |
---|
113 | |
---|
114 | |
---|
115 | |
---|
116 | |
---|
117 | |
---|
118 | |
---|
119 | |
---|
120 | |
---|
121 | bbftpd = Extension('pybbftp.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('pybbftp.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 = 'bbftp-python', |
---|
146 | version = version, |
---|
147 | description = 'Embedded bbftp server', |
---|
148 | author = 'Stephen Pascoe', |
---|
149 | author_email = 'S.Pascoe@rl.ac.uk', |
---|
150 | package_dir = {'': 'lib/python'}, |
---|
151 | packages = ['pybbftp'], |
---|
152 | scripts=['examples/deliveryd.py', 'examples/deliveryclient.py'], |
---|
153 | ext_modules = [ |
---|
154 | bbftpd, |
---|
155 | bbftpc], |
---|
156 | cmdclass = {'doc': Doc, 'build': MyBuild} |
---|
157 | ) |
---|
158 | |
---|