diff --git a/setup.py b/setup.py
index <HASH>..<HASH> 100644
--- a/setup.py
+++ b/setup.py
@@ -1,6 +1,7 @@
 #!/usr/bin/env python

 # Generated by jaraco.develop (https://bitbucket.org/jaraco/jaraco.develop)

 import io

+import sys

 

 import setuptools

 

@@ -9,6 +10,11 @@ with io.open('README.txt', encoding='utf-8') as readme:
 with io.open('CHANGES.txt', encoding='utf-8') as changes:

 	long_description += '\n\n' + changes.read()

 

+needs_pytest = {'pytest', 'test'}.intersection(sys.argv)

+pytest_runner = ['pytest_runner'] if needs_pytest else []

+needs_sphinx = {'release', 'build_sphinx', 'upload_docs'}.intersection(sys.argv)

+sphinx = ['sphinx'] if needs_sphinx else []

+

 setup_params = dict(

 	name='jaraco.itertools',

 	use_hg_version=True,

@@ -25,9 +31,7 @@ setup_params = dict(
 	],

 	setup_requires=[

 		'hgtools',

-		'pytest-runner',

-		'sphinx',

-	],

+	] + pytest_runner + sphinx,

 	tests_require=[

 		'pytest',

 	],
Make pytest_runner and sphinx optionally required.