API¶
setuptools-pyproject-migration is only intended for use as a setuptools plugin or a command-line executable, so it does not expose an API to be used as a Python library.
setuptools_pyproject_migration
¶
There should generally be no need to use this API unless you’re trying to invoke setuptools plugins in a custom way, in which case you’re probably better off looking at the setuptools documentation.
- class setuptools_pyproject_migration.WritePyproject(dist: Distribution, **kw)¶
Bases:
Command
- finalize_options()¶
Set final values for all the options that this command supports. This is always called as late as possible, ie. after any option assignments from the command-line or from other commands have been done. Thus, this is the place to code option dependencies: if ‘foo’ depends on ‘bar’, then it is safe to set ‘foo’ from ‘bar’ as long as ‘foo’ still has the same value it was assigned in ‘initialize_options()’.
This method must be implemented by all command classes.
- initialize_options()¶
Set default values for all the options that this command supports. Note that these defaults may be overridden by other commands, by the setup script, by config files, or by the command-line. Thus, this is not the place to code dependencies between options; generally, ‘initialize_options()’ implementations are just a bunch of “self.foo = None” assignments.
This method must be implemented by all command classes.
- run()¶
Write out the contents of a pyproject.toml file containing information ingested from
setup.py
and/orsetup.cfg
.
setuptools_pyproject_migration.cli
¶
This API is only meant for use by this project’s built-in console script. You can call it from Python at your own risk.
A simple command-line interface to the plugin.
- setuptools_pyproject_migration.cli.main() None ¶
Run the
setuptools_pyproject_migration.WritePyproject
setuptools command. This does the same thing aspython setup.py pyproject
, except that ifsetup.py
doesn’t exist, it will act as though there were a “stub”setup.py
script with the following contents:import setuptools setuptools.setup()
Effectively, this lets you use
setuptools-pyproject-migration
without having to install the plugin and without having to create asetup.py
file if all you have issetup.cfg
.Note
This function changes
sys.argv
. If you call this from Python, make sure to restore the original argument list afterwards if your program needs it.