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,10 +37,9 @@ Compiling for Windows (With MSYS2) | ||
| 37 | 37 | ||
| 38 | * git clone https://github.com/PerryWerneck/python-tn3270.git | 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 | * cd python-tn3270 | 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,6 +318,10 @@ AC_DEFINE_UNQUOTED(PACKAGE_DESCRIPTION,"$app_cv_description") | ||
| 318 | AC_SUBST(OSNAME,$app_cv_osname) | 318 | AC_SUBST(OSNAME,$app_cv_osname) |
| 319 | AC_SUBST(LIBS) | 319 | AC_SUBST(LIBS) |
| 320 | AC_SUBST(DLLEXT) | 320 | AC_SUBST(DLLEXT) |
| 321 | + | ||
| 322 | +CFLAGS="$CFLAGS -DHAVE_CONFIG_H" | ||
| 323 | +CXXFLAGS="$CXXFLAGS -DHAVE_CONFIG_H" | ||
| 324 | + | ||
| 321 | AC_SUBST(CFLAGS) | 325 | AC_SUBST(CFLAGS) |
| 322 | AC_SUBST(CXXFLAGS) | 326 | AC_SUBST(CXXFLAGS) |
| 323 | AC_SUBST(LDFLAGS) | 327 | AC_SUBST(LDFLAGS) |
setup.py
| 1 | from distutils.core import setup, Extension | 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 | include_dirs = ['src/include'], | 9 | include_dirs = ['src/include'], |
| 6 | libraries = ['ipc3270'], | 10 | libraries = ['ipc3270'], |
| 7 | - library_dirs = ['/usr/lib64'], | ||
| 8 | sources = [ | 11 | sources = [ |
| 9 | 'src/action/type.c', | 12 | 'src/action/type.c', |
| 10 | 'src/module/init.c', | 13 | 'src/module/init.c', |
| @@ -22,11 +25,20 @@ tn3270 = Extension('tn3270', | @@ -22,11 +25,20 @@ tn3270 = Extension('tn3270', | ||
| 22 | 'src/session/misc.cc', | 25 | 'src/session/misc.cc', |
| 23 | 'src/session/set.cc', | 26 | 'src/session/set.cc', |
| 24 | 'src/session/attributes.cc', | 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 | setup ( name = 'tn3270', | 33 | setup ( name = 'tn3270', |
| 29 | version = '5.2', | 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 | ext_modules = [ tn3270 ]) | 43 | ext_modules = [ tn3270 ]) |
| 32 | 44 |
src/include/py3270.h
| @@ -31,11 +31,20 @@ | @@ -31,11 +31,20 @@ | ||
| 31 | 31 | ||
| 32 | #define PY3270_H_INCLUDED | 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 | #define PY_SSIZE_T_CLEAN | 45 | #define PY_SSIZE_T_CLEAN |
| 35 | #include <Python.h> | 46 | #include <Python.h> |
| 36 | 47 | ||
| 37 | - #include <config.h> | ||
| 38 | - | ||
| 39 | #if defined(_WIN32) | 48 | #if defined(_WIN32) |
| 40 | 49 | ||
| 41 | #include <windows.h> | 50 | #include <windows.h> |
src/module/properties.cc
| @@ -32,10 +32,18 @@ | @@ -32,10 +32,18 @@ | ||
| 32 | /*---[ Implement ]----------------------------------------------------------------------------------*/ | 32 | /*---[ Implement ]----------------------------------------------------------------------------------*/ |
| 33 | 33 | ||
| 34 | PyObject * py3270_get_module_version(PyObject *self, PyObject *args) { | 34 | PyObject * py3270_get_module_version(PyObject *self, PyObject *args) { |
| 35 | +#ifdef PACKAGE_VERSION | ||
| 35 | return PyUnicode_FromString(PACKAGE_VERSION); | 36 | return PyUnicode_FromString(PACKAGE_VERSION); |
| 37 | +#else | ||
| 38 | + return PyUnicode_FromString(""); | ||
| 39 | +#endif // PACKAGE_VERSION | ||
| 36 | } | 40 | } |
| 37 | 41 | ||
| 38 | PyObject * py3270_get_module_revision(PyObject *self, PyObject *args) { | 42 | PyObject * py3270_get_module_revision(PyObject *self, PyObject *args) { |
| 43 | +#ifdef PACKAGE_REVISION | ||
| 39 | return PyLong_FromLong(PACKAGE_REVISION); | 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,10 +36,10 @@ | ||
| 36 | * | 36 | * |
| 37 | */ | 37 | */ |
| 38 | 38 | ||
| 39 | - #include <config.h> | ||
| 40 | - #include <winsock2.h> | ||
| 41 | - #include <windows.h> | ||
| 42 | #include <py3270.h> | 39 | #include <py3270.h> |
| 40 | + | ||
| 41 | + #if defined(_WIN32) && defined(USING_STATIC_IPC3270) | ||
| 42 | + | ||
| 43 | #include <lmcons.h> | 43 | #include <lmcons.h> |
| 44 | #include <delayimp.h> | 44 | #include <delayimp.h> |
| 45 | #include <fcntl.h> | 45 | #include <fcntl.h> |
| @@ -47,8 +47,6 @@ | @@ -47,8 +47,6 @@ | ||
| 47 | #include <stdexcept> | 47 | #include <stdexcept> |
| 48 | #include <lib3270.h> | 48 | #include <lib3270.h> |
| 49 | 49 | ||
| 50 | - #ifdef USING_STATIC_IPC3270 | ||
| 51 | - | ||
| 52 | extern "C" { | 50 | extern "C" { |
| 53 | 51 | ||
| 54 | extern __declspec (dllexport) PfnDliHook __pfnDliNotifyHook2; | 52 | extern __declspec (dllexport) PfnDliHook __pfnDliNotifyHook2; |
src/module/windows/tools.cc
| @@ -27,10 +27,12 @@ | @@ -27,10 +27,12 @@ | ||
| 27 | * | 27 | * |
| 28 | */ | 28 | */ |
| 29 | 29 | ||
| 30 | - #include <py3270.h> | 30 | +#include <py3270.h> |
| 31 | 31 | ||
| 32 | /*--[ Implement ]------------------------------------------------------------------------------------*/ | 32 | /*--[ Implement ]------------------------------------------------------------------------------------*/ |
| 33 | 33 | ||
| 34 | +#ifdef _WIN32 | ||
| 35 | + | ||
| 34 | std::string py3270_get_datadir() noexcept { | 36 | std::string py3270_get_datadir() noexcept { |
| 35 | 37 | ||
| 36 | LSTATUS rc; | 38 | LSTATUS rc; |
| @@ -76,3 +78,5 @@ | @@ -76,3 +78,5 @@ | ||
| 76 | return string(datadir); | 78 | return string(datadir); |
| 77 | } | 79 | } |
| 78 | 80 | ||
| 81 | +#endif // _WIN32 | ||
| 82 | + |