Commits

AJ R committed fa4c47e

modified generic.py, messing with files

Comments (0)

Files changed (41)

-3.2
+3.2.1

make_packages.bat

+:: make packages that can be built under/for windows
+python setup.py sdist --formats=gztar,zip
+del .\build\lib\savReaderWriter\spssio\aix64 /s /q
+del .\build\lib\savReaderWriter\spssio\hpux_it /s /q
+del .\build\lib\savReaderWriter\spssio\lin32 /s /q
+del .\build\lib\savReaderWriter\spssio\lin64 /s /q
+del .\build\lib\savReaderWriter\spssio\macos /s /q
+del .\build\lib\savReaderWriter\spssio\sol64 /s /q
+del .\build\lib\savReaderWriter\spssio\win64 /s /q
+del .\build\lib\savReaderWriter\spssio\zlinux64 /s /q
+python setup.py bdist --formats=wininst
+del .\build /s /q

savReaderWriter/VERSION

-3.2
+3.2.1

savReaderWriter/__init__.py

-#!/usr/bin/env python
-# -*- coding: utf-8 -*-
-
-"""
-SavReaderWriter.py: A cross-platform Python interface to the IBM SPSS
-Statistics Input Output Module. Read or Write SPSS system files (.sav, .zsav)
-
-.. moduleauthor:: Albert-Jan Roskam <fomcl@yahoo.com>
-
-"""
-
-__author__ = "Albert-Jan Roskam" + " " + "@".join(["fomcl", "yahoo.com"])
-__version__ = "3.1.1"
-
-# change this to 'True' in case you experience segmentation
-# faults related to freeing memory.
-segfaults = False
-
-from ctypes import *
-import ctypes.util
-import struct
-import sys
-import platform
-import os
-import re
-import operator
-import math
-import locale
-import datetime
-import time
-import getpass
-import encodings
-import functools
-import gc
-try:
-    import psyco
-    psycoOk = True  # reading 66 % faster
-except ImportError:
-    print ("NOTE. Psyco module not found. Install this module " +
-           "to increase reader performance")
-    psycoOk = False
-try:
-    import numpy
-    numpyOk = True
-except ImportError:
-    print ("NOTE. Numpy module not found. Install this module " +
-           "to use array slicing")
-    numpyOk = False
-try:
-    from cWriterow import cWriterow  # writing 66 % faster
-    cWriterowOK = True
-except ImportError:
-    print ("NOTE. cWriterow module not found. Install this module " +
-            "to increase writer performance")
-    cWriterowOK = False
-
-retcodes = {
-    0: "SPSS_OK",
-    1: "SPSS_FILE_OERROR",
-    2: "SPSS_FILE_WERROR",
-    3: "SPSS_FILE_RERROR",
-    4: "SPSS_FITAB_FULL",
-    5: "SPSS_INVALID_HANDLE",
-    6: "SPSS_INVALID_FILE",
-    7: "SPSS_NO_MEMORY",
-    8: "SPSS_OPEN_RDMODE",
-    9: "SPSS_OPEN_WRMODE",
-    10: "SPSS_INVALID_VARNAME",
-    11: "SPSS_DICT_EMPTY",
-    12: "SPSS_VAR_NOTFOUND",
-    13: "SPSS_DUP_VAR",
-    14: "SPSS_NUME_EXP",
-    15: "SPSS_STR_EXP",
-    16: "SPSS_SHORTSTR_EXP",
-    17: "SPSS_INVALID_VARTYPE",
-    18: "SPSS_INVALID_MISSFOR",
-    19: "SPSS_INVALID_COMPSW",
-    20: "SPSS_INVALID_PRFOR",
-    21: "SPSS_INVALID_WRFOR",
-    22: "SPSS_INVALID_DATE",
-    23: "SPSS_INVALID_TIME",
-    24: "SPSS_NO_VARIABLES",
-    27: "SPSS_DUP_VALUE",
-    28: "SPSS_INVALID_CASEWGT",
-    30: "SPSS_DICT_COMMIT",
-    31: "SPSS_DICT_NOTCOMMIT",
-    33: "SPSS_NO_TYPE2",
-    41: "SPSS_NO_TYPE73",
-    45: "SPSS_INVALID_DATEINFO",
-    46: "SPSS_NO_TYPE999",
-    47: "SPSS_EXC_STRVALUE",
-    48: "SPSS_CANNOT_FREE",
-    49: "SPSS_BUFFER_SHORT",
-    50: "SPSS_INVALID_CASE",
-    51: "SPSS_INTERNAL_VLABS",
-    52: "SPSS_INCOMPAT_APPEND",
-    53: "SPSS_INTERNAL_D_A",
-    54: "SPSS_FILE_BADTEMP",
-    55: "SPSS_DEW_NOFIRST",
-    56: "SPSS_INVALID_MEASURELEVEL",
-    57: "SPSS_INVALID_7SUBTYPE",
-    58: "SPSS_INVALID_VARHANDLE",
-    59: "SPSS_INVALID_ENCODING",
-    60: "SPSS_FILES_OPEN",
-    70: "SPSS_INVALID_MRSETDEF",
-    71: "SPSS_INVALID_MRSETNAME",
-    72: "SPSS_DUP_MRSETNAME",
-    73: "SPSS_BAD_EXTENSION",
-    74: "SPSS_INVALID_EXTENDEDSTRING",
-    75: "SPSS_INVALID_ATTRNAME",
-    76: "SPSS_INVALID_ATTRDEF",
-    77: "SPSS_INVALID_MRSETINDEX",
-    78: "SPSS_INVALID_VARSETDEF",
-    79: "SPSS_INVALID_ROLE",
-
-    -15: "SPSS_EMPTY_DEW",
-    -14: "SPSS_NO_DEW",
-    -13: "SPSS_EMPTY_MULTRESP",
-    -12: "SPSS_NO_MULTRESP",
-    -11: "SPSS_NO_DATEINFO",
-    -10: "SPSS_NO_CASEWGT",
-    -9: "SPSS_NO_LABEL",
-    -8: "SPSS_NO_LABELS",
-    -7: "SPSS_EMPTY_VARSETS",
-    -6: "SPSS_NO_VARSETS",
-    -5: "SPSS_FILE_END",
-    -4: "SPSS_EXC_VALLABEL",
-    -3: "SPSS_EXC_LEN120",
-    -2: "SPSS_EXC_VARLABEL",
-    -1: "SPSS_EXC_LEN64"}
-
-allFormats = {
-    1: ("SPSS_FMT_A", "Alphanumeric"),
-    2: ("SPSS_FMT_AHEX", "Alphanumeric hexadecimal"),
-    3: ("SPSS_FMT_COMMA", "F Format with commas"),
-    4: ("SPSS_FMT_DOLLAR", "Commas and floating dollar sign"),
-    5: ("SPSS_FMT_F", "Default Numeric Format"),
-    6: ("SPSS_FMT_IB", "Integer binary"),
-    7: ("SPSS_FMT_PIBHEX", "Positive integer binary - hex"),
-    8: ("SPSS_FMT_P", "Packed decimal"),
-    9: ("SPSS_FMT_PIB", "Positive integer binary unsigned"),
-    10: ("SPSS_FMT_PK", "Positive integer binary unsigned"),
-    11: ("SPSS_FMT_RB", "Floating point binary"),
-    12: ("SPSS_FMT_RBHEX", "Floating point binary hex"),
-    15: ("SPSS_FMT_Z", "Zoned decimal"),
-    16: ("SPSS_FMT_N", "N Format- unsigned with leading 0s"),
-    17: ("SPSS_FMT_E", "E Format- with explicit power of 10"),
-    20: ("SPSS_FMT_DATE", "Date format dd-mmm-yyyy"),
-    21: ("SPSS_FMT_TIME", "Time format hh:mm:ss.s"),
-    22: ("SPSS_FMT_DATE_TIME", "Date and Time"),
-    23: ("SPSS_FMT_ADATE", "Date format dd-mmm-yyyy"),
-    24: ("SPSS_FMT_JDATE", "Julian date - yyyyddd"),
-    25: ("SPSS_FMT_DTIME", "Date-time dd hh:mm:ss.s"),
-    26: ("SPSS_FMT_WKDAY", "Day of the week"),
-    27: ("SPSS_FMT_MONTH", "Month"),
-    28: ("SPSS_FMT_MOYR", "mmm yyyy"),
-    29: ("SPSS_FMT_QYR", "q Q yyyy"),
-    30: ("SPSS_FMT_WKYR", "ww WK yyyy"),
-    31: ("SPSS_FMT_PCT", "Percent - F followed by %"),
-    32: ("SPSS_FMT_DOT", "Like COMMA, switching dot for comma"),
-    33: ("SPSS_FMT_CCA", "User Programmable currency format"),
-    34: ("SPSS_FMT_CCB", "User Programmable currency format"),
-    35: ("SPSS_FMT_CCC", "User Programmable currency format"),
-    36: ("SPSS_FMT_CCD", "User Programmable currency format"),
-    37: ("SPSS_FMT_CCE", "User Programmable currency format"),
-    38: ("SPSS_FMT_EDATE", "Date in dd/mm/yyyy style"),
-    39: ("SPSS_FMT_SDATE", "Date in yyyy/mm/dd style")}
-
-MAXLENGTHS = {
-    "SPSS_MAX_VARNAME": (64, "Variable name"),
-    "SPSS_MAX_SHORTVARNAME": (8, "Short (compatibility) variable name"),
-    "SPSS_MAX_SHORTSTRING": (8, "Short string variable"),
-    "SPSS_MAX_IDSTRING": (64, "File label string"),
-    "SPSS_MAX_LONGSTRING": (32767, "Long string variable"),
-    "SPSS_MAX_VALLABEL": (120, "Value label"),
-    "SPSS_MAX_VARLABEL": (256, "Variable label"),
-    "SPSS_MAX_7SUBTYPE": (40, "Maximum record 7 subtype"),
-    "SPSS_MAX_ENCODING": (64, "Maximum encoding text")}
-
-supportedDates = {  # uses ISO dates wherever applicable.
-    "DATE": "%Y-%m-%d",
-    "JDATE": "%Y-%m-%d",
-    "EDATE": "%Y-%m-%d",
-    "SDATE": "%Y-%m-%d",
-    "DATETIME": "%Y-%m-%d %H:%M:%S",
-    "WKDAY": "%A %H:%M:%S",
-    "ADATE": "%Y-%m-%d",
-    "WKDAY": "%A",
-    "MONTH": "%B",
-    "MOYR": "%B %Y",
-    "WKYR": "%W WK %Y"}
-
-userMissingValues = {
-    "SPSS_NO_MISSVAL": 0,
-    "SPSS_ONE_MISSVAL": 1,
-    "SPSS_TWO_MISSVAL": 2,
-    "SPSS_THREE_MISSVAL": 3,
-    "SPSS_MISS_RANGE": -2,
-    "SPSS_MISS_RANGEANDVAL": -3}
-
-version = __version__
-
-from error import *
-from generic import *
-from header import *
-from savReader import *
-from savWriter import *
-from savHeaderReader import *
-
-__all__ = ["SavReader", "SavWriter", "SavHeaderReader"]
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+
+"""
+SavReaderWriter.py: A cross-platform Python interface to the IBM SPSS
+Statistics Input Output Module. Read or Write SPSS system files (.sav, .zsav)
+
+.. moduleauthor:: Albert-Jan Roskam <fomcl@yahoo.com>
+
+"""
+
+# change this to 'True' in case you experience segmentation
+# faults related to freeing memory.
+segfaults = False
+
+from ctypes import *
+import ctypes.util
+import struct
+import sys
+import platform
+import os
+import re
+import operator
+import math
+import locale
+import datetime
+import time
+import getpass
+import encodings
+import functools
+import gc
+try:
+    import psyco
+    psycoOk = True  # reading 66 % faster
+except ImportError:
+    print ("NOTE. Psyco module not found. Install this module " +
+           "to increase reader performance")
+    psycoOk = False
+try:
+    import numpy
+    numpyOk = True
+except ImportError:
+    print ("NOTE. Numpy module not found. Install this module " +
+           "to use array slicing")
+    numpyOk = False
+try:
+    from cWriterow import cWriterow  # writing 66 % faster
+    cWriterowOK = True
+except ImportError:
+    print ("NOTE. cWriterow module not found. Install this module " +
+            "to increase writer performance")
+    cWriterowOK = False
+
+__author__ = "Albert-Jan Roskam" + " " + "@".join(["fomcl", "yahoo.com"])
+__version__ = open(os.path.join(os.path.dirname(__file__),
+                                "VERSION")).read().strip()
+
+retcodes = {
+    0: "SPSS_OK",
+    1: "SPSS_FILE_OERROR",
+    2: "SPSS_FILE_WERROR",
+    3: "SPSS_FILE_RERROR",
+    4: "SPSS_FITAB_FULL",
+    5: "SPSS_INVALID_HANDLE",
+    6: "SPSS_INVALID_FILE",
+    7: "SPSS_NO_MEMORY",
+    8: "SPSS_OPEN_RDMODE",
+    9: "SPSS_OPEN_WRMODE",
+    10: "SPSS_INVALID_VARNAME",
+    11: "SPSS_DICT_EMPTY",
+    12: "SPSS_VAR_NOTFOUND",
+    13: "SPSS_DUP_VAR",
+    14: "SPSS_NUME_EXP",
+    15: "SPSS_STR_EXP",
+    16: "SPSS_SHORTSTR_EXP",
+    17: "SPSS_INVALID_VARTYPE",
+    18: "SPSS_INVALID_MISSFOR",
+    19: "SPSS_INVALID_COMPSW",
+    20: "SPSS_INVALID_PRFOR",
+    21: "SPSS_INVALID_WRFOR",
+    22: "SPSS_INVALID_DATE",
+    23: "SPSS_INVALID_TIME",
+    24: "SPSS_NO_VARIABLES",
+    27: "SPSS_DUP_VALUE",
+    28: "SPSS_INVALID_CASEWGT",
+    30: "SPSS_DICT_COMMIT",
+    31: "SPSS_DICT_NOTCOMMIT",
+    33: "SPSS_NO_TYPE2",
+    41: "SPSS_NO_TYPE73",
+    45: "SPSS_INVALID_DATEINFO",
+    46: "SPSS_NO_TYPE999",
+    47: "SPSS_EXC_STRVALUE",
+    48: "SPSS_CANNOT_FREE",
+    49: "SPSS_BUFFER_SHORT",
+    50: "SPSS_INVALID_CASE",
+    51: "SPSS_INTERNAL_VLABS",
+    52: "SPSS_INCOMPAT_APPEND",
+    53: "SPSS_INTERNAL_D_A",
+    54: "SPSS_FILE_BADTEMP",
+    55: "SPSS_DEW_NOFIRST",
+    56: "SPSS_INVALID_MEASURELEVEL",
+    57: "SPSS_INVALID_7SUBTYPE",
+    58: "SPSS_INVALID_VARHANDLE",
+    59: "SPSS_INVALID_ENCODING",
+    60: "SPSS_FILES_OPEN",
+    70: "SPSS_INVALID_MRSETDEF",
+    71: "SPSS_INVALID_MRSETNAME",
+    72: "SPSS_DUP_MRSETNAME",
+    73: "SPSS_BAD_EXTENSION",
+    74: "SPSS_INVALID_EXTENDEDSTRING",
+    75: "SPSS_INVALID_ATTRNAME",
+    76: "SPSS_INVALID_ATTRDEF",
+    77: "SPSS_INVALID_MRSETINDEX",
+    78: "SPSS_INVALID_VARSETDEF",
+    79: "SPSS_INVALID_ROLE",
+
+    -15: "SPSS_EMPTY_DEW",
+    -14: "SPSS_NO_DEW",
+    -13: "SPSS_EMPTY_MULTRESP",
+    -12: "SPSS_NO_MULTRESP",
+    -11: "SPSS_NO_DATEINFO",
+    -10: "SPSS_NO_CASEWGT",
+    -9: "SPSS_NO_LABEL",
+    -8: "SPSS_NO_LABELS",
+    -7: "SPSS_EMPTY_VARSETS",
+    -6: "SPSS_NO_VARSETS",
+    -5: "SPSS_FILE_END",
+    -4: "SPSS_EXC_VALLABEL",
+    -3: "SPSS_EXC_LEN120",
+    -2: "SPSS_EXC_VARLABEL",
+    -1: "SPSS_EXC_LEN64"}
+
+allFormats = {
+    1: ("SPSS_FMT_A", "Alphanumeric"),
+    2: ("SPSS_FMT_AHEX", "Alphanumeric hexadecimal"),
+    3: ("SPSS_FMT_COMMA", "F Format with commas"),
+    4: ("SPSS_FMT_DOLLAR", "Commas and floating dollar sign"),
+    5: ("SPSS_FMT_F", "Default Numeric Format"),
+    6: ("SPSS_FMT_IB", "Integer binary"),
+    7: ("SPSS_FMT_PIBHEX", "Positive integer binary - hex"),
+    8: ("SPSS_FMT_P", "Packed decimal"),
+    9: ("SPSS_FMT_PIB", "Positive integer binary unsigned"),
+    10: ("SPSS_FMT_PK", "Positive integer binary unsigned"),
+    11: ("SPSS_FMT_RB", "Floating point binary"),
+    12: ("SPSS_FMT_RBHEX", "Floating point binary hex"),
+    15: ("SPSS_FMT_Z", "Zoned decimal"),
+    16: ("SPSS_FMT_N", "N Format- unsigned with leading 0s"),
+    17: ("SPSS_FMT_E", "E Format- with explicit power of 10"),
+    20: ("SPSS_FMT_DATE", "Date format dd-mmm-yyyy"),
+    21: ("SPSS_FMT_TIME", "Time format hh:mm:ss.s"),
+    22: ("SPSS_FMT_DATE_TIME", "Date and Time"),
+    23: ("SPSS_FMT_ADATE", "Date format dd-mmm-yyyy"),
+    24: ("SPSS_FMT_JDATE", "Julian date - yyyyddd"),
+    25: ("SPSS_FMT_DTIME", "Date-time dd hh:mm:ss.s"),
+    26: ("SPSS_FMT_WKDAY", "Day of the week"),
+    27: ("SPSS_FMT_MONTH", "Month"),
+    28: ("SPSS_FMT_MOYR", "mmm yyyy"),
+    29: ("SPSS_FMT_QYR", "q Q yyyy"),
+    30: ("SPSS_FMT_WKYR", "ww WK yyyy"),
+    31: ("SPSS_FMT_PCT", "Percent - F followed by %"),
+    32: ("SPSS_FMT_DOT", "Like COMMA, switching dot for comma"),
+    33: ("SPSS_FMT_CCA", "User Programmable currency format"),
+    34: ("SPSS_FMT_CCB", "User Programmable currency format"),
+    35: ("SPSS_FMT_CCC", "User Programmable currency format"),
+    36: ("SPSS_FMT_CCD", "User Programmable currency format"),
+    37: ("SPSS_FMT_CCE", "User Programmable currency format"),
+    38: ("SPSS_FMT_EDATE", "Date in dd/mm/yyyy style"),
+    39: ("SPSS_FMT_SDATE", "Date in yyyy/mm/dd style")}
+
+MAXLENGTHS = {
+    "SPSS_MAX_VARNAME": (64, "Variable name"),
+    "SPSS_MAX_SHORTVARNAME": (8, "Short (compatibility) variable name"),
+    "SPSS_MAX_SHORTSTRING": (8, "Short string variable"),
+    "SPSS_MAX_IDSTRING": (64, "File label string"),
+    "SPSS_MAX_LONGSTRING": (32767, "Long string variable"),
+    "SPSS_MAX_VALLABEL": (120, "Value label"),
+    "SPSS_MAX_VARLABEL": (256, "Variable label"),
+    "SPSS_MAX_7SUBTYPE": (40, "Maximum record 7 subtype"),
+    "SPSS_MAX_ENCODING": (64, "Maximum encoding text")}
+
+supportedDates = {  # uses ISO dates wherever applicable.
+    "DATE": "%Y-%m-%d",
+    "JDATE": "%Y-%m-%d",
+    "EDATE": "%Y-%m-%d",
+    "SDATE": "%Y-%m-%d",
+    "DATETIME": "%Y-%m-%d %H:%M:%S",
+    "WKDAY": "%A %H:%M:%S",
+    "ADATE": "%Y-%m-%d",
+    "WKDAY": "%A",
+    "MONTH": "%B",
+    "MOYR": "%B %Y",
+    "WKYR": "%W WK %Y"}
+
+userMissingValues = {
+    "SPSS_NO_MISSVAL": 0,
+    "SPSS_ONE_MISSVAL": 1,
+    "SPSS_TWO_MISSVAL": 2,
+    "SPSS_THREE_MISSVAL": 3,
+    "SPSS_MISS_RANGE": -2,
+    "SPSS_MISS_RANGEANDVAL": -3}
+
+version = __version__
+
+from error import *
+from generic import *
+from header import *
+from savReader import *
+from savWriter import *
+from savHeaderReader import *
+
+__all__ = ["SavReader", "SavWriter", "SavHeaderReader"]

