dbf package requires that I manually install enum34

283 views
Skip to first unread message

Travis Dart

unread,
Aug 2, 2016, 1:28:41 PM8/2/16
to Python dBase
When I try to install the dbf package, I need to manually install enum34.

It appears that enum34 was being installed during the installation described in this other thread ( https://groups.google.com/forum/#!topic/python-dbase/XSEjkI2yvjQ ). Not sure why I have to do it manually.

Below is a reproducible error log:

$ mkvirtualenv testenv
New python executable in testenv/bin/python
Installing setuptools, pip, wheel...done.
(testenv)$ pip install -U pip
You are using pip version 7.1.0, however version 8.1.2 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
Collecting pip
  Using cached pip-8.1.2-py2.py3-none-any.whl
Installing collected packages: pip
  Found existing installation: pip 7.1.0
    Uninstalling pip-7.1.0:
      Successfully uninstalled pip-7.1.0
Successfully installed pip-8.1.2
(testenv)$ pip install dbf
Collecting dbf
  Using cached dbf-0.96.8-py2-none-any.whl
Collecting aenum (from dbf)
  Using cached aenum-1.4.5-py2-none-any.whl
Installing collected packages: aenum, dbf
Successfully installed aenum-1.4.5 dbf-0.96.8
(testenv)$ python
Python 2.7.10 (default, Oct 23 2015, 19:19:21)
[GCC 4.2.1 Compatible Apple LLVM 7.0.0 (clang-700.0.59.5)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import dbf
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/oscargarcia/.virtualenvs/testenv/lib/python2.7/site-packages/dbf/__init__.py", line 11, in <module>
    from dbf import ver_2 as _dbf
  File "/Users/oscargarcia/.virtualenvs/testenv/lib/python2.7/site-packages/dbf/ver_2.py", line 49, in <module>
    from enum import Enum, IntEnum
ImportError: No module named enum
>>> ^D
(testenv)$ pip install enum34
Collecting enum34
  Downloading enum34-1.1.6-py2-none-any.whl
Installing collected packages: enum34
Successfully installed enum34-1.1.6
(testenv)$ python
Python 2.7.10 (default, Oct 23 2015, 19:19:21)
[GCC 4.2.1 Compatible Apple LLVM 7.0.0 (clang-700.0.59.5)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import dbf
>>>
>>> ^D
(testenv)$

Adrian Klaver

unread,
Aug 2, 2016, 2:05:30 PM8/2/16
to python...@googlegroups.com
Well the first thing I would do is not use the cached wheels.

After uninstalling try running the install with -no-cache-dir:

https://pip.pypa.io/en/stable/reference/pip/?highlight=no-cache-dir#cmdoption--no-cache-dir

The requirement is in setup.py:

if sys.version_info[:2] < (3, 4):
requirements = ['enum34']
else:
requirements = []
> --
>
> ---
> You received this message because you are subscribed to the Google
> Groups "Python dBase" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to python-dbase...@googlegroups.com
> <mailto:python-dbase...@googlegroups.com>.
> For more options, visit https://groups.google.com/d/optout.


--
Adrian Klaver
adrian...@aklaver.com

Travis Dart

unread,
Aug 2, 2016, 2:37:10 PM8/2/16
to Python dBase
I tried that, but it still doesn't work.

These are the commands I tried. I also had this issue on another computer.

mkvirtualenv testenv
pip install -U pip
pip install --no-cache-dir dbf
python -c "import dbf"
# returns 1
echo $?
pip install enum34
python -c "import dbf"
# returns 0
echo $?
deactivate
rmvirtualenv testenv

Adrian Klaver

unread,
Aug 2, 2016, 3:35:09 PM8/2/16
to python...@googlegroups.com
On 08/02/2016 11:37 AM, Travis Dart wrote:
> I tried that, but it still doesn't work.
>
> These are the commands I tried. I also had this issue on another computer.
>
> mkvirtualenv testenv
> pip install -U pip
> pip install --no-cache-dir dbf
> python -c "import dbf"
> # returns 1
> echo $?
> pip install enum34
> python -c "import dbf"
> # returns 0
> echo $?
> deactivate
> rmvirtualenv testenv
>
>

Got to be changes in how setuptools works. If I:

Comment out:


#if sys.version_info[:2] < (3, 4):
# requirements = ['enum34']
#else:
# requirements = []

and then add enum34 to install_requires I can build an sdist that when
I pip install pulls in enum34.

I will have to do some more digging on this, but I believe this is
something Ethan is going to have to do on his end to get the packages
from PyPi to work.


--
Adrian Klaver
adrian...@aklaver.com

Adrian Klaver

unread,
Aug 2, 2016, 3:59:44 PM8/2/16
to python...@googlegroups.com
Aah found the magic incantation here:

http://stackoverflow.com/questions/21082091/install-requires-based-on-python-version

So:

try:
import setuptools
except ImportError:
pass
from distutils.core import setup
from glob import glob
import os
import sys

#html_docs = glob('dbf/html/*')

long_desc="""
Currently supports dBase III, Clipper, FoxPro, and Visual FoxPro tables.
Text is returned as unicode, and codepage settings in tables are
honored. Memos and Null fields are supported. Documentation needs work,
but author is very responsive to e-mails.

Not supported: index files (but can create tempory non-file indexes),
auto-incrementing fields, and Varchar fields.

Installation: `pip install dbf`

There may be messages about byte-compiling failures -- you can safely
ignore them (this is a multi-version release, and 2 and 3 don't like
some of each other's code).
"""

#if sys.version_info[:2] < (3, 4):
# requirements = ['enum34']
#else:
# requirements = []

py2_only = ('dbf/ver_2.py', )
py3_only = ('dbf/ver_32.py', 'dbf/ver_33.py')
make = []

data = dict(
name='dbf',
version='0.96.8',
license='BSD License',
description='Pure python package for reading/writing dBase,
FoxPro, and Visual FoxPro .dbf files (including memos)',
long_description=long_desc,
url='https://pypi.python.org/pypi/dbf',
packages=['dbf', ],
provides=['dbf'],
install_requires=['aenum'],
extras_require={':python_version < "3.4"': ["enum34"],},
author='Ethan Furman',
author_email='et...@stoneleaf.us',
classifiers=[
'Development Status :: 4 - Beta',
'Intended Audience :: Developers',
'License :: OSI Approved :: BSD License',
'Programming Language :: Python',
'Topic :: Database',
'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3.3',
'Programming Language :: Python :: 3.4',
'Programming Language :: Python :: 3.5',
],
)

if __name__ == '__main__':
setup(**data)


>
>


--
Adrian Klaver
adrian...@aklaver.com

Ethan Furman

unread,
Aug 4, 2016, 3:44:44 PM8/4/16
to python...@googlegroups.com
On 08/02/2016 10:28 AM, Travis Dart wrote:

> When I try to install the dbf package, I need to manually install enum34.

Totally my fault. Thanks for tracking that down, Adrian.

--
~Ethan~
Reply all
Reply to author
Forward
0 new messages