Skip to main content

OpenFisca Country-Template

This repository helps you quickly set up and use your own OpenFisca country package.

You should NOT fork it but follow the set up instructions below.

Otherwise, you will have to clean up all tags when you deploy your own country package.

Setting up your Country Package

This set of instructions only needs to be followed once and will create your own copy of this boilerplate directory, customising it to the country you want to work on. You will need to have Git installed.

  1. Click on the “Use this template” dropdown and select “Create a new repository”.

  2. Set the repository name to openfisca-<your_country_name>; use underscore _ as separator if there are spaces in the country name. For example, openfisca-new_zealand or openfisca-france.

  3. After being redirected to your newly created repository, please allow a few minutes for the automatic setup to be executed. Once done, the title of the README file should be updated to OpenFisca <your_country_name>.

If the automatic setup does not start within a few minutes, you can initiate it manually:

  • Navigate to the “Actions” tab.
  • Select the “First time setup” workflow.
  • Click on “Run workflow” to start the setup process manually.
  1. Follow the instructions in the new repository's README.md.
  1. Download a copy of this repository, unzip it and cd into it in a Terminal window.

  2. Create a new repository on your favourite git host (Bitbucket, GitLab, …) with the name openfisca-<your_country_name>. For example, openfisca-new_zealand or openfisca-france.

  3. Execute the first-time-setup.sh script to initialise the git repository. This performs numerous tasks including replacing all references to openfisca-country_template with references to the new country package.

    • To execute the script run bash first-time-setup.sh from the command line
    • After the first-time-setup.sh has run both it and these instructions are removed.
  4. Follow the instructions in the new repository's README.md.

Writing the Legislation

The country whose law is modelled here has a very simple tax and benefit system.

  • It has a flat rate tax whose rates increase every year.
  • On the first of December, 2015, it introduced a basic income for all its citizens of age who have no income.
  • On the first of December, 2016, it removed the income condition, providing all its adult citizens with a basic income.

These elements are described in different folders. All the modelling happens within the openfisca_country_template folder.

  • The rates are in the parameters folder.
  • The formulas are in the variables folder.
  • This country package comes also with reforms in the reforms folder. This is optional: your country may exist without defining any reform.
    • In this country, there is a reform project aiming to modify the social security taxation, deleting the first bracket, raising the intermediary ones and adding a new bracket with a higher tax rate of 40 % for people earning more than 40000. This reform project would apply starting from 2017-01-01.

The files that are outside from the openfisca_country_template folder are used to set up the development environment.

Packaging your Country Package for Distribution

Country packages are Python distributions. You can choose to distribute your package automatically via the predefined continuous deployment system on GitHub Actions, or manually.

Automatic continuous deployment on GitHub

This repository is configured with a continuous deployment system to automate the distribution of your package via pip.

Setting up continuous deployment

To activate the continuous deployment:

  1. Create an account on PyPI if you don't already have one.
  2. Generate a token in your PyPI account. This token will allow GitHub Actions to securely upload new versions of your package to PyPI.
  3. Add this token to your GitHub repository's secrets under the name PYPI_TOKEN.

Once set up, changes to the main branch will trigger an automated workflow to build and publish your package to PyPI, making it available for pip installation.

Manual distribution

If you prefer to manually manage the release and distribution of your package, follow the guidelines provided by the Python Packaging Authority.

This involves detailed steps on preparing your package, creating distribution files, and uploading them to PyPI.

Install Instructions for Users and Contributors

This package requires Python 3.11. More recent versions should work, but are not tested.

All platforms that can execute Python are supported, which includes GNU/Linux, macOS and Microsoft Windows.

A. Minimal Installation

Follow this installation if you wish to:

  • run calculations on a large population;
  • create tax & benefits simulations;
  • write an extension to this legislation (e.g. city specific tax & benefits);
  • serve your Country Package with the OpenFisca Web API.

For more advanced uses, head to the Advanced Installation.

Install this Country Package with uv

Install the Country Package:

uv add install openfisca-country_template

🎉 This OpenFisca Country Package is now installed and ready!

Next Steps

Depending on what you want to do with OpenFisca, you may want to install yet other packages:

B. Advanced Installation (Git Clone)

Follow this tutorial if you wish to:

  • create or change this Country Package's legislation;
  • contribute to the source code.

Clone this Country Package with Git

First, make sure Git is installed on your machine.

Set your working directory to the location where you want this OpenFisca Country Package cloned.

Clone this Country Package on your machine:

git clone https://example.com/repository.git
cd repository_folder

You can make sure that everything is working by running the provided tests with make test.

Learn more about tests

🎉 This OpenFisca Country Package is now installed and ready!

Next Steps