savReaderWriter/cWriterow/__init__.py

File contents unchanged.

savReaderWriter/cWriterow/build/temp.linux-i686-2.7/cWriterow.o

Binary file modified.

savReaderWriter/cWriterow/cWriterow.c

File contents unchanged.

savReaderWriter/cWriterow/cWriterow.html

File contents unchanged.

savReaderWriter/cWriterow/cWriterow.pyx

File contents unchanged.

savReaderWriter/cWriterow/cWriterow.so

Binary file modified.

savReaderWriter/cWriterow/readme.txt

File contents unchanged.

savReaderWriter/cWriterow/setup.py

File contents unchanged.

savReaderWriter/doc_tests/test_SavHeaderReader_report_utf8.txt~

-##############################################################################
-## Print a report of the header information (ioUtf8=True)
-##############################################################################
-
-
->>> import doctest
->>> import pprint
->>> doctest.ELLIPSIS_MARKER = ",,,"
->>> from savReaderWriter import *
-
-,,,
-
->>> savFileName = "../test_data/greetings.sav"
->>> with SavHeaderReader(savFileName, ioUtf8=True) as spssDict:
-...     pprint.pprint( repr(unicode(spssDict)).split("\n") )  # doctest: +ELLIPSIS, +NORMALIZE_WHITESPACE
-,,,
-['u"File \'greetings.sav\' built using SavReaderWriter.py version 3.1.1 (Thu Jan 17 16:35:14 2013)\\n#ALIGNMENTS\\nline -- left\\ngreeting -- left\\nBondjo\\xfb -- left\\n#CASEWEIGHTVAR\\n#COLUMNWIDTHS\\nline -- 8\\ngreeting -- 50\\nBondjo\\xfb -- 20\\n#FILEATTRIBUTES\\n#FILELABEL\\nFile created by user \'Administrator\' at Thu Jan 17 16:35:14 2013\\n#FORMATS\\nline -- F8.2\\ngreeting -- A50\\nBondjo\\xfb -- A20\\n#MEASURELEVELS\\nline -- unknown\\ngreeting -- unknown\\nBondjo\\xfb -- unknown\\n#MISSINGVALUES\\nline: lower -- 0.0\\nline: upper -- 9.0\\nBondjo\\xfb: values -- \\xa1hola! \\n#MULTRESPDEFS\\n#VALUELABELS\\nBondjo\\xfb: Thai -- \\u0e2a\\u0e27\\u0e31\\u0e2a\\u0e14\\u0e35\\n#VARATTRIBUTES\\n#VARLABELS\\ngreeting -- \\u0627\\u0644\\u0633\\u0644\\u0627\\u0645 \\u0639\\u0644\\u064a\\u0643\\u0645\\n#VARNAMES\\nline\\nBondjo\\xfb\\ngreeting\\n#VARROLES\\nline -- input\\ngreeting -- input\\nBondjo\\xfb -- input\\n#VARSETS\\n#VARTYPES\\nline -- 0\\ngreeting -- 50\\nBondjo\\xfb -- 20"']
-

