|
1 |
| -from setuptools import find_packages, setup |
| 1 | +# -*- coding: utf-8 -*- |
| 2 | +from __future__ import unicode_literals |
| 3 | + |
| 4 | +import io |
| 5 | +import os |
| 6 | +from shutil import rmtree |
| 7 | +import sys |
| 8 | + |
| 9 | +from setuptools import Command, find_packages, setup |
| 10 | + |
| 11 | + |
| 12 | +# Package meta-data. |
| 13 | +VERSION = __import__("obfuscator").__version__ |
| 14 | +NAME = 'django-obfuscate' |
| 15 | +DESCRIPTION = 'Django app to obfuscate data. ' |
| 16 | +URL = 'https://github.com/dipcode-software/django-obfuscator' |
| 17 | + |
| 18 | +AUTHOR = 'Dipcode' |
| 19 | + |
| 20 | + |
| 21 | +here = os.path.abspath(os.path.dirname(__file__)) |
| 22 | +with io.open(os.path.join(here, 'README.rst'), encoding='utf-8') as f: |
| 23 | + long_description = '\n' + f.read() |
| 24 | + |
| 25 | + |
| 26 | +class PublishCommand(Command): |
| 27 | + """Support setup.py publish.""" |
| 28 | + |
| 29 | + description = 'Build and publish the package.' |
| 30 | + user_options = [] |
| 31 | + environment = None |
| 32 | + |
| 33 | + @staticmethod |
| 34 | + def status(s): |
| 35 | + """Prints things in bold.""" |
| 36 | + print('\033[1m{0}\033[0m'.format(s)) |
| 37 | + |
| 38 | + def initialize_options(self): |
| 39 | + pass |
| 40 | + |
| 41 | + def finalize_options(self): |
| 42 | + pass |
| 43 | + |
| 44 | + def run(self): |
| 45 | + try: |
| 46 | + self.status('Removing previous builds…') |
| 47 | + rmtree(os.path.join(here, 'dist')) |
| 48 | + rmtree(os.path.join(here, 'build')) |
| 49 | + except OSError: |
| 50 | + pass |
| 51 | + |
| 52 | + self.status('Building Source and Wheel distribution…') |
| 53 | + os.system( |
| 54 | + '{0} setup.py sdist bdist_wheel '.format(sys.executable) |
| 55 | + ) |
| 56 | + |
| 57 | + self.status('Uploading the package to {env} via Twine…'\ |
| 58 | + .format(env=self.environment)) |
| 59 | + os.system('twine upload --repository {env} dist/*'.format(env=self.environment)) |
| 60 | + |
| 61 | + sys.exit() |
| 62 | + |
| 63 | + |
| 64 | +class ProductionPublishCommand(PublishCommand): |
| 65 | + environment = 'pypi' |
| 66 | + |
| 67 | + |
| 68 | +class DevelopmentPublishCommand(PublishCommand): |
| 69 | + environment = 'testpypi' |
2 | 70 |
|
3 | 71 |
|
4 | 72 | setup(
|
5 |
| - name='django-obfuscate', |
6 |
| - version=__import__("obfuscator").__version__, |
| 73 | + name=NAME, |
| 74 | + version=VERSION, |
| 75 | + description=DESCRIPTION, |
| 76 | + long_description=long_description, |
| 77 | + author=AUTHOR, |
| 78 | + author_email=EMAIL, |
| 79 | + url=URL, |
7 | 80 | packages=find_packages(),
|
8 | 81 | include_package_data=True,
|
9 | 82 | license='MIT',
|
10 |
| - description='Django app to obfuscate data.', |
11 |
| - url='https://github.com/dipcode-software/django-obfuscator', |
12 |
| - author='Dipcode', |
13 |
| - |
14 |
| - keywords=['django', 'django-models', 'models', 'obfuscator'], |
15 | 83 | classifiers=[
|
16 | 84 | 'Environment :: Web Environment',
|
17 | 85 | 'Framework :: Django',
|
|
22 | 90 | 'Programming Language :: Python',
|
23 | 91 | 'Programming Language :: Python :: 2.7',
|
24 | 92 | ],
|
| 93 | + cmdclass={ |
| 94 | + 'publish_dev': DevelopmentPublishCommand, |
| 95 | + 'publish_prod': ProductionPublishCommand, |
| 96 | + }, |
25 | 97 | install_requires=[
|
26 | 98 | 'setuptools-git >= 1.2'
|
27 | 99 | ]
|
|
0 commit comments