Skip to content

Commit

Permalink
setup.py: Correct dependencies (fixes #21)
Browse files Browse the repository at this point in the history
* Move imports to the last minute in setup.py.

* Declare pytz and dateutil as setup dependencies, as the setup process will
  import __init__.py, which in turn imports those two libraries.  In a pip
  or setuptools based install, this will fail.
  • Loading branch information
micolous committed Jan 27, 2016
1 parent 0aa18b6 commit f35a18d
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,17 +26,17 @@
from distutils.core import setup
from distutils.command import sdist, install

from datetime_tz import update_win32tz_map

class update_sdist(sdist.sdist):
def run(self):
from datetime_tz import update_win32tz_map
update_win32tz_map.update_stored_win32tz_map()
sdist.sdist.run(self)

class update_install(install.install):
def run(self):
if not os.path.exists(os.path.join(os.path.dirname(__file__), "datetime_tz", "win32tz_map.py")):
# Running an install from a non-sdist, so need to generate map
from datetime_tz import update_win32tz_map
update_win32tz_map.update_stored_win32tz_map()
install.install.run(self)

Expand All @@ -61,17 +61,22 @@ def run(self):
],
packages=['datetime_tz'],
install_requires=[],
setup_requires=["Genshi"],
setup_requires=['Genshi'],
py_modules=['datetime_tz','datetime_tz.pytz_abbr'],
test_suite='tests',
cmdclass={'sdist': update_sdist, "install": update_install},
)

# Bump this to whatever is latest at the time of release.
# Using old timezone data will return wrong results.
deps = ['pytz >= 2015.7']

This comment has been minimized.

Copy link
@mithro

mithro Jan 27, 2016

Owner

Please don't do this. This should be the earliest version we support. Some people are required to use old tz data for bureaucratic reasons.


if sys.version[:3] < '3.0':
data['install_requires'].append('pytz >= 2007g')
data['install_requires'].append('python-dateutil >= 1.4')
deps += ['python-dateutil >= 1.4']
else:
data['install_requires'].append('pytz >= 2011g')
data['install_requires'].append('python-dateutil >= 2.0')
deps += ['python-dateutil >= 2.0']

data['install_requires'] += deps
data['setup_requires'] += deps

setup(**data)

0 comments on commit f35a18d

Please sign in to comment.