| 1 |
Flit command line interface |
| 2 |
=========================== |
| 3 |
|
| 4 |
All operations use the ``flit`` command, followed by one of a number of |
| 5 |
subcommands. |
| 6 |
|
| 7 |
Common options |
| 8 |
-------------- |
| 9 |
|
| 10 |
.. program:: flit |
| 11 |
|
| 12 |
.. option:: -f <path>, --ini-file <path> |
| 13 |
|
| 14 |
Path to a config file specifying the module to build. The default is |
| 15 |
``pyproject.toml``. |
| 16 |
|
| 17 |
.. option:: --version |
| 18 |
|
| 19 |
Show the version of Flit in use. |
| 20 |
|
| 21 |
.. option:: --help |
| 22 |
|
| 23 |
Show help on the command-line interface. |
| 24 |
|
| 25 |
.. option:: --debug |
| 26 |
|
| 27 |
Show more detailed logs about what flit is doing. |
| 28 |
|
| 29 |
.. _build_cmd: |
| 30 |
|
| 31 |
``flit build`` |
| 32 |
-------------- |
| 33 |
|
| 34 |
.. program:: flit build |
| 35 |
|
| 36 |
Build a wheel and an sdist (tarball) from the package. |
| 37 |
|
| 38 |
.. option:: --format <format> |
| 39 |
|
| 40 |
Limit to building either ``wheel`` or ``sdist``. |
| 41 |
|
| 42 |
.. option:: --use-vcs |
| 43 |
|
| 44 |
Use the files checked in to git or mercurial as the starting list to include |
| 45 |
in an sdist, and then apply inclusions and exclusions :ref:`from pyproject.toml |
| 46 |
<pyproject_toml_sdist>`. |
| 47 |
|
| 48 |
.. option:: --no-use-vcs |
| 49 |
|
| 50 |
Create the sdist starting with only the files inside the installed module |
| 51 |
or package, along with any inclusions and exclusions defined in pyproject.toml. |
| 52 |
|
| 53 |
With this option, sdists from ``flit build`` are equivalent to those built |
| 54 |
by tools calling Flit as a backend, such as `build |
| 55 |
<https://pypa-build.readthedocs.io/en/stable/>`_. |
| 56 |
|
| 57 |
This is the default for Flit version 4 and above. |
| 58 |
|
| 59 |
.. _publish_cmd: |
| 60 |
|
| 61 |
``flit publish`` |
| 62 |
---------------- |
| 63 |
|
| 64 |
.. program:: flit publish |
| 65 |
|
| 66 |
Build a wheel and an sdist (tarball) from the package, and upload them to PyPI |
| 67 |
or another repository. |
| 68 |
|
| 69 |
.. option:: --format <format> |
| 70 |
|
| 71 |
Limit to publishing either ``wheel`` or ``sdist``. |
| 72 |
You should normally publish the two formats together. |
| 73 |
|
| 74 |
.. option:: --use-vcs |
| 75 |
.. option:: --no-use-vcs |
| 76 |
|
| 77 |
These options affecting what goes in the sdist are described for |
| 78 |
:ref:`build_cmd` above. |
| 79 |
|
| 80 |
.. option:: --repository <repository> |
| 81 |
|
| 82 |
Name of a repository to upload packages to. Should match a section in |
| 83 |
``~/.pypirc``. The default is ``pypi``. |
| 84 |
|
| 85 |
.. option:: --pypirc <pypirc> |
| 86 |
|
| 87 |
The .pypirc config file to be used. The default is ``~/.pypirc``. |
| 88 |
|
| 89 |
.. seealso:: :doc:`upload` |
| 90 |
|
| 91 |
.. _install_cmd: |
| 92 |
|
| 93 |
``flit install`` |
| 94 |
---------------- |
| 95 |
|
| 96 |
.. program:: flit install |
| 97 |
|
| 98 |
Install the package on your system. |
| 99 |
|
| 100 |
By default, the package is installed to the same Python environment that Flit |
| 101 |
itself is installed in; use :option:`--python` or :envvar:`FLIT_INSTALL_PYTHON` |
| 102 |
to override this. |
| 103 |
|
| 104 |
If you don't have permission to modify the environment (e.g. the system Python |
| 105 |
on Linux), Flit may do a user install instead. Use the :option:`--user` or |
| 106 |
:option:`--env` flags to force this one way or the other, rather than letting |
| 107 |
Flit guess. |
| 108 |
|
| 109 |
.. option:: -s, --symlink |
| 110 |
|
| 111 |
Symlink the module into site-packages rather than copying it, so that you |
| 112 |
can test changes without reinstalling the module. |
| 113 |
|
| 114 |
.. option:: --pth-file |
| 115 |
|
| 116 |
Create a ``.pth`` file in site-packages rather than copying the module, so |
| 117 |
you can test changes without reinstalling. This is a less elegant alternative |
| 118 |
to ``--symlink``, but it works on Windows, which typically doesn't allow |
| 119 |
symlinks. |
| 120 |
|
| 121 |
.. option:: --deps <dependency option> |
| 122 |
|
| 123 |
Which dependencies to install. One of ``all``, ``production``, ``develop``, |
| 124 |
or ``none``. ``all`` and ``develop`` install the extras ``test``, ``doc``, |
| 125 |
and ``dev``. Default ``all``. |
| 126 |
|
| 127 |
.. option:: --extras <extra[,extra,...]> |
| 128 |
|
| 129 |
Which named extra features to install dependencies for. Specify ``all`` to |
| 130 |
install all optional dependencies, or a comma-separated list of extras. |
| 131 |
Default depends on ``--deps``. |
| 132 |
|
| 133 |
.. option:: --only-deps |
| 134 |
|
| 135 |
Install the dependencies of this package, but not the package itself. |
| 136 |
|
| 137 |
This can be useful for e.g. building a container image, where your own code |
| 138 |
is copied or mounted into the container at a later stage. |
| 139 |
|
| 140 |
.. versionadded:: 3.8 |
| 141 |
|
| 142 |
.. option:: --user |
| 143 |
|
| 144 |
Do a user-local installation. This is the default if flit is not in a |
| 145 |
virtualenv or conda env (if the environment's library directory is |
| 146 |
read-only and ``site.ENABLE_USER_SITE`` is true). |
| 147 |
|
| 148 |
.. option:: --env |
| 149 |
|
| 150 |
Install into the environment - the opposite of :option:`--user`. |
| 151 |
This is the default in a virtualenv or conda env (if the environment's |
| 152 |
library directory is writable or ``site.ENABLE_USER_SITE`` is false). |
| 153 |
|
| 154 |
.. option:: --python <path to python> |
| 155 |
|
| 156 |
Install for another Python, identified by the path of the python |
| 157 |
executable. Using this option, you can install a module for Python 2, for |
| 158 |
instance. See :envvar:`FLIT_INSTALL_PYTHON` if this option is not given. |
| 159 |
|
| 160 |
.. versionchanged:: 2.1 |
| 161 |
Added :envvar:`FLIT_INSTALL_PYTHON` and use its value over the Python |
| 162 |
running Flit when an explicit :option:`--python` option is not given. |
| 163 |
|
| 164 |
.. note:: |
| 165 |
|
| 166 |
Flit calls pip to do the installation. You can set any of pip's options |
| 167 |
`using its environment variables |
| 168 |
<https://pip.pypa.io/en/stable/topics/configuration/#environment-variables>`__. |
| 169 |
|
| 170 |
When you use the :option:`--symlink` or :option:`--pth-file` options, pip |
| 171 |
is used to install dependencies. Otherwise, Flit builds a wheel and then |
| 172 |
calls pip to install that. |
| 173 |
|
| 174 |
.. _init_cmd: |
| 175 |
|
| 176 |
``flit init`` |
| 177 |
------------- |
| 178 |
|
| 179 |
.. program:: flit init |
| 180 |
|
| 181 |
Create a new ``pyproject.toml`` config file by prompting for information about |
| 182 |
the module in the current directory. |
| 183 |
|
| 184 |
Environment variables |
| 185 |
--------------------- |
| 186 |
|
| 187 |
.. envvar:: FLIT_NO_NETWORK |
| 188 |
|
| 189 |
.. versionadded:: 0.10 |
| 190 |
|
| 191 |
Setting this to any non-empty value will stop flit from making network |
| 192 |
connections (unless you explicitly ask to upload a package). This |
| 193 |
is intended for downstream packagers, so if you use this, it's up to you to |
| 194 |
ensure any necessary dependencies are installed. |
| 195 |
|
| 196 |
.. envvar:: FLIT_ROOT_INSTALL |
| 197 |
|
| 198 |
By default, ``flit install`` will fail when run as root on POSIX systems, |
| 199 |
because installing Python modules systemwide is not recommended. Setting |
| 200 |
this to any non-empty value allows installation as root. It has no effect on |
| 201 |
Windows. |
| 202 |
|
| 203 |
.. envvar:: FLIT_USERNAME |
| 204 |
FLIT_PASSWORD |
| 205 |
FLIT_INDEX_URL |
| 206 |
|
| 207 |
.. versionadded:: 0.11 |
| 208 |
|
| 209 |
Set a username, password, and index URL for uploading packages. |
| 210 |
See :ref:`uploading packages with environment variables <upload_envvars>` |
| 211 |
for more information. |
| 212 |
|
| 213 |
Token-based upload to PyPI is supported. To upload using a PyPI token, |
| 214 |
set ``FLIT_USERNAME`` to ``__token__``, and ``FLIT_PASSWORD`` to the |
| 215 |
token value. |
| 216 |
|
| 217 |
.. envvar:: FLIT_ALLOW_INVALID |
| 218 |
|
| 219 |
.. versionadded:: 0.13 |
| 220 |
|
| 221 |
Setting this to any non-empty value tells Flit to continue if it detects |
| 222 |
invalid metadata, instead of failing with an error. Problems will still be |
| 223 |
reported in the logs, but won't cause Flit to stop. |
| 224 |
|
| 225 |
If the metadata is invalid, uploading the package to PyPI may fail. This |
| 226 |
environment variable provides an escape hatch in case Flit incorrectly |
| 227 |
rejects your valid metadata. If you need to use it and you believe your |
| 228 |
metadata is valid, please `open an issue <https://github.com/pypa/flit/issues>`__. |
| 229 |
|
| 230 |
.. envvar:: FLIT_INSTALL_PYTHON |
| 231 |
|
| 232 |
.. versionadded:: 2.1 |
| 233 |
|
| 234 |
.. program:: flit install |
| 235 |
|
| 236 |
Set a default Python interpreter for :ref:`install_cmd` to use when |
| 237 |
:option:`--python` is not specified. The value can be either an absolute |
| 238 |
path, or a command name (which will be found in ``PATH``). If this is unset |
| 239 |
or empty, the module is installed for the copy of Python that is running |
| 240 |
Flit. |
| 241 |
|
| 242 |
.. envvar:: SOURCE_DATE_EPOCH |
| 243 |
|
| 244 |
To make reproducible builds, set this to a timestamp as a number of seconds |
| 245 |
since the start of the year 1970 in UTC, and document the value you used. |
| 246 |
On Unix systems, you can get a value for the current time by running:: |
| 247 |
|
| 248 |
date +%s |
| 249 |
|
| 250 |
|
| 251 |
.. seealso:: |
| 252 |
|
| 253 |
`The SOURCE_DATE_EPOCH specification |
| 254 |
<https://reproducible-builds.org/specs/source-date-epoch/>`__ |