savReaderWriter/doc_tests/test_SavWriter_typical.txt~

-##############################################################################
-## Write a file, typical use
-##############################################################################
-
->>> import os
->>> import tempfile
->>> import sys
->>> sys.stdout.write('<skipline> '); from savReaderWriter import * # doctest: +ELLIPSIS
-<skipline> ...
-
-
-## ----- Typical use
->>> records = [['Test1', 1, 1, '2010-08-11'], ['Test2', 2, 1, '1910-01-12']]
->>> varNames = ['var1', 'v2', 'v3', 'bdate']
->>> varTypes = {'var1': 6, 'v2': 0, 'v3': 0, 'bdate': 10}
->>> savFileName = os.path.join(tempfile.gettempdir(), "test.sav")
->>> with SavWriter(savFileName, varNames, varTypes) as sav:
-...     for record in records:
-...         sav.writerow(record)
-...     print "Done! %s" % os.path.basename(sav.savFileName)
-Done! test.sav
-
-# read it back in
->>> try:
-...     reader = SavReader(savFileName)  # doctest: +ELLIPSIS
-...     records_out = [line for line in iter(reader)]
-... finally:
-...     reader.close()
-...
->>> print records_out == records  # doctest: +NORMALIZE_WHITESPACE
-True
-
-# clean up
->>> os.remove(savFileName)
-
-

savReaderWriter/doc_tests/test_SavWriter_writerow_date.txt~

-##############################################################################
-## Write a file, incl. SPSS date values
-##############################################################################
-
->>> import os
->>> import tempfile
->>> import sys
->>> sys.stdout.write('<skipline> '); from savReaderWriter import * # doctest: +ELLIPSIS
-<skipline> ...
-
-## ----- Write one row
-# var1 is a 5-char string var, the others are numerical:
-# formats, varLabels, valueLabels, missingValues etc. may also be None (default).
-# This also shows how date fields can be converted into spss dates.
-# Spss dates are *stored* as the number of seconds since Oct 14, 1582, but
-# *displayed* as <format>. In this case they are displayed as EDATE
-# (European date, cf. ADATE = American date), ie. as dd.mm.yyyy
-
->>> records = [['Test1', 1, 1, '2010-08-11'], ['Test2', 2, 1, '1910-01-12']]
->>> varNames = ['var1', 'v2', 'v3', 'bdate']
->>> varTypes = {'var1': 41, 'v2': 0, 'v3': 0, 'bdate': 0}
->>> formats = {'var1': 'A41', 'v2': 'F3.1', 'v3': 'F5.1', 'bdate': 'EDATE40'}
->>> missingValues = {'var1': {'values': ['Test1', 'Test2']},
-...                  'v2': {'values': 1}}
->>> varLabels = {'var1': 'This is variable 1',
-...              'v2': 'This is v2!',
-...              'bdate': 'dob'}
->>> valueLabels = {'var1': {'Test1': 'Test1 value label',
-...                         'Test2': 'Test2 value label'},
-...                'v2': {1: 'yes', 2: 'no'}}
->>> savFileName = os.path.join(tempfile.gettempdir(), "test.sav")
->>> with SavWriter(savFileName, varNames, varTypes,
-...                valueLabels, varLabels, formats) as sav:
-...     pos = varNames.index("bdate")
-...     for record in records:
-...         record[pos] = sav.spssDateTime(record[pos], "%Y-%m-%d")
-...         print record
-...         sav.writerow(record)
-...     print "Done! %s" % os.path.basename(sav.savFileName)
-['Test1', 1, 1, 13500864000.0]
-['Test2', 2, 1, 10326873600.0]
-Done! test.sav
-
-# read it back in in rawMode (dates not converted to ISO-dates)
->>> try:
-...     reader = SavReader(savFileName, rawMode=True)  # doctest: +ELLIPSIS
-...     records_out = [line for line in iter(reader)]
-... finally:
-...     reader.close()
-...
->>> print records_out == records  # doctest: +NORMALIZE_WHITESPACE
-True
-
-# clean up
->>> os.remove(os.path.abspath(savFileName))
-
-

savReaderWriter/documentation/LA_en

File contents unchanged.

savReaderWriter/documentation/Makefile

File contents unchanged.

savReaderWriter/documentation/PkgId

File contents unchanged.

savReaderWriter/documentation/conf.py

File contents unchanged.

savReaderWriter/documentation/index.rst

File contents unchanged.

savReaderWriter/documentation/index.rst~

-.. savReaderWriter documentation master file, created by
-   sphinx-quickstart on Thu Jan  3 00:25:18 2013.
-   You can adapt this file completely to your liking, but it should at least
-   contain the root `toctree` directive.
-
-Welcome to savReaderWriter's documentation!
-=================================================================================
-
-.. module:: savReaderWriter
-   :platform: Unix, Windows, Mac
-   :synopsis: Read/Write Spss system files (.sav, .zsav)
-.. moduleauthor:: Albert-Jan Roskam <fomcl@yahoo.com>
-
-.. _`IBM SPSS Statistics Command Syntax Reference.pdf`: ftp://public.dhe.ibm.com/software/analytics/spss/documentation/statistics/20.0/en/client/Manuals/IBM_SPSS_Statistics_Command_Syntax_Reference.pdf
-.. _`International License Agreement`: ./LA_en
-
-In the documentation below, the associated SPSS commands are given in ``CAPS``.
-See also the `IBM SPSS Statistics Command Syntax Reference.pdf`_ for info about SPSS syntax.
-
-.. seealso::
-
-   The :mod:`savReaderWriter` program uses the SPSS I/O module (``.so``, ``.dll``, ``.dylib``, depending on your Operating  System). Users of the SPSS I/O module should read the `International License Agreement`_ before using the SPSS I/O module. By downloading, installing, copying, accessing, or otherwise using the  SPSS I/O module, licensee agrees to the terms of this agreement. Copyright © IBM Corporation™ 1989, 2012 --- all rights reserved.
-
-
-.. toctree::
-   :maxdepth: 2
-
-Installation
-============================================================================
-
-This program works for Linux (incl. z/Linux), Windows, MacOS (32 and 64 bit), AIX-64, HP-UX and Solaris-64. However, it has only been tested on Linux 32 (Ubuntu and Mint), Windows (mostly on Windows XP 32, but also a few times on Windows 7 64), and MacOS (with an earlier version of savReaderWriter). The other OSs are entirely untested. The program can be installed by running::
-
-    python setup.py install
-
-Or alternatively::
-
-    pip install savReaderWriter
-
-To get the 'bleeding edge' version straight from the repository do::
-
-    pip install -U -e git+https://bitbucket.org/fomcl/savreaderwriter.git#egg=savreaderwriter
-
-.. versionchanged:: 3.1.3
-
-The ``savReaderWriter`` program is now self-contained. That is, the IBM SPSS I/O modules now all load by themselves, without any changes being required anymore to ``PATH``, ``LD_LIBRARY_PATH`` and equivalents. Also, no extra .deb files need to be installed anymore (i.e. no dependencies).
-
-
-The ``cWriterow`` package is a faster Cython implementation of the pyWriterow method. To install it, you need Cython and run ``setup.py`` in the ``cWriterow`` folder::
-
-    easy_install cython
-    python setup.py build_ext --inplace
-
-
-
-:mod:`SavWriter` -- Write Spss system files
-============================================================================
-.. function:: SavWriter(savFileName, varNames, varTypes, [valueLabels=None, varLabels=None, formats=None, missingValues=None, measureLevels=None, columnWidths=None, alignments=None, varSets=None, varRoles=None, varAttributes=None, fileAttributes=None, fileLabel=None, multRespDefs=None, caseWeightVar=None, overwrite=True, ioUtf8=False, ioLocale=None, mode="wb", refSavFileName=None])
-   
-   **Write Spss system files (.sav, .zsav)**
-
-   :param savFileName: the file name of the spss data file. File names that end with '.zsav' are   compressed using the ZLIB (ZSAV) compression scheme (requires v21 SPSS I/O files), while for file    names that end with '.sav' the 'old' compression scheme is used (it is not possible to generate uncompressed files unless you modify the source code).
-
-   :param varNames: list of the variable names in the order in which they appear in the spss data file.
-
-   :param varTypes: varTypes dictionary ``{varName: varType}``, where varType == 0 means 'numeric', and varType > 0 means 'character' of that length (in bytes)
-
-   :param valueLabels: value label dictionary ``{varName: {value: label}}``. Cf. ``VALUE LABELS`` (default: None).
-
-   :param varLabels: variable label dictionary ``{varName: varLabel}``. Cf. ``VARIABLE LABEL`` (default: None).
-
-   :param formats: print/write format dictionary ``{varName: spssFmt}``. Commonly used formats include F  (numeric, e.g. F5.4), N (numeric with leading zeroes, e.g. N8), A (string, e.g. A8) and EDATE/ADATE  (European/American date, e.g. ADATE30). Cf. ``FORMATS`` (default: None).
-
-   :param missingValues: missing values dictionary ``{varName: {missing_value_spec}}``. Cf. ``MISSING VALUES`` (default: None). For example: 
-
-      .. code:: python
-
-         missingValues = {"someNumvar1": {"values": [999, -1, -2]},  # discrete values
-                          "someNumvar2": {"lower": -9, "upper": -1}, # range, cf. MISSING VALUES x (-9 THRU -1)
-                          "someNumvar3": {"lower": -9, "upper": -1, "value": 999},
-                          "someStrvar1": {"values": ["foo', "bar", "baz"]},
-                          "someStrvar2": {"values': "bletch"}}
-     
-      .. warning:: *measureLevels, columnWidths, alignments must all three be set, if used*
-
-   :param measureLevels: measurement level dictionary ``{varName: <level>}``. Valid levels are: "unknown",  "nominal", "ordinal", "scale", "ratio", "flag", "typeless". Cf. ``VARIABLE LEVEL`` (default: None). 
-
-   :param columnWidths: column display width dictionary ``{varName: <int>}``. Cf. ``VARIABLE WIDTH``.   (default: None --> >= 10 [stringVars] or automatic [numVars]). 
-
-   :param alignments: alignment dictionary ``{varName: <left/center/right>}`` Cf. ``VARIABLE ALIGNMENT``  (default: None --> numerical: right, string: left). 
-
-   :param varSets: sets dictionary ``{setName: [list_of_valid_varNames]}``. Cf. ``SETMACRO`` extension  command. (default: None). 
-
-   :param varRoles: variable roles dictionary ``{varName: varRole}``. VarRoles may be any of the following:  'both', 'frequency', 'input', 'none', 'partition', 'record ID', 'split', 'target'. Cf. ``VARIABLE ROLE``  (default: None). 
-
-   :param varAttributes: variable attributes dictionary ``{varName: {attribName: attribValue}`` (default:  None). Cf. ``VARIABLE  ATTRIBUTES``. (default: None). For example:
-
-      .. code:: python
-
-         varAttributes = {'gender': {'Binary': 'Yes'}, 'educ': {'DemographicVars': '1'}}
-
-   :param fileAttributes: file attributes dictionary ``{attribName: attribValue}``. Square brackets indicate  attribute arrays, which must  start with 1. Cf. ``FILE ATTRIBUTES``. (default: None). For example:
-
-      .. code:: python
-
-         fileAttributes = {'RevisionDate[1]': '10/29/2004', 'RevisionDate[2]': '10/21/2005'} 
-
-   :param fileLabel: file label string, which defaults to "File created by user <username> at <datetime>" if  file label is None. Cf. ``FILE LABEL`` (default: None). 
-
-   :param multRespDefs: Multiple response sets definitions (dichotomy groups or category groups) dictionary ``{setName: <set definition>}``. In SPSS syntax, 'setName' has a dollar prefix ('$someSet'). See also  docstring of multRespDefs method. Cf. ``MRSETS``. (default: None). 
-
-   :param caseWeightVar: valid varName that is set as case weight. Cf. ``WEIGHT BY`` command). 
-
-   :param overwrite: Boolean that indicates whether an existing Spss file should be overwritten (default: True). 
-
-   :param ioUtf8: Boolean that indicates the mode in which text communicated to or from the I/O Module will  be. Valid values are True (UTF-8/unicode mode, cf. ``SET UNICODE=ON``) or False (Codepage mode, ``SET  UNICODE=OFF``) (default: False). 
-
-   :param ioLocale: indicates the locale of the I/O module, cf. ``SET LOCALE`` (default: None, which is the  same as ``".".join(locale.getlocale())``. Locale specification is OS-dependent. 
-
-   :param mode: indicates the mode in which <savFileName> should be opened. Possible values are "wb" (write),  "ab" (append), "cp" (copy: initialize header using <refSavFileName> as a reference file, cf. ``APPLY DICTIONARY``). (default: "wb"). 
-
-   :param refSavFileName: reference file that should be used to initialize the header (aka the SPSS data  dictionary) containing variable label, value label, missing value, etc, etc definitions. Only relevant  in conjunction with mode="cp". (default: None). 
-
-
-Typical use::
-    
-    savFileName = "someFile.sav"
-    records = [['Test1', 1, 1], ['Test2', 2, 1]]
-    varNames = ['var1', 'v2', 'v3']
-    varTypes = {'var1': 5, 'v2': 0, 'v3': 0}
-    with SavWriter(savFileName, varNames, varTypes) as writer:
-        for record in records:
-            writer.writerow(record)
-
-.. seealso::
-
-    More code examples can be found in the ``doc_tests`` folder
-
-:mod:`SavReader` -- Read Spss system files
-============================================================================
-.. function:: SavReader(savFileName, [returnHeader=False, recodeSysmisTo=None,                 verbose=False, selectVars=None, idVar=None, rawMode=False, ioUtf8=False, ioLocale=None])
-
-   **Read Spss system files (.sav, .zsav)**
-
-   :param savFileName: the file name of the spss data file
-
-   :param returnHeader: Boolean that indicates whether the first record should be a list of variable names (default = False)
-
-   :param recodeSysmisTo: indicates to which value missing values should be recoded (default = None, i.e. no recoding is done)
-
-   :param selectVars: indicates which variables in the file should be selected. The variables should be  specified as a list or a tuple of valid variable names. If None is specified, all variables in the file are used (default = None)
-
-   :param idVar: indicates which variable in the file should be used for use as id variable for the 'get'  method (default = None)
-
-   :param verbose: Boolean that indicates whether information about the spss data file (e.g., number of cases,  variable names, file size) should be printed on the screen (default = False).
-
-   :param rawMode: Boolean that indicates whether values should get SPSS-style formatting, and whether date variables (if present) should be converted to ISO-dates. If True, the program does not format any values, which increases processing speed. (default = False)
-
-   :param ioUtf8: Boolean that indicates the mode in which text communicated to or from the I/O Module will be. Valid values are True (UTF-8 mode aka Unicode mode) and False (Codepage mode). Cf. ``SET UNICODE=ON/OFF`` (default = False)
-
-   :param ioLocale: indicates the locale of the I/O module. Cf. ``SET LOCALE`` (default = None, which corresponds to ``".".join(locale.getlocale())``)
-
-.. warning::
-
-   Once a file is open, ``ioUtf8`` and ``ioLocale`` can not be changed. The same applies after a file could not be successfully closed. Always ensure a file is closed by calling ``__exit__()`` (i.e., using a context manager) or ``close()`` (in a ``try - finally`` suite)
-
-Typical use::
-    
-    savFileName = "someFile.sav"
-    with SavReader(savFileName, returnHeader=True) as sav:
-        header = sav.next()
-        for line in sav:
-            process(line)
-
-Use of __getitem__ and other methods::
-    
-    data = SavReader(savFileName, idVar="id")
-    with data:
-        print "The file contains %d records" % len(data)
-        print unicode(data)  # prints a file report
-        print "The first six records look like this\n", data[:6]
-        print "The first record looks like this\n", data[0]
-        print "The last four records look like this\n", data.tail(4)
-        print "The first five records look like this\n", data.head()
-        print "First column:\n", data[..., 0]  # requires numpy
-        print "Row 4 & 5, first three cols\n", data[4:6, :3]  # requires numpy
-        ## ... Do a binary search for records --> idVar
-        print data.get(4, "not found")  # gets 1st record where id==4
-
-
-.. seealso::
-
-    More code examples can be found in the ``doc_tests`` folder
-
-:mod:`SavHeaderReader` -- Read Spss file meta data
-============================================================================
-.. function:: SavHeaderReader(savFileName[, ioUtf8=False, ioLocale=None])
-	
-   **Read Spss file meta data. Yields the same information as the Spss command ``DISPLAY DICTIONARY``**
-
-
-   :param savFileName: the file name of the spss data file
-
-   :param ioUtf8: Boolean that indicates the mode in which text communicated to or from the I/O Module will be. Valid values are True (UTF-8 mode aka Unicode mode) and False (Codepage mode). Cf. ``SET UNICODE=ON/OFF`` (default = False)
-
-   :param ioLocale: indicates the locale of the I/O module. Cf. ``SET LOCALE`` (default = None, which corresponds to ``".".join(locale.getlocale())``)
-
-.. warning::
-
-   The program calls ``spssFree*`` C functions to free memory allocated to dynamic arrays. This previously sometimes caused segmentation faults. This problem now appears to be solved. However, if you do experience segmentation faults you can set ``segfaults=True`` in ``__init__.py``. This will prevent the spssFree* functions from being called (and introduce a memory leak).
-
-Typical use::
-
-    with SavHeaderReader(savFileName) as spssDict:
-        wholeDict = spssDict.dataDictionary()
-        print unicode(spssDict)
-
-.. seealso::
-
-    More code examples can be found in the ``doc_tests`` folder
-
-Indices and tables
-==================
-
-* :ref:`genindex`
-* :ref:`modindex`
-* :ref:`search`
-

savReaderWriter/documentation/make.bat

File contents unchanged.

savReaderWriter/documentation/setupwfc

File contents unchanged.

savReaderWriter/error.py

File contents unchanged.

savReaderWriter/generic.py

                    "encode file name %r [%s]")
             raise ValueError(msg % (encoding, fn, e))
 
-    def _loadLibs(self, path):
+    def _loadLibs(self, folder):
         """Helper function that loads I/O libraries in the correct order"""
         # Get a list of all the files in the spssio dir for a given OS
         # Sort the list in the order in which the libs need to be loaded
         # Using regex patterns ought to be more resilient to updates of the
         # I/O modules, compared to hardcoding the names
+        debug = False
+        path = os.path.join(os.path.dirname(__file__), "spssio", folder)
         libs = sorted(os.listdir(path))
-        pats = ['(lib)?icudata', '(lib)?icuuc', '(lib)?icui',
+        pats = ['(lib)?icuda?t', '(lib)?icuuc', '(lib)?icui',
                 '(lib)?zlib', '(lib)?spssd?io', '(lib)?spssjdio']
         libs = [lib for pat in pats for lib in libs if re.match(pat, lib)]
+        isLib = r"""\w+(\.s[ol](?:\.\d+)*| # linux/hp/solaris
+                    \.\d+\.a|              # aix
+                    \.dll|                 # windows
+                    (\.\d+)*\.dylib)$      # mac""" # filter out non-libs
+        libs = [lib for lib in libs if re.match(isLib, lib, re.I | re.X)]
         load = WinDLL if sys.platform.lower().startswith("win") else CDLL
+        if libs and debug:
+            assert len(libs) == 6, "SPSS I/O needs to load 6 libraries!"
+            print os.path.basename(path).upper().center(79, "-")
+            print "\n".join(libs)
         return [load(os.path.join(path, lib)) for lib in libs][-2]
 
     def loadLibrary(self):
         arch = platform.architecture()[0]
         is_32bit, is_64bit = arch == "32bit", arch == "64bit"
         pf = sys.platform.lower()
-        path = os.path.join(os.path.dirname(__file__), "spssio")
-        join = os.path.join
 
         # windows
         if pf.startswith("win") and is_32bit:
-            spssio = self._loadLibs(join(path, "win32"))
+            spssio = self._loadLibs("win32")
         elif pf.startswith("win"):
-            spssio = self._loadLibs(join(path, "win64"))
+            spssio = self._loadLibs("win64")
 
         # linux
         elif pf.startswith("lin") and is_32bit:
-            spssio = self._loadLibs(join(path, "lin32"))
+            spssio = self._loadLibs("lin32")
         elif pf.startswith("lin") and is_64bit and os.uname()[-1] == "s390x":
             # zLinux64: Thanks Anderson P. from System z Linux LinkedIn Group!
-            spssio = self._loadLibs(path, "zlinux")[-1]
+            spssio = self._loadLibs("zlinux")
         elif pf.startswith("lin") and is_64bit:
-            spssio = self._loadLibs(path, "lin32")[-1]
+            spssio = self._loadLibs("lin32")
 
         # other
         elif pf.startswith("darwin") or pf.startswith("mac"):
             # Mac: Thanks Rich Sadowsky!
-            spssio = self._loadLibs(path, "macos")[-1]
+            spssio = self._loadLibs("macos")
         elif pf.startswith("aix") and is_64bit:
-            spssio = self._loadLibs(path, "aix64")[-1]
+            spssio = self._loadLibs("aix64")
         elif pf.startswith("hp-ux"):
-            spssio = self._loadLibs(path, "hpux_it")[-1]
+            spssio = self._loadLibs("hpux_it")
         elif pf.startswith("sunos") and is_64bit:
-            spssio = self._loadLibs(path, "sol64")[-1]
+            spssio = self._loadLibs("sol64")
         else:
             msg = "Your platform (%r) is not supported" % pf
             raise NotImplementedError(msg)

savReaderWriter/header.py

File contents unchanged.

savReaderWriter/savHeaderReader.py

File contents unchanged.

savReaderWriter/savReader.py

File contents unchanged.

savReaderWriter/savWriter.py

File contents unchanged.

savReaderWriter/spssio/lin32/libicudata.so.48.1

Binary file added.

savReaderWriter/spssio/lin32/libicui18n.so.48.1

Binary file added.

savReaderWriter/spssio/lin32/libicuuc.so.48.1

Binary file added.

savReaderWriter/spssio/lin32/libspssjdio.so.1

Binary file added.

savReaderWriter/spssio/lin32/libzlib123spss.so

Binary file added.

savReaderWriter/test_data/Employee data.sav

Binary file modified.

savReaderWriter/test_data/greetings.sav

Binary file modified.

savReaderWriter/test_data/spssio_test.pdf

Binary file modified.

savReaderWriter/test_data/spssio_test.sav

Binary file modified.

savReaderWriter/test_data/spssio_test.sps

File contents unchanged.

savReaderWriter/test_data/spssio_test.spv

Binary file modified.
-#!/usr/bin/env python
-# -*- coding: utf-8 -*-
-
-# python setup.py sdist --formats=gztar,zip bdist --formats=rpm,wininst
-# sudo python setup.py register -r https://testpypi.python.org/pypi sdist --formats=gztar upload -r https://testpypi.python.org/pypi
-# sudo python setup.py check build_sphinx --source-dir=savReaderWriter/documentation -v
-# sudo python setup.py check upload_sphinx --upload-dir=build/sphinx/html
-#cd /home/antonia/Desktop/savReaderWriter/dist
-#sudo py2dsc savReaderWriter-3.1.2b.tar.gz
-#cd deb_dist/savreaderwriter-3.1.2b/
-#sudo dpkg-buildpackage -rfakeroot -uc -us
-
-import os
-import shutil
-import sys
-import platform
-
-sys.path.append(os.path.dirname(os.path.realpath(__file__)))
-from ez_setup import use_setuptools
-use_setuptools()
-from setuptools import setup
-
-def read(fname):
-    return open(os.path.join(os.path.dirname(__file__), fname)).read().strip()
-
-#####
-## Set package_data values, depending on install/build
-#####
-args = sys.argv
-
-is_32bit = platform.architecture()[0] == "32bit"
-is_64bit = platform.architecture()[0] == "64bit"
-is_install_mode = 'install' in args
-is_only_bdist = 'bdist' in args and not 'sdist' in args
-is_msi32 = is_only_bdist and '--formats=wininst' in args
-is_rpm32 = is_only_bdist and '--formats=rpm' in args
-is_deb = args[-2:] == ['--command-packages=stdeb.command', 'bdist_deb']
-pf = sys.platform.lower()
-
-## This is included in every platform
-package_data = {'savReaderWriter': ['spssio/include/*.*',
-                                    'spssio/documents/*',
-                                    'spssio/license/*',
-                                    'cWriterow/*.*',
-                                    'documentation/*',
-                                    'doc_tests/*.*',
-                                    'test_data/*.*',
-                                    'README','VERSION', 
-                                    'TODO', 'COPYRIGHT']}
-
-## *installing* the package: install only platform-relevant libraries
-if is_install_mode:             
-    if pf.startswith("win") and is_32bit:
-        package_data['savReaderWriter'].append('spssio/win32/*.*')
-    elif pf.startswith("win"):
-        package_data['savReaderWriter'].append('spssio/win64/*.*')
-    elif pf.startswith("lin") and is_32bit:
-        package_data['savReaderWriter'].append('spssio/lin32/*.*')
-    elif pf.startswith("lin") and is_64bit and os.uname()[-1] == "s390x":
-        package_data['savReaderWriter'].append('spssio/zlinux64/*.*')
-    elif pf.startswith("lin") and is_64bit:
-        package_data['savReaderWriter'].append('spssio/lin64/*.*')
-    elif pf.startswith("darwin") or pf.startswith("mac"):
-        package_data['savReaderWriter'].append('spssio/macos/*.*')
-    elif pf.startswith("aix") and not is_32bit:
-        package_data['savReaderWriter'].append('spssio/aix64/*.*')
-    elif pf.startswith("hp-ux"):
-        package_data['savReaderWriter'].append('spssio/hp-ux/*.*')
-    elif pf.startswith("sunos") and not is_32bit:
-        package_data['savReaderWriter'].append('spssio/sol64/*.*')
-    else:
-        msg = "Your platform (%r) is not supported" % pf
-        raise NotImplementedError(msg)
-
-## Two 'light-weight' binary distributions
-elif is_rpm32 or is_deb:
-    package_data['savReaderWriter'].append('spssio/lin32/*.*')
-
-elif is_msi32:
-    package_data['savReaderWriter'].append('spssio/win32/*.*')
-
-## *building* the package: include all the libraries
-else: 
-    package_data['savReaderWriter'].extend(['spssio/win64/*.*',
-                                            'spssio/macos/*.*',
-                                            'spssio/win32/*.*',
-                                            'spssio/sol64/*.*',
-                                            'spssio/lin32/*.*',
-                                            'spssio/lin64/*.*',
-                                            'spssio/hpux_it/*.*',
-                                            'spssio/zlinux64/*.*',
-                                            'spssio/aix64/*.*'])
-
-email = "@".join(["fomcl", "yahoo.com"])
-
-setup(name='savReaderWriter',
-      version=read('VERSION'),
-      description='Read and write SPSS files',
-      author='Albert-Jan Roskam',
-      author_email=email,
-      maintainer='Albert-Jan Roskam',
-      maintainer_email=email,
-      license='MIT',
-      long_description=read('README'),
-      zip_safe=False,
-      platforms=['Windows', 'Mac', 'Linux/POSIX'],
-      url='https://bitbucket.org/fomcl/savreaderwriter',
-      download_url='https://bitbucket.org/fomcl/savreaderwriter/downloads',
-      extras_require={'fastReading': ["psyco"],
-                      'arraySlicing': ["numpy"],
-                      'fastWriting': ["Cython"],},
-      packages=['savReaderWriter'],
-      package_data=package_data,
-      classifiers=['Development Status :: 4 - Beta',
-                   'Intended Audience :: Developers',
-                   'License :: OSI Approved :: MIT License',
-                   'Operating System :: MacOS',
-                   'Operating System :: Microsoft :: Windows',
-                   'Operating System :: POSIX',
-                   'Programming Language :: Cython',
-                   'Programming Language :: Python :: 2.6',
-                   'Programming Language :: Python :: 2.7',
-                   'Programming Language :: Python :: Implementation :: CPython',
-                   'Topic :: Database']
-      )
-
-# ugly, but it works
-for f in ['README','VERSION', 'TODO', 'COPYRIGHT']:
-    p = os.path.dirname(__file__)
-    src = os.path.join(p, f)
-    dst = os.path.join(p, "savReaderWriter", f)
-    shutil.copy(src, dst)
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+
+# python setup.py sdist --formats=gztar,zip bdist --formats=rpm,wininst
+# sudo python setup.py register -r https://testpypi.python.org/pypi sdist --formats=gztar bdist --formats=egg upload -r https://testpypi.python.org/pypi
+# sudo python setup.py check build_sphinx --source-dir=savReaderWriter/documentation -v
+# sudo python setup.py check upload_sphinx --upload-dir=build/sphinx/html
+#cd /home/antonia/Desktop/savReaderWriter/dist
+#sudo python setup.py --command-packages=stdeb.command bdist_deb
+#sudo py2dsc savReaderWriter-3.1.2b.tar.gz
+#cd deb_dist/savreaderwriter-3.1.2b/
+#sudo dpkg-buildpackage -rfakeroot -uc -us
+
+import os
+import shutil
+import sys
+import platform
+
+sys.path.append(os.path.dirname(os.path.realpath(__file__)))
+from ez_setup import use_setuptools
+use_setuptools()
+from setuptools import setup
+
+def read(fname):
+    return open(os.path.join(os.path.dirname(__file__), fname)).read().strip()
+
+#####
+## Set package_data values, depending on install/build
+#####
+args = sys.argv
+
+is_32bit = platform.architecture()[0] == "32bit"
+is_64bit = platform.architecture()[0] == "64bit"
+is_install_mode = 'install' in args
+is_only_bdist = 'bdist' in args and not 'sdist' in args
+is_msi32 = is_only_bdist and ('--formats=wininst' in args or '--formats=msi' in args)
+is_rpm32 = is_only_bdist and '--formats=rpm' in args
+is_deb = args[-2:] == ['--command-packages=stdeb.command', 'bdist_deb']
+pf = sys.platform.lower()
+
+## This is included in every platform
+package_data = {'savReaderWriter': ['spssio/include/*.*',
+                                    'spssio/documents/*',
+                                    'spssio/license/*',
+                                    'cWriterow/*.*',
+                                    'documentation/*',
+                                    'doc_tests/*.*',
+                                    'test_data/*.*',
+                                    'README','VERSION', 
+                                    'TODO', 'COPYRIGHT']}
+
+## *installing* the package: install only platform-relevant libraries
+if is_install_mode:             
+    if pf.startswith("win") and is_32bit:
+        package_data['savReaderWriter'].append('spssio/win32/*.*')
+    elif pf.startswith("win"):
+        package_data['savReaderWriter'].append('spssio/win64/*.*')
+    elif pf.startswith("lin") and is_32bit:
+        package_data['savReaderWriter'].append('spssio/lin32/*.*')
+    elif pf.startswith("lin") and is_64bit and os.uname()[-1] == "s390x":
+        package_data['savReaderWriter'].append('spssio/zlinux64/*.*')
+    elif pf.startswith("lin") and is_64bit:
+        package_data['savReaderWriter'].append('spssio/lin64/*.*')
+    elif pf.startswith("darwin") or pf.startswith("mac"):
+        package_data['savReaderWriter'].append('spssio/macos/*.*')
+    elif pf.startswith("aix") and not is_32bit:
+        package_data['savReaderWriter'].append('spssio/aix64/*.*')
+    elif pf.startswith("hp-ux"):
+        package_data['savReaderWriter'].append('spssio/hp-ux/*.*')
+    elif pf.startswith("sunos") and not is_32bit:
+        package_data['savReaderWriter'].append('spssio/sol64/*.*')
+    else:
+        msg = "Your platform (%r) is not supported" % pf
+        raise NotImplementedError(msg)
+
+## Two 'light-weight' binary distributions
+elif is_rpm32 or is_deb:
+    package_data['savReaderWriter'].append('spssio/lin32/*.*')
+
+elif is_msi32:
+    package_data['savReaderWriter'].append('spssio/win32/*.*')
+
+## *building* the package: include all the libraries
+else: 
+    package_data['savReaderWriter'].extend(['spssio/win64/*.*',
+                                            'spssio/macos/*.*',
+                                            'spssio/win32/*.*',
+                                            'spssio/sol64/*.*',
+                                            'spssio/lin32/*.*',
+                                            'spssio/lin64/*.*',
+                                            'spssio/hpux_it/*.*',
+                                            'spssio/zlinux64/*.*',
+                                            'spssio/aix64/*.*'])
+
+email = "@".join(["fomcl", "yahoo.com"])
+
+setup(name='savReaderWriter',
+      version=read('VERSION'),
+      description='Read and write SPSS files',
+      author='Albert-Jan Roskam',
+      author_email=email,
+      maintainer='Albert-Jan Roskam',
+      maintainer_email=email,
+      license='MIT',
+      long_description=read('README'),
+      zip_safe=False,
+      platforms=['Windows', 'Mac', 'Linux/POSIX'],
+      url='https://bitbucket.org/fomcl/savreaderwriter',
+      download_url='https://bitbucket.org/fomcl/savreaderwriter/downloads',
+      extras_require={'fastReading': ["psyco"],
+                      'arraySlicing': ["numpy"],
+                      'fastWriting': ["Cython"],},
+      packages=['savReaderWriter'],
+      package_data=package_data,
+      classifiers=['Development Status :: 4 - Beta',
+                   'Intended Audience :: Developers',
+                   'License :: OSI Approved :: MIT License',
+                   'Operating System :: MacOS',
+                   'Operating System :: Microsoft :: Windows',
+                   'Operating System :: POSIX',
+                   'Programming Language :: Cython',
+                   'Programming Language :: Python :: 2.6',
+                   'Programming Language :: Python :: 2.7',
+                   'Programming Language :: Python :: Implementation :: CPython',
+                   'Topic :: Database']
+      )
+
+# ugly, but it works
+for f in ['README','VERSION', 'TODO', 'COPYRIGHT']:
+    p = os.path.dirname(__file__)
+    src = os.path.join(p, f)
+    dst = os.path.join(p, "savReaderWriter", f)
+    shutil.copy(src, dst)