Commit cb0e26998fa98ccac8f5b65e041ab8ff4999c04e
1 parent
3dda0800
Exists in
master
Adding "setup.py" script.
Showing
8 changed files
with
51 additions
and
16 deletions
Show diff stats
.gitignore
README.md
... | ... | @@ -37,10 +37,9 @@ Compiling for Windows (With MSYS2) |
37 | 37 | |
38 | 38 | * git clone https://github.com/PerryWerneck/python-tn3270.git |
39 | 39 | |
40 | -6. Build zip file with the modules using the mingw shell | |
40 | +6. Build the extension using setup.py | |
41 | 41 | |
42 | 42 | * cd python-tn3270 |
43 | - * ./autogen.sh | |
44 | - * make zip | |
43 | + * python setup.py build | |
45 | 44 | |
46 | 45 | ... | ... |
configure.ac
... | ... | @@ -318,6 +318,10 @@ AC_DEFINE_UNQUOTED(PACKAGE_DESCRIPTION,"$app_cv_description") |
318 | 318 | AC_SUBST(OSNAME,$app_cv_osname) |
319 | 319 | AC_SUBST(LIBS) |
320 | 320 | AC_SUBST(DLLEXT) |
321 | + | |
322 | +CFLAGS="$CFLAGS -DHAVE_CONFIG_H" | |
323 | +CXXFLAGS="$CXXFLAGS -DHAVE_CONFIG_H" | |
324 | + | |
321 | 325 | AC_SUBST(CFLAGS) |
322 | 326 | AC_SUBST(CXXFLAGS) |
323 | 327 | AC_SUBST(LDFLAGS) | ... | ... |
setup.py
1 | 1 | from distutils.core import setup, Extension |
2 | 2 | |
3 | -tn3270 = Extension('tn3270', | |
4 | - define_macros = [('MAJOR_VERSION', '5'), ('MINOR_VERSION', '2')], | |
3 | +tn3270 = Extension( | |
4 | + 'tn3270', | |
5 | + define_macros = [ | |
6 | + ('PACKAGE_NAME', '\"python-tn3270\"'), | |
7 | + ('PACKAGE_VERSION', '\"5.2\"') | |
8 | + ], | |
5 | 9 | include_dirs = ['src/include'], |
6 | 10 | libraries = ['ipc3270'], |
7 | - library_dirs = ['/usr/lib64'], | |
8 | 11 | sources = [ |
9 | 12 | 'src/action/type.c', |
10 | 13 | 'src/module/init.c', |
... | ... | @@ -22,11 +25,20 @@ tn3270 = Extension('tn3270', |
22 | 25 | 'src/session/misc.cc', |
23 | 26 | 'src/session/set.cc', |
24 | 27 | 'src/session/attributes.cc', |
25 | - 'src/session/actions.cc' | |
28 | + 'src/session/actions.cc', | |
29 | + 'src/module/windows/init.cc', | |
30 | + 'src/module/windows/tools.cc' | |
26 | 31 | ]) |
27 | 32 | |
28 | 33 | setup ( name = 'tn3270', |
29 | 34 | version = '5.2', |
30 | - description = 'TN3270 module.', | |
35 | + description = 'Python bindings for lib3270/pw3270.', | |
36 | + author = 'Perry Werneck', | |
37 | + author_email = 'perry.werneck@gmail.com', | |
38 | + url = 'https://github.com/PerryWerneck/python-tn3270', | |
39 | + long_description = ''' | |
40 | +This is an extension allowing tn3270 acess for python applications | |
41 | +using lib3270 directly or ipc calls to an enabled pw3270 window. | |
42 | +''', | |
31 | 43 | ext_modules = [ tn3270 ]) |
32 | 44 | ... | ... |
src/include/py3270.h
... | ... | @@ -31,11 +31,20 @@ |
31 | 31 | |
32 | 32 | #define PY3270_H_INCLUDED |
33 | 33 | |
34 | + #ifdef HAVE_CONFIG_H | |
35 | + #include <config.h> | |
36 | + #else | |
37 | + #define PACKAGE_DESCRIPTION "Python bindings for lib3270/pw3270" | |
38 | + #define HAVE_GNUC_VISIBILITY 1 | |
39 | + #endif // HAVE_CONFIG_H | |
40 | + | |
41 | + #ifndef PACKAGE_NAME | |
42 | + #define PACKAGE_NAME "Python-TN3270" | |
43 | + #endif // !PACKAGE_NAME | |
44 | + | |
34 | 45 | #define PY_SSIZE_T_CLEAN |
35 | 46 | #include <Python.h> |
36 | 47 | |
37 | - #include <config.h> | |
38 | - | |
39 | 48 | #if defined(_WIN32) |
40 | 49 | |
41 | 50 | #include <windows.h> | ... | ... |
src/module/properties.cc
... | ... | @@ -32,10 +32,18 @@ |
32 | 32 | /*---[ Implement ]----------------------------------------------------------------------------------*/ |
33 | 33 | |
34 | 34 | PyObject * py3270_get_module_version(PyObject *self, PyObject *args) { |
35 | +#ifdef PACKAGE_VERSION | |
35 | 36 | return PyUnicode_FromString(PACKAGE_VERSION); |
37 | +#else | |
38 | + return PyUnicode_FromString(""); | |
39 | +#endif // PACKAGE_VERSION | |
36 | 40 | } |
37 | 41 | |
38 | 42 | PyObject * py3270_get_module_revision(PyObject *self, PyObject *args) { |
43 | +#ifdef PACKAGE_REVISION | |
39 | 44 | return PyLong_FromLong(PACKAGE_REVISION); |
45 | +#else | |
46 | + return PyLong_FromLong(0); | |
47 | +#endif // PACKAGE_REVISION | |
40 | 48 | } |
41 | 49 | ... | ... |
src/module/windows/init.cc
... | ... | @@ -36,10 +36,10 @@ |
36 | 36 | * |
37 | 37 | */ |
38 | 38 | |
39 | - #include <config.h> | |
40 | - #include <winsock2.h> | |
41 | - #include <windows.h> | |
42 | 39 | #include <py3270.h> |
40 | + | |
41 | + #if defined(_WIN32) && defined(USING_STATIC_IPC3270) | |
42 | + | |
43 | 43 | #include <lmcons.h> |
44 | 44 | #include <delayimp.h> |
45 | 45 | #include <fcntl.h> |
... | ... | @@ -47,8 +47,6 @@ |
47 | 47 | #include <stdexcept> |
48 | 48 | #include <lib3270.h> |
49 | 49 | |
50 | - #ifdef USING_STATIC_IPC3270 | |
51 | - | |
52 | 50 | extern "C" { |
53 | 51 | |
54 | 52 | extern __declspec (dllexport) PfnDliHook __pfnDliNotifyHook2; | ... | ... |
src/module/windows/tools.cc
... | ... | @@ -27,10 +27,12 @@ |
27 | 27 | * |
28 | 28 | */ |
29 | 29 | |
30 | - #include <py3270.h> | |
30 | +#include <py3270.h> | |
31 | 31 | |
32 | 32 | /*--[ Implement ]------------------------------------------------------------------------------------*/ |
33 | 33 | |
34 | +#ifdef _WIN32 | |
35 | + | |
34 | 36 | std::string py3270_get_datadir() noexcept { |
35 | 37 | |
36 | 38 | LSTATUS rc; |
... | ... | @@ -76,3 +78,5 @@ |
76 | 78 | return string(datadir); |
77 | 79 | } |
78 | 80 | |
81 | +#endif // _WIN32 | |
82 | + | ... | ... |