Browse Source

switched to python 3.9

test_fixup
Richard Young 3 years ago
parent
commit
32a2fa4fb7
5 changed files with 16 additions and 13 deletions
  1. +4
    -3
      libarchive/Makefile
  2. +3
    -2
      libarchive/__init__.py
  3. +2
    -2
      libarchive/_libarchive.i
  4. +5
    -5
      libarchive/_libarchive_wrap.c
  5. +2
    -1
      tests.py

+ 4
- 3
libarchive/Makefile View File

@@ -1,13 +1,14 @@
CFLAGS = -g
CFLAGS = -g
INCLUDE = -I/usr/include -I.
LIBS = -larchive

PYVER ?= 3.10
PYVER ?= 3.9

all: __libarchive.so

_libarchive_wrap.c: _libarchive.i
swig -python -shadow _libarchive.i
#swig -python -c++ -Wall -shadow _libarchive.i
swig -python -Wall -shadow _libarchive.i

_libarchive_wrap.o: _libarchive_wrap.c
${CC} -c ${CFLAGS} -fPIC ${INCLUDE} $$(python${PYVER}-config --cflags) _libarchive_wrap.c


+ 3
- 2
libarchive/__init__.py View File

@@ -29,12 +29,13 @@ import sys
import time
import warnings

from ctypes import cdll, c_char_p
#from ctypes import cdll, c_char_p

from libarchive import _libarchive
from io import StringIO

PY3 = sys.version_info[0] == 3
#PY3 = sys.version_info[0] == 3
PY3 = True

# Suggested block size for libarchive. Libarchive may adjust it.
BLOCK_SIZE = 10240


+ 2
- 2
libarchive/_libarchive.i View File

@@ -318,8 +318,8 @@ extern const char *archive_error_string(struct archive *);


/* CONSTANTS */
#define ARCHIVE_VERSION_NUMBER 3000001
#define ARCHIVE_VERSION_STRING "libarchive 3.0.1b"
#define ARCHIVE_VERSION_NUMBER 3005003
#define ARCHIVE_VERSION_STRING "libarchive 3.5.2"
#define ARCHIVE_EOF 1 /* Found end of archive. */
#define ARCHIVE_OK 0 /* Operation was successful. */
#define ARCHIVE_RETRY (-10) /* Retry might succeed. */


+ 5
- 5
libarchive/_libarchive_wrap.c View File

@@ -760,7 +760,7 @@ SWIG_UnpackDataName(const char *c, void *ptr, size_t sz, const char *name) {
#define PyString_Size(str) PyBytes_Size(str)
#define PyString_InternFromString(key) PyUnicode_InternFromString(key)
#define Py_TPFLAGS_HAVE_CLASS Py_TPFLAGS_BASETYPE
#define PyString_AS_STRING(x) PyUnicode_AsUTF8(x)
#define PyString_AS_STRING(x) PyUnicode_AS_STRING(x)
#define _PyLong_FromSsize_t(x) PyLong_FromSsize_t(x)

#endif
@@ -3199,7 +3199,7 @@ PyObject *archive_read_data_into_str(struct archive *archive, int len) {
PyErr_SetString(PyExc_MemoryError, "could not allocate string.");
return NULL;
}
if (len != archive_read_data(archive, (void*)PyString_AS_STRING(str), len)) {
if (len != archive_read_data(archive, PyString_AS_STRING(str), len)) {
PyErr_SetString(PyExc_RuntimeError, "could not read requested data.");
return NULL;
}
@@ -3208,7 +3208,7 @@ PyObject *archive_read_data_into_str(struct archive *archive, int len) {

PyObject *archive_write_data_from_str(struct archive *archive, PyObject *str) {
int len = PyString_Size(str);
if (!archive_write_data(archive, (const void *)PyString_AS_STRING(str), len)) {
if (!archive_write_data(archive, PyString_AS_STRING(str), len)) {
PyErr_SetString(PyExc_RuntimeError, "could not write requested data.");
return NULL;
}
@@ -6545,8 +6545,8 @@ SWIG_init(void) {
SWIG_InstallConstants(d,swig_const_table);
SWIG_Python_SetConstant(d, "ARCHIVE_VERSION_NUMBER",SWIG_From_int((int)(3000001)));
SWIG_Python_SetConstant(d, "ARCHIVE_VERSION_STRING",SWIG_FromCharPtr("libarchive 3.0.1b"));
SWIG_Python_SetConstant(d, "ARCHIVE_VERSION_NUMBER",SWIG_From_int((int)(3005003)));
SWIG_Python_SetConstant(d, "ARCHIVE_VERSION_STRING",SWIG_FromCharPtr("libarchive 3.5.2"));
SWIG_Python_SetConstant(d, "ARCHIVE_EOF",SWIG_From_int((int)(1)));
SWIG_Python_SetConstant(d, "ARCHIVE_OK",SWIG_From_int((int)(0)));
SWIG_Python_SetConstant(d, "ARCHIVE_RETRY",SWIG_From_int((int)((-10))));


+ 2
- 1
tests.py View File

@@ -33,7 +33,8 @@ import io
from libarchive import Archive, is_archive_name, is_archive
from libarchive.zip import is_zipfile, ZipFile, ZipEntry

PY3 = sys.version_info[0] == 3
#PY3 = sys.version_info[0] == 3
PY3 = True

TMPDIR = tempfile.mkdtemp(suffix='.python-libarchive')
ZIPFILE = 'test.zip'


Loading…
Cancel
Save