Skip to main content

Making setup.py clean more useful.

Project description

Version Downloads Status License

Extends the clean command to remove stuff generated by the development process.

Wait… Why? What??

So setup.py clean is useful for developers of C extensions or anything else that takes advantage of the setup.py build command. Pure Python packages generate their own set of artifacts that clutter up the source tree. This package extends the clean command so that it removes the following artifacts as well:

  • The distribution directory as generated by the sdist and bdist* commands

  • Top-level .egg-info and .egg directories that setup.py creates

  • Local virtual environment directories

  • __pycache__ directories

I come from a C/C++ background where the Makefile usually provide house keeping targets such as clean, dist-clean, and maintainer-clean. This extension is inspired by the same desire for a clean working environment.

Installation

The setuptools package contains a number of interesting ways in which it can be extended. If you develop Python packages, then you can include extension packages using the setup_requires and cmdclass keyword parameters to the setup function call. This is a little more difficult than it should be since the setupext package needs to be imported into setup.py so that it can be passed as a keyword parameter before it is downloaded. The easiest way to do this is to catch the ImportError that happens if it is not already downloaded:

import setuptools
try:
   from setupext import janitor
   CleanCommand = janitor.CleanCommand
except ImportError:
   CleanCommand = None

cmd_classes = {}
if CleanCommand is not None:
   cmd_classes['clean'] = CleanCommand

setup(
   # normal parameters
   setup_requires=['setupext.janitor'],
   cmdclass=cmd_classes,
)

You can use a different approach if you are simply a developer that wants to have this functionality available for your own use, then you can install it into your working environment. This package installs itself into the environment as a distutils extension so that it is available to any setup.py script as if by magic.

Usage

Once the extension is installed, the clean command will accept a few new command line parameters.

setup.py clean --dist

Removes directories that the various dist commands produce.

setup.py clean --egg

Removes .egg and .egg-info directories.

setup.py clean --environment

Removes the currently active virtual environment as indicated by the $VIRTUAL_ENV environment variable. The name of the directory can also be specified using the --virtualenv-dir command line option.

setup.py clean --pycache

Recursively removes directories named __pycache__.

setup.py clean --all

Remove all of by-products. This is the same as using --dist --egg --environment --pycache.

Where can I get this extension from?

Source

https://github.com/dave-shawley/setupext-janitor

Status

https://travis-ci.org/dave-shawley/setupext-janitor

Download

https://pypi.python.org/pypi/setupext-janitor

Documentation

http://setupext-janitor.readthedocs.org/en/latest

Issues

https://github.com/dave-shawley/setupext-janitor

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

setupext-janitor-1.0.0.tar.gz (9.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

setupext_janitor-1.0.0-py2.py3-none-any.whl (8.5 kB view details)

Uploaded Python 2Python 3

File details

Details for the file setupext-janitor-1.0.0.tar.gz.

File metadata

File hashes

Hashes for setupext-janitor-1.0.0.tar.gz
Algorithm Hash digest
SHA256 8eecfac00275a31240e148aad95c20614146b3b777c3b0055d1ccb1f07d455be
MD5 6061ba6a21ed8b9db3c0661255f61f3e
BLAKE2b-256 d3495fbf2babab5678b573b3639c5babbd3df480452c0c1fbfc5f2aa862af3c2

See more details on using hashes here.

File details

Details for the file setupext_janitor-1.0.0-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for setupext_janitor-1.0.0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 e0dd92fff4cc34cd1514e3f8a7c89e3540e24a107576a70f1f8dede0f025d0db
MD5 17fa0d9ad16db30dc3ca85bf63a04b99
BLAKE2b-256 4d37962fd314dba9956f47fb5e206fa3f1a46a903ab2512dd412eeb579f27083

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page