pegler / pytzwhere

python library to look up timezone from lat lng offline
Other
146 stars 54 forks source link

package_data are not installed when installing pytzwhere with pip in a venv #45

Closed seahawk1986 closed 7 years ago

seahawk1986 commented 7 years ago

Hello, when installing tzwhere in a venv with pip using Python 3.6 (or 3.5) both json files 'tz_world.json' and 'tz_world_shortcuts.json' are missing:

$ python3 -m venv test_pytzwhere
$ source test_pytzwhere/bin/activate
(test_pytzwhere) $ pip install tzwhere
(test_pytzwhere) $ tree test_pytzwhere/lib/python3.6/site-packages/tzwhere*
test_pytzwhere/lib/python3.6/site-packages/tzwhere
├── __init__.py
├── __pycache__
│   ├── __init__.cpython-36.pyc
│   └── tzwhere.cpython-36.pyc
└── tzwhere.py
test_pytzwhere/lib/python3.6/site-packages/tzwhere-3.0.1-py3.6.egg-info
├── PKG-INFO
├── SOURCES.txt
├── dependency_links.txt
├── installed-files.txt
├── requires.txt
└── top_level.txt

Removing the Line "include_package_data=True," from the setup.py (https://github.com/pegler/pytzwhere/blob/master/setup.py#L19) seems to fix the problem - is this needed by anything else?

LowieHuyghe commented 7 years ago

I'm having the same problem and would love to see it fixed! Would it be possible to submit a pull request with your changes? Thanks in advance!

seahawk1986 commented 7 years ago

I dug a little deeper into the setuptools documentation (https://setuptools.readthedocs.io/en/latest/setuptools.html?highlight=include_package_data#including-data-files) - the missing entries in the MANIFEST.in for those files seem to be the real cause for the missing files:

if using the setuptools-specific include_package_data argument, files specified by package_data will not be automatically added to the manifest unless they are listed in the MANIFEST.in file.

So including those files to the MANIFEST.in seems to be the better solution (the file tzwhere/tz_world.csv mentioned in MANIFEST.in has been removed in https://github.com/pegler/pytzwhere/commit/df871d2dfaed96a8d537b0f57f2a6d00fd2bb024 )

46 should fix the installation of those files.

pegler commented 7 years ago

Thanks @linwoodc3 and @seahawk1986 for the pull requests. I ended up using @linwoodc3's since it added compression. I just pushed version 3.0.2 to PyPI

linwoodc3 commented 7 years ago

I'm an idiot. Careless mistake. I left the test name in the Manifest file.

This...

tzwhere/worldtest.json.gz

Needs to change to this...

include tzwhere/tz_world.json.gz

That's why the file is missing....

screen shot 2017-08-23 at 10 53 47 pm

pegler commented 7 years ago

@linwoodc3 I just pushed v 3.0.3 with the fix