C. Contributing

  • Read CONTRIBUTING.
  • Open a pull request to the main branch of this repository.
  • Announce your changes as described in CONTRIBUTING.

Serve this Country Package with the OpenFisca Web API

If you are considering building a web application, you can use the packaged OpenFisca Web API with your Country Package.

To serve the Openfisca Web API locally, run:

openfisca serve --port 5000 --country-package openfisca_country_template

Or use the quick-start Make command:

make serve-local

To read more about the openfisca serve command, check out its documentation.

You can make sure that your instance of the API is working by requesting:

curl "http://localhost:5000/spec"

This endpoint returns the Open API specification of your API.

🎉 This OpenFisca Country Package is now served by the OpenFisca Web API! To learn more, go to the OpenFisca Web API documentation.

You can test your new Web API by sending it example JSON data located in the situation_examples folder.

curl -X POST -H "Content-Type: application/json" \
  -d @./openfisca_country_template/situation_examples/couple.json \
  http://localhost:5000/calculate

Release files for openfisca-country_template 8.0.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for openfisca-country_template 8.0.4
File Size Uploaded
openfisca_country_template-8.0.4.tar.gz 137.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for openfisca-country_template 8.0.4
File Interpreter ABI Platform
openfisca_country_template-8.0.4-py3-none-any.whl Python 3 none any Details

Total release size: 183.2 kB

Release files / openfisca_country_template-8.0.4.tar.gz

Download URL openfisca_country_template-8.0.4.tar.gz
Size 137.9 kB
Tags Source
SHA-256 checksum
How to use checksums
22655819a651732d6ec04ea376024dee1f092b31e958e95866719045f5aa5bbe
BLAKE2b-256 checksum
How to use checksums
ffcb021b36e588174bcac0ef9d09550346a1099c22bc570798534299a4e81c58
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.12.15 {"installer":{"name":"uv","version":"0.12.15","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / openfisca_country_template-8.0.4-py3-none-any.whl

Download URL openfisca_country_template-8.0.4-py3-none-any.whl
Size 45.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
a4c625bbd55aee957b0600c93ea6a09c49f8392ef4421b40ea17d1a34cafe186
BLAKE2b-256 checksum
How to use checksums
ae754f2a098c4f39ec7f65fb3d46bd37d4a4859d8d7c3073559b6df6b49a1a82
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.12.15 {"installer":{"name":"uv","version":"0.12.15","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release history Release notifications | RSS feed

8.1.0

2 release files

8.0.5

2 release files

This release

8.0.4 This release

2 release files

8.0.3

2 release files

8.0.2

2 release files

8.0.1

2 release files

8.0.0

2 release files

7.1.9

2 release files

7.1.8

2 release files

7.1.7

2 release files

7.1.6

2 release files

7.1.5

2 release files

7.1.4

2 release files

7.1.1

2 release files

7.1.0

2 release files

7.0.0

2 release files

6.0.3

2 release files

6.0.2

2 release files

6.0.1

2 release files

6.0.0

2 release files

5.0.0

2 release files

4.0.0

2 release files

3.13.1

1 release file

3.13.0

1 release file

3.12.10

1 release file

3.12.9

1 release file

3.12.8

1 release file

3.12.7

1 release file

3.12.6

1 release file

3.12.5

1 release file

3.12.4

1 release file

3.12.3

1 release file

3.12.2

1 release file

3.11.0

1 release file

3.10.0

1 release file

3.9.13

1 release file

3.9.12

1 release file

3.9.11

1 release file

3.9.10

1 release file

3.9.9

1 release file

3.9.8

1 release file

3.9.7

1 release file

3.9.6

1 release file

3.9.5

1 release file

3.9.4

1 release file

3.9.3

1 release file

3.9.2

1 release file

3.9.1

1 release file

3.9.0

1 release file

3.8.0

1 release file

3.7.0

1 release file

3.6.0

2 release files

3.5.3

2 release files

3.5.2

2 release files

3.5.0

2 release files

3.4.0

2 release files

3.3.2

2 release files

3.3.1

2 release files

3.3.0

2 release files

3.2.3

2 release files

3.2.2

2 release files

3.2.1

2 release files

3.2.0

2 release files

3.1.3

2 release files

3.1.2

2 release files

3.1.1

2 release files

3.0.2

2 release files

3.0.1

1 release file

3.0.0

1 release file

2.1.0

1 release file

2.0.1

1 release file

1.4.0

1 release file

1.3.2

1 release file

1.3.1

1 release file

1.3.0

1 release file

1.2.7

1 release file

1.2.6

1 release file

1.2.5

1 release file

1.2.4

1 release file

1.2.3

1 release file

1.2.2

1 release file

1.2.1

1 release file

1.2.0

1 release file

1.0.0

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page