diff --git a/.travis.yml b/.travis.yml index 10e93e9..fb03085 100644 --- a/.travis.yml +++ b/.travis.yml @@ -33,7 +33,7 @@ deploy: user: $TEST_PYPI_USER password: $TEST_PYPI_PASS server: https://test.pypi.org/legacy/ - distributions: "sdist bdist_wheel" + distributions: "sdist" on: - branch: staging + branch: develop condition: $TRAVIS_PYTHON_VERSION = "3.6" \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index 9f4a3d6..0dd5522 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,14 @@ ## Unreleased -## 0.2.0 +## 0.3.0 - 2019-05-15 +### Added +- Support Cython + +### Changed +- Use develop instead of staging + +## 0.2.0 - 2019-05-07 ### Added - Support PyPy - AppVeyor integration @@ -11,7 +18,7 @@ - Convert amortization to package - Move definitions to setup.cfg -## 0.1.0 +## 0.1.0 - 2019-05-05 ### Added - PyPI package diff --git a/Pipfile b/Pipfile index faa1c27..a3c56a2 100644 --- a/Pipfile +++ b/Pipfile @@ -8,7 +8,6 @@ codecov = "==2.0.15" pytest = "==4.4.1" pytest-cov = "==2.7.1" twine = "==1.13.0" -wheel = "==0.33.1" [packages] tabulate = "==0.8.3" diff --git a/README.md b/README.md index 796b1bc..bdf1b19 100644 --- a/README.md +++ b/README.md @@ -10,13 +10,13 @@ Python library for calculating amortizations and generating amortization schedul Travis CI - + AppVeyor - + Coverage - + Wheel @@ -44,6 +44,13 @@ Python library for calculating amortizations and generating amortization schedul pip install amortization ``` +### To build using Cython + +```bash +pip install cython +pip install amortization +``` + ## Usage ### Python @@ -51,7 +58,7 @@ pip install amortization #### Amortization Amount ```python -from amortization import calculate_amortization_amount +from amortization.amount import calculate_amortization_amount amount = calculate_amortization_amount(150000, 0.1, 36) ``` diff --git a/amortization/__init__.py b/amortization/__init__.py index ee7a6b4..e69de29 100644 --- a/amortization/__init__.py +++ b/amortization/__init__.py @@ -1,19 +0,0 @@ -#!/usr/bin/env python -# __author__ = "Ronie Martinez" -# __copyright__ = "Copyright 2019, Ronie Martinez" -# __credits__ = ["Ronie Martinez"] -# __maintainer__ = "Ronie Martinez" -# __email__ = "ronmarti18@gmail.com" - - -def calculate_amortization_amount(principal, interest_rate, period): - """ - Calculates Amortization Amount per period - - :param principal: Principal amount - :param interest_rate: Interest rate per period - :param period: Total number of periods - :return: Amortization amount per period - """ - x = (1 + interest_rate) ** period - return principal * (interest_rate * x) / (x - 1) diff --git a/amortization/amortize.py b/amortization/amortize.py index 03f2704..c9aa197 100644 --- a/amortization/amortize.py +++ b/amortization/amortize.py @@ -4,7 +4,7 @@ # __credits__ = ["Ronie Martinez"] # __maintainer__ = "Ronie Martinez" # __email__ = "ronmarti18@gmail.com" -from amortization import calculate_amortization_amount +from amortization.amount import calculate_amortization_amount from amortization.schedule import amortization_schedule diff --git a/amortization/amount.py b/amortization/amount.py new file mode 100644 index 0000000..ee7a6b4 --- /dev/null +++ b/amortization/amount.py @@ -0,0 +1,19 @@ +#!/usr/bin/env python +# __author__ = "Ronie Martinez" +# __copyright__ = "Copyright 2019, Ronie Martinez" +# __credits__ = ["Ronie Martinez"] +# __maintainer__ = "Ronie Martinez" +# __email__ = "ronmarti18@gmail.com" + + +def calculate_amortization_amount(principal, interest_rate, period): + """ + Calculates Amortization Amount per period + + :param principal: Principal amount + :param interest_rate: Interest rate per period + :param period: Total number of periods + :return: Amortization amount per period + """ + x = (1 + interest_rate) ** period + return principal * (interest_rate * x) / (x - 1) diff --git a/amortization/schedule.py b/amortization/schedule.py index 88de708..5be0d92 100644 --- a/amortization/schedule.py +++ b/amortization/schedule.py @@ -4,7 +4,7 @@ # __credits__ = ["Ronie Martinez"] # __maintainer__ = "Ronie Martinez" # __email__ = "ronmarti18@gmail.com" -from amortization import calculate_amortization_amount +from amortization.amount import calculate_amortization_amount def amortization_schedule(principal, interest_rate, period): diff --git a/setup.cfg b/setup.cfg index a341d4d..f655b2c 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,7 +1,7 @@ [metadata] name=amortization -version=0.2.1-rc1 -download_url=https://github.com/roniemartinez/amortization/tarball/0.2.1-rc1 +version=0.3.0-rc1 +download_url=https://github.com/roniemartinez/amortization/tarball/0.3.0-rc1 description=Python library for calculating amortizations and generating amortization schedules long_description=file:README.md description-file=README.md diff --git a/setup.py b/setup.py index f53471f..70003fb 100644 --- a/setup.py +++ b/setup.py @@ -4,6 +4,19 @@ # __credits__ = ["Ronie Martinez"] # __maintainer__ = "Ronie Martinez" # __email__ = "ronmarti18@gmail.com" -from setuptools import setup +from setuptools import setup, Extension -setup() +try: + from Cython.Build import cythonize + + ext_modules = cythonize([ + Extension("amortization.amount", ["amortization/amount.py"]), + Extension("amortization.schedule", ["amortization/schedule.py"]), + Extension("amortization.amortize", ["amortization/amortize.py"]), + ]) +except ImportError: + ext_modules = None + +setup( + ext_modules=ext_modules +) diff --git a/tests/test_amortization.py b/tests/test_amortization.py index b63b039..a02293b 100644 --- a/tests/test_amortization.py +++ b/tests/test_amortization.py @@ -4,7 +4,7 @@ # __credits__ = ["Ronie Martinez"] # __maintainer__ = "Ronie Martinez" # __email__ = "ronmarti18@gmail.com" -from amortization import calculate_amortization_amount +from amortization.amount import calculate_amortization_amount from amortization.schedule import amortization_schedule