Skip to content

Commit f681ec3

Browse files
authored
Merge pull request #63 from Kai-Striega/move_to_poetry
2 parents 37c4937 + 74cc871 commit f681ec3

File tree

8 files changed

+132
-86
lines changed

8 files changed

+132
-86
lines changed

.github/workflows/pythonpackage.yml

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,11 @@ on: [push, pull_request]
44

55
jobs:
66
build:
7-
87
runs-on: ${{ matrix.os }}
98
strategy:
109
matrix:
1110
os: [ubuntu-latest, macos-latest, windows-latest]
12-
python-version: ["3.7", "3.8", "3.9", "3.10", "3.11"]
13-
numpy-version: ["oldest-supported-numpy", "numpy"]
14-
11+
python-version: ["3.9", "3.10", "3.11"]
1512
steps:
1613
- uses: actions/checkout@v3
1714
- name: Set up Python ${{ matrix.python-version }}
@@ -20,19 +17,15 @@ jobs:
2017
python-version: ${{ matrix.python-version }}
2118
- name: Install dependencies
2219
run: |
23-
python -m pip install --upgrade pip
24-
pip install ${{ matrix.numpy-version }}
20+
python -m pip install --upgrade pip poetry
21+
poetry env use ${{ matrix.python-version }}
22+
poetry install --with=test --with=lint
2523
- name: Lint with flake8
2624
run: |
27-
pip install flake8
2825
# stop the build if there are Python syntax errors or undefined names
29-
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
30-
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
31-
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
32-
- name: Install numpy-financial
33-
run: |
34-
pip install .
26+
poetry run flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
27+
# The GitHub editor is 127 chars wide
28+
poetry run flake8 . --ignore=F401,F403,W503,E226 --count --max-complexity=10 --max-line-length=127 --statistics
3529
- name: Test with pytest
3630
run: |
37-
pip install pytest
38-
pytest
31+
poetry run pytest

doc_developer/building_with_poetry.md

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
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.

numpy_financial/_financial.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,16 +27,14 @@
2727
'start': 1,
2828
'finish': 0}
2929

30-
# Define custom Exceptions
3130

3231
class NoRealSolutionException(Exception):
3332
""" No real solution to the problem. """
34-
3533
pass
3634

35+
3736
class IterationsExceededException(Exception):
3837
""" Maximum number of iterations reached. """
39-
4038
pass
4139

4240

pyproject.toml

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
[build-system]
2+
requires = ["poetry-core"]
3+
build-backend = "poetry.core.masonry.api"
4+
5+
6+
[tool.poetry]
7+
name = "numpy-financial"
8+
version = "1.1.0.dev0"
9+
description = "Simple financial functions"
10+
license = "BSD-3-Clause"
11+
authors = ["Travis E. Oliphant et al."]
12+
maintainers = ["Numpy Financial Developers <numpy-discussion@python.org>"]
13+
readme = "README.md"
14+
homepage = "https://numpy.org/numpy-financial/latest/"
15+
repository = "https://github.com/numpy/numpy-financial"
16+
documentation = "https://numpy.org/numpy-financial/latest/#functions"
17+
classifiers = [
18+
"Development Status :: 5 - Production/Stable",
19+
"Intended Audience :: Developers",
20+
"Intended Audience :: Financial and Insurance Industry",
21+
"License :: OSI Approved :: BSD License",
22+
"Programming Language :: Python",
23+
"Programming Language :: Python :: 3",
24+
"Programming Language :: Python :: 3.9",
25+
"Programming Language :: Python :: 3.10",
26+
"Programming Language :: Python :: 3.11",
27+
"Programming Language :: Python :: 3.12",
28+
"Programming Language :: Python :: 3 :: Only",
29+
"Topic :: Software Development",
30+
"Topic :: Office/Business :: Financial :: Accounting",
31+
"Topic :: Office/Business :: Financial :: Investment",
32+
"Topic :: Office/Business :: Financial :: Spreadsheet",
33+
"Operating System :: Microsoft :: Windows",
34+
"Operating System :: POSIX",
35+
"Operating System :: Unix",
36+
"Operating System :: MacOS",
37+
]
38+
packages = [{include = "numpy_financial"}]
39+
40+
[tool.poetry.dependencies]
41+
python = "^3.9"
42+
numpy = "^1.23"
43+
44+
45+
[tool.poetry.group.test.dependencies]
46+
pytest = "^7.4"
47+
48+
49+
[tool.poetry.group.docs.dependencies]
50+
sphinx = "^7.0"
51+
numpydoc = "^1.5"
52+
53+
54+
[tool.poetry.group.lint.dependencies]
55+
flake8 = "*"

requirements.txt

Lines changed: 0 additions & 1 deletion
This file was deleted.

setup.py

Lines changed: 0 additions & 66 deletions
This file was deleted.
File renamed without changes.

numpy_financial/tests/test_financial.py renamed to tests/test_financial.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
import numpy
77
from numpy.testing import (
88
assert_, assert_almost_equal, assert_allclose, assert_equal, assert_raises
9-
)
9+
)
1010
import pytest
1111

1212
import numpy_financial as npf

0 commit comments

Comments
 (0)