Adding installation options
suggest changeAs seen in previous examples, basic use of this script is:
python setup.py install
But there are more options, such as installing the package so you can change the code and test it without reinstalling. This is done using:
python setup.py develop
Direct python setup.py install and python setup.py develop commands are deprecated.
If you want to perform specific actions like compiling a Sphinx documentation or building Fortran code, you can create your own option like this:
from setuptools import Command, setup
cmdclasses = dict()
class BuildSphinx(Command):
"""Build Sphinx documentation."""
description = 'Build Sphinx documentation'
user_options = []
def initialize_options(self):
pass
def finalize_options(self):
pass
def run(self):
from sphinx.cmd.build import build_main
build_main(['-b', 'html', './doc', './doc/_build/html'])
build_main(['-b', 'man', './doc', './doc/_build/man'])
cmdclasses['build_sphinx'] = BuildSphinx
setup(
...,
cmdclass=cmdclasses,
)
initialize_options and finalize_options will be executed before run, as their names suggest. sphinx.build_main was removed in Sphinx 2; sphinx.cmd.build.build_main parses the argument list itself and does not skip a program name. This command was not run here.
After that, you will be able to call your option:
python setup.py build_sphinx
Found a mistake? Have a question or improvement idea?
Let me know.
Table Of Contents