-
Notifications
You must be signed in to change notification settings - Fork 27
/
Copy pathsetup.py
executable file
·123 lines (109 loc) · 4.04 KB
/
setup.py
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
#!/usr/bin/env python
## Copyright (C) 2002, 2005, 2006, 2007, 2008, 2010, 2011, 2012 Red Hat, Inc
## Copyright (C) 2010 Open Source Solution Technology Corporation
## Authors:
## Tim Waugh <twaugh@redhat.com>
## Tsukasa Hamano <hamano@osstech.co.jp>
## Laurent Coustet <laurent.coustet@clarisys.fr>
## This program is free software; you can redistribute it and/or modify
## it under the terms of the GNU General Public License as published by
## the Free Software Foundation; either version 2 of the License, or
## (at your option) any later version.
## This program is distributed in the hope that it will be useful,
## but WITHOUT ANY WARRANTY; without even the implied warranty of
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
## GNU General Public License for more details.
## You should have received a copy of the GNU General Public License
## along with this program; if not, write to the Free Software
## Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
"""This is a set of Python bindings for the libsmbclient library
from the samba project.
>>> # Directory listing example:
>>> import smbc
>>> ctx = smbc.Context (auth_fn=my_auth_callback_fn)
>>> entries = ctx.opendir ("smb://SERVER").getdents ()
>>> for entry in entries:
... print entry
<smbc.Dirent object "music" (File share) at 0x7fbd7c42b3a0>
<smbc.Dirent object "IPC$" (IPC share) at 0x7fbd7c42b148>
<smbc.Dirent object "Charlie" (Printer share) at 0x7fbd7c42b3c8>
>>> d = ctx.open ("smb://SERVER/music")
>>> # Write file example:
>>> import smbc
>>> import os
>>> ctx = smbc.Context (auth_fn=my_auth_callback_fn)
>>> file = ctx.open ("smb://SERVER/music/file.txt", os.O_CREAT | os.O_WRONLY)
>>> file.write ("hello")
>>> # Read file example:
>>> import smbc
>>> ctx = smbc.Context (auth_fn=my_auth_callback_fn)
>>> file = ctx.open ("smb://SERVER/music/file.txt")
>>> print file.read()
hello
"""
import subprocess
from setuptools import setup, Extension
def pkgconfig_I(pkg):
dirs = []
c = subprocess.Popen(["pkg-config", "--cflags", pkg], stdout=subprocess.PIPE)
(stdout, stderr) = c.communicate ()
for p in stdout.decode('ascii').split():
if p.startswith("-I"):
dirs.append(p[2:])
return dirs
def pkgconfig_L(pkg):
dirs = []
c = subprocess.Popen(["pkg-config", "--libs", pkg], stdout=subprocess.PIPE)
(stdout, stderr) = c.communicate ()
for p in stdout.decode('ascii').split():
if p.startswith("-L"):
dirs.append(p[2:])
return dirs
def pkgconfig_Dversion(pkg, prefix=None):
if prefix is None:
prefix = pkg.upper() + '_'
c = subprocess.Popen(["pkg-config", "--modversion", pkg],
stdout=subprocess.PIPE)
(stdout, stderr) = c.communicate()
vers = stdout.decode('ascii').rstrip().split('.')
if len(vers) == 3:
ver = str(int(vers[0]) * 10000 + int(vers[1]) * 100 + int(vers[2]))
else:
ver = str(int(vers[0]))
return [(prefix + 'VERSION', ver)]
setup(
name="pysmbc",
version="1.0.25.1",
description="Python bindings for libsmbclient",
long_description=__doc__,
author=[
"Tim Waugh <twaugh@redhat.com>",
"Tsukasa Hamano <hamano@osstech.co.jp>",
"Roberto Polli <rpolli@babel.it>",
],
url="https://github.com/hamano/pysmbc",
license="GPLv2+",
packages=["smbc"],
classifiers=[
"Intended Audience :: Developers",
"Topic :: Software Development :: Libraries :: Python Modules",
"License :: OSI Approved :: GNU General Public License (GPL)",
"Development Status :: 5 - Production/Stable",
"Operating System :: Unix",
"Programming Language :: C",
],
ext_modules=[
Extension("_smbc", [
"smbc/smbcmodule.c",
"smbc/context.c",
"smbc/dir.c",
"smbc/file.c",
"smbc/smbcdirent.c"
],
libraries=["smbclient"],
library_dirs=pkgconfig_L("smbclient"),
include_dirs=pkgconfig_I("smbclient"),
define_macros=pkgconfig_Dversion("smbclient"),
)
],
)