Add long_description and custom clean command (setup.py)
This commit is contained in:
parent
a0b92e38c8
commit
9413e7b590
2 changed files with 54 additions and 4 deletions
|
@ -34,6 +34,10 @@ No prerequisites are required, all test dependencies will be installed
|
|||
automatically by ``tox`` in virtual environments created on the fly.
|
||||
Unfortunately, you'll have to install ``virtualenv`` for this to work, though.
|
||||
|
||||
To remove all build files and folders including Python byte code you can run::
|
||||
|
||||
$ python setup.py clean
|
||||
|
||||
|
||||
.. |latest-version| image:: https://img.shields.io/pypi/v/django-todo.svg
|
||||
:alt: Latest version on PyPI
|
||||
|
|
54
setup.py
54
setup.py
|
@ -1,9 +1,13 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
from glob import glob
|
||||
from os import remove
|
||||
from os.path import abspath, dirname, join
|
||||
from setuptools import setup, find_packages
|
||||
from setuptools.command.test import test as TestCommand
|
||||
import shlex
|
||||
import sys
|
||||
from shlex import split
|
||||
from shutil import rmtree
|
||||
from sys import exit
|
||||
|
||||
import todo as package
|
||||
|
||||
|
@ -24,14 +28,55 @@ class Tox(TestCommand):
|
|||
import tox
|
||||
args = self.tox_args
|
||||
if args:
|
||||
args = shlex.split(self.tox_args)
|
||||
args = split(self.tox_args)
|
||||
errno = tox.cmdline(args=args)
|
||||
sys.exit(errno)
|
||||
exit(errno)
|
||||
|
||||
|
||||
class Clean(TestCommand):
|
||||
def run(self):
|
||||
delete_in_root = [
|
||||
'build',
|
||||
'dist',
|
||||
'.eggs',
|
||||
'*.egg-info',
|
||||
'.tox',
|
||||
]
|
||||
delete_everywhere = [
|
||||
'__pycache__',
|
||||
'*.pyc',
|
||||
]
|
||||
for candidate in delete_in_root:
|
||||
rmtree_glob(candidate)
|
||||
for visible_dir in glob('[A-Za-z0-9]*'):
|
||||
for candidate in delete_everywhere:
|
||||
rmtree_glob(join(visible_dir, candidate))
|
||||
rmtree_glob(join(visible_dir, '*', candidate))
|
||||
rmtree_glob(join(visible_dir, '*', '*', candidate))
|
||||
|
||||
|
||||
def rmtree_glob(file_glob):
|
||||
for fobj in glob(file_glob):
|
||||
try:
|
||||
rmtree(fobj)
|
||||
print('%s/ removed ...' % fobj)
|
||||
except OSError:
|
||||
try:
|
||||
remove(fobj)
|
||||
print('%s removed ...' % fobj)
|
||||
except OSError:
|
||||
pass
|
||||
|
||||
|
||||
def read_file(*pathname):
|
||||
with open(join(dirname(abspath(__file__)), *pathname)) as f:
|
||||
return f.read()
|
||||
|
||||
setup(
|
||||
name='django-todo',
|
||||
version=package.__version__,
|
||||
description=package.__doc__.strip(),
|
||||
long_description=read_file('README.rst'),
|
||||
author=package.__author__,
|
||||
author_email=package.__email__,
|
||||
url=package.__url__,
|
||||
|
@ -54,6 +99,7 @@ setup(
|
|||
zip_safe=False,
|
||||
tests_require=['tox'],
|
||||
cmdclass={
|
||||
'clean': Clean,
|
||||
'test': Tox,
|
||||
},
|
||||
)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue