2013-10-28 23:26:44 +00:00
|
|
|
#!/usr/bin/env python
|
2013-10-29 16:43:41 +00:00
|
|
|
from setuptools import setup
|
|
|
|
from distutils.core import Command
|
2013-10-29 20:44:13 +00:00
|
|
|
from setuptools.command.install import install
|
|
|
|
from setuptools.command.develop import develop
|
2013-10-28 23:26:44 +00:00
|
|
|
|
2013-10-29 16:43:41 +00:00
|
|
|
import os
|
|
|
|
import sys
|
2013-10-29 20:44:13 +00:00
|
|
|
import logging
|
|
|
|
logging.basicConfig(level=logging.INFO)
|
|
|
|
|
|
|
|
# Make sure we can import stuff from here.
|
2013-10-29 16:43:41 +00:00
|
|
|
current_dir = os.path.dirname(__file__)
|
|
|
|
sys.path.insert(0, current_dir)
|
2013-10-28 23:26:44 +00:00
|
|
|
|
2013-10-29 20:44:13 +00:00
|
|
|
from wordfreq import config, transfer
|
2013-10-28 23:26:44 +00:00
|
|
|
|
|
|
|
classifiers=[
|
|
|
|
'Intended Audience :: Developers',
|
|
|
|
'Intended Audience :: Science/Research',
|
|
|
|
'License :: OSI Approved :: MIT License',
|
|
|
|
'Natural Language :: English',
|
|
|
|
'Operating System :: MacOS',
|
|
|
|
'Operating System :: Microsoft :: Windows',
|
|
|
|
'Operating System :: POSIX',
|
|
|
|
'Operating System :: Unix',
|
|
|
|
'Programming Language :: C',
|
|
|
|
'Programming Language :: Python :: 2',
|
|
|
|
'Programming Language :: Python :: 2.7',
|
|
|
|
'Programming Language :: Python :: 3',
|
|
|
|
'Programming Language :: Python :: 3.3',
|
|
|
|
'Topic :: Scientific/Engineering',
|
|
|
|
'Topic :: Software Development',
|
|
|
|
'Topic :: Text Processing :: Linguistic',]
|
|
|
|
|
2013-10-29 16:43:41 +00:00
|
|
|
README_contents = open(os.path.join(current_dir, 'README.txt')).read()
|
2013-10-28 23:26:44 +00:00
|
|
|
doclines = README_contents.split("\n")
|
|
|
|
|
2013-10-29 20:44:13 +00:00
|
|
|
|
|
|
|
class SimpleCommand(Command):
|
|
|
|
"""
|
|
|
|
Get the boilerplate out of the way for commands that take no options.
|
|
|
|
"""
|
|
|
|
user_options = []
|
|
|
|
|
|
|
|
def initialize_options(self):
|
|
|
|
pass
|
|
|
|
|
|
|
|
def finalize_options(self):
|
|
|
|
pass
|
|
|
|
|
2013-10-30 18:59:26 +00:00
|
|
|
|
2013-10-29 20:44:13 +00:00
|
|
|
class BuildDatabaseCommand(SimpleCommand):
|
|
|
|
description = "Build the word frequency database from raw data"
|
|
|
|
def run(self):
|
|
|
|
from wordfreq.build import load_all_data
|
|
|
|
load_all_data()
|
|
|
|
|
|
|
|
|
|
|
|
class DownloadDatabaseCommand(SimpleCommand):
|
|
|
|
description = "Download the built word frequency database"
|
|
|
|
user_options = []
|
|
|
|
|
|
|
|
def run(self):
|
|
|
|
transfer.download_db()
|
|
|
|
|
|
|
|
|
|
|
|
class DownloadRawDataCommand(SimpleCommand):
|
|
|
|
description = "Download the raw wordlist data"
|
|
|
|
user_options = []
|
|
|
|
|
|
|
|
def run(self):
|
|
|
|
transfer.download_and_extract_raw_data()
|
|
|
|
|
|
|
|
|
|
|
|
class UploadDataCommand(SimpleCommand):
|
|
|
|
description = "Upload the raw data and database"
|
|
|
|
user_options = []
|
|
|
|
|
|
|
|
def run(self):
|
|
|
|
transfer.upload_data()
|
|
|
|
|
|
|
|
|
|
|
|
class CustomInstallCommand(install):
|
|
|
|
def run(self):
|
|
|
|
install.run(self)
|
2013-10-31 18:12:04 +00:00
|
|
|
if not os.path.exists(config.DB_FILENAME):
|
|
|
|
self.run_command('download_db')
|
2013-10-29 20:44:13 +00:00
|
|
|
|
|
|
|
|
|
|
|
class CustomDevelopCommand(develop):
|
|
|
|
def run(self):
|
|
|
|
develop.run(self)
|
2013-10-31 18:12:04 +00:00
|
|
|
if not os.path.exists(config.DB_FILENAME):
|
|
|
|
self.run_command('download_db')
|
2013-10-29 20:44:13 +00:00
|
|
|
|
|
|
|
|
2013-10-30 16:06:41 +00:00
|
|
|
requirements = ['ftfy >= 3']
|
|
|
|
if sys.version_info.major == 2:
|
2013-10-31 18:06:06 +00:00
|
|
|
requirements.append('functools32')
|
2013-10-30 16:06:41 +00:00
|
|
|
|
2013-10-28 23:26:44 +00:00
|
|
|
setup(
|
|
|
|
name="wordfreq",
|
2013-10-29 20:44:13 +00:00
|
|
|
version=config.VERSION,
|
2013-10-28 23:26:44 +00:00
|
|
|
maintainer='Luminoso Technologies, Inc.',
|
|
|
|
maintainer_email='dev@luminoso.com',
|
|
|
|
url='http://github.com/LuminosoInsight/wordfreq/',
|
|
|
|
license = "MIT",
|
|
|
|
platforms = ["any"],
|
|
|
|
description = doclines[0],
|
|
|
|
classifiers = classifiers,
|
|
|
|
long_description = "\n".join(doclines[2:]),
|
|
|
|
packages=['wordfreq'],
|
2013-10-30 16:06:41 +00:00
|
|
|
install_requires=requirements,
|
2013-10-29 20:44:13 +00:00
|
|
|
cmdclass = {
|
|
|
|
'build_db': BuildDatabaseCommand,
|
|
|
|
'download_db': DownloadDatabaseCommand,
|
|
|
|
'download_raw': DownloadRawDataCommand,
|
|
|
|
'upload_data': UploadDataCommand,
|
|
|
|
'install': CustomInstallCommand,
|
|
|
|
'develop': CustomDevelopCommand
|
|
|
|
}
|
2013-10-28 23:26:44 +00:00
|
|
|
)
|