|
| 1 | +# Building with poetry |
| 2 | + |
| 3 | +## Installing poetry |
| 4 | +numpy-financial uses [poetry](https://python-poetry.org/) to manage |
| 5 | +dependencies, build wheels and sdists, and publish to PyPI this page documents |
| 6 | +how to work with poetry. |
| 7 | + |
| 8 | +To install poetry follow their [official guide](https://python-poetry.org/docs/#installing-with-the-official-installer) |
| 9 | +it is recommended to use the official installer for local development. |
| 10 | + |
| 11 | +To check your installation try to check the version of poetry: |
| 12 | + |
| 13 | +```shell |
| 14 | +poetry -V |
| 15 | +``` |
| 16 | + |
| 17 | +## Setting up a virtual environment using poetry |
| 18 | + |
| 19 | +Once poetry is installed it is time to set up the virtual environment. To do |
| 20 | +this run: |
| 21 | + |
| 22 | +```shell |
| 23 | +poetry install |
| 24 | +``` |
| 25 | + |
| 26 | +``poetry install`` looks for dependencies in the ``pyproject.toml`` file, |
| 27 | +resolves them to the most recent version and installs the dependencies |
| 28 | +in a virtual environment. It is now possible to launch an interactive REPL |
| 29 | +by running the following command: |
| 30 | + |
| 31 | +```shell |
| 32 | +poetry run python |
| 33 | +``` |
| 34 | + |
| 35 | +## Running the test suite |
| 36 | + |
| 37 | +numpy-financial has an extensive test suite, which can be run with the |
| 38 | +following command: |
| 39 | + |
| 40 | +```shell |
| 41 | +poetry run pytest |
| 42 | +``` |
| 43 | + |
| 44 | +## Building distributions |
| 45 | + |
| 46 | +It is possible to manually build distributions for numpy-financial using |
| 47 | +poetry. This is possible via the `build` command: |
| 48 | + |
| 49 | +```shell |
| 50 | +poetry build |
| 51 | +``` |
| 52 | + |
| 53 | +The `build` command creates a `dist` directory containing a wheel and sdist |
| 54 | +file. |
| 55 | + |
| 56 | + |
| 57 | +## Publishing to PyPI |
| 58 | + |
| 59 | +poetry provides support to publish packages to PyPI. This is possible using |
| 60 | +the ``publish`` command: |
| 61 | + |
| 62 | +```shell |
| 63 | +poetry publish --build --username <your username> --password <your password> |
| 64 | +``` |
| 65 | + |
| 66 | +Note that this builds the package before publishing it. You will need to |
| 67 | +provide the correct username and password for PyPI. |
0 commit comments