Skip to content

Commit d5655f7

Browse files
authored
Merge pull request #11 from dipcode-software/feat/md-to-rst
refactor to setup.py to accept a publish
2 parents 422c534 + 5d49fca commit d5655f7

File tree

1 file changed

+80
-8
lines changed

1 file changed

+80
-8
lines changed

setup.py

+80-8
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,85 @@
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'
270

371

472
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,
780
packages=find_packages(),
881
include_package_data=True,
982
license='MIT',
10-
description='Django app to obfuscate data.',
11-
url='https://github.com/dipcode-software/django-obfuscator',
12-
author='Dipcode',
13-
author_email='[email protected]',
14-
keywords=['django', 'django-models', 'models', 'obfuscator'],
1583
classifiers=[
1684
'Environment :: Web Environment',
1785
'Framework :: Django',
@@ -22,6 +90,10 @@
2290
'Programming Language :: Python',
2391
'Programming Language :: Python :: 2.7',
2492
],
93+
cmdclass={
94+
'publish_dev': DevelopmentPublishCommand,
95+
'publish_prod': ProductionPublishCommand,
96+
},
2597
install_requires=[
2698
'setuptools-git >= 1.2'
2799
]

0 commit comments

Comments
 (0)