Repository: openfisca/openfisca-core (language: python)

Issue:
Simplify testing of new major versions
For smoke testing purposes, the Core has a dependency on both [Country Template](https://github.com/openfisca/country-template/) and [Extension Template](https://github.com/openfisca/extension-template/). This enables running their test suites with the latest Core code.

While powerful and useful, this technique leads to a major obstacle in delivering major releases of the Core. Indeed, both of these packages in turn have a dependency to the core, and this dependency is pinned to a specific major version to ensure stability.

These two points combined create a circular dependency that prevents testing major releases: if I bump the major Core version to version N, the Template dependencies bring irresolvable constraints to version N-1.

This is typically handled by creating a new branch for each repository, relaxing the version constraint, and updating the core dependency to these new branches. This means that every such change needs temporary modifications on at least three repositories, making them very impractical. See for example https://github.com/openfisca/openfisca-core/pull/989, leading to https://github.com/openfisca/country-template/pull/128 and https://github.com/openfisca/extension-template/pull/47.

A solution to enable testing from the Core with any Core version would significantly ease the delivery of new major versions, which will be needed to finally unblock many PRs and features that have been waiting for way too long.


Discussion / hints:
## Suggestion 1

1. Delay major version bump in Core until PR has been approved, which means a code freeze.
2. Upgrade higher bound in template repositories, without upgrading lower bound, and publish new version.
3. Bump major in Core, merge, publish.

### Example

1. Approve https://github.com/openfisca/openfisca-core/pull/989.
2. In https://github.com/openfisca/country-template/pull/128, upgrade Core constraint from `OpenFisca-Core[web-api] >= 35.0.0, < 36.0.0` to `OpenFisca-Core[web-api] >= 35.0.0, < 37.0.0`, publish `OpenFisca-Country-Template@4`.
3. In https://github.com/openfisca/extension-template/pull/47, upgrade Core constraint from `OpenFisca-Country-Template >= 3.8.0, < 4` to `OpenFisca-Country-Template >= 3.8.0, < 5`, publish `OpenFisca-Extension-Template@2`.
4. Bump major in https://github.com/openfisca/openfisca-core/pull/989. Tests should pass. Merge and publish.


## Suggestion 2

Add a dependency group in Country Template and Extension Template called something like `future` that removes the upper bound version constraint on the Core, making it easier to test upgrades by changing the dependency in Core from `openfisca-country-template` to `openfisca-country-template[future]`.

### Example

1. Add an optional dependency group in Country Template and Extension Template called `future` (or `testing`, or `optimistic`, or `latest-core`) that overrides the dependency to `OpenFisca-Core[web-api] >= 35.0.0, < 36.0.0` to `OpenFisca-Core[web-api] >= 35.0.0`.
2. Change Core dependency from `OpenFisca-Country-Template` to `OpenFisca-Country-Template[future]`.
3. Have all tests pass in Core without making any effort. If there are errors, then that means code upgrades in Template are actually warranted.
4. Publish Core update.
5. In https://github.com/openfisca/country-template/pull/128, upgrade Core constraint from `OpenFisca-Core[web-api] >= 35.0.0, < 36.0.0` to `OpenFisca-Core[web-api] >= 35.0.0, < 37.0.0`, publish `OpenFisca-Country-Template@4`.
I like suggestion 2 as it imposes less constraints at each step of the process and report those efforts to where knowledge can be found (I use core but do not use the web-api for example).

Fix patch:
diff --git a/.github/workflows/workflow.yml b/.github/workflows/workflow.yml
index 55b8bfdef5..8c676c6b55 100644
--- a/.github/workflows/workflow.yml
+++ b/.github/workflows/workflow.yml
@@ -28,7 +28,7 @@ jobs:
             build-${{ env.pythonLocation }}-
 
       - name: Build package
-        run: make build
+        run: make install-deps install-test build
 
       - name: Cache release
         id: restore-release
diff --git a/.gitignore b/.gitignore
index c66d2bd194..00d9f19fb6 100644
--- a/.gitignore
+++ b/.gitignore
@@ -4,6 +4,7 @@
 *~
 .coverage
 .mypy_cache
+.mypy_cache*
 .noseids
 .project
 .pydevproject
@@ -13,7 +14,6 @@
 .tags*
 .venv
 .vscode
-.vscode
 build
 cover
 dist
diff --git a/CHANGELOG.md b/CHANGELOG.md
index f5528d9708..68d2f0bb38 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,5 +1,11 @@
 # Changelog
 
+## 35.12.0 [#1160](https://github.com/openfisca/openfisca-core/pull/1160)
+
+#### New Features
+
+- Lighter install by removing test packages from systematic install.
+
 ### 35.11.2 [#1166](https://github.com/openfisca/openfisca-core/pull/1166)
 
 #### Technical changes
@@ -39,7 +45,7 @@
 
 #### New Features
 
-- Introduce a maximal depth for compuation logs
+- Introduce a maximal depth for computation logs
   - Allows for limiting the depth of the computation log chain
 
 ### 35.8.6 [#1145](https://github.com/openfisca/openfisca-core/pull/1145)
diff --git a/README.md b/README.md
index d25506609b..a3f18555f1 100644
--- a/README.md
+++ b/README.md
@@ -40,8 +40,7 @@ git clone https://github.com/openfisca/openfisca-core.git
 cd openfisca-core
 python3 -m venv .venv
 source .venv/bin/activate
-pip install -U pip
-pip install --editable .[dev] --use-deprecated=legacy-resolver
+make install-deps install-edit
 ```
 
 ### Installing `openfisca-core` with `conda`
@@ -69,6 +68,18 @@ For information on how we publish to conda-forge, see [openfisca-core-feedstock]
 
 ## Testing
 
+Install the test dependencies:
+
+```
+make install-deps install-edit install-test
+```
+
+> For integration testing purposes, `openfisca-core` relies on
+> [country-template](https://github.com/openfisca/country-template.git) and
+> [extension-template](https://github.com/openfisca/extension-template.git).
+> Because these packages rely at the same time on `openfisca-core`, they need
+> to be installed separately.
+
 To run the entire test suite:
 
 ```sh
diff --git a/openfisca_tasks/install.mk b/openfisca_tasks/install.mk
index 192e38d417..d4ffd8667a 100644
--- a/openfisca_tasks/install.mk
+++ b/openfisca_tasks/install.mk
@@ -1,13 +1,17 @@
-## Install project dependencies.
-install:
+## Uninstall project's dependencies.
+uninstall:
+	@$(call print_help,$@:)
+	@pip freeze | grep -v "^-e" | sed "s/@.*//" | xargs pip uninstall -y
+
+## Install project's overall dependencies
+install-deps:
 	@$(call print_help,$@:)
 	@pip install --upgrade pip twine wheel
-	@pip install --editable ".[dev]" --upgrade
 
-## Uninstall project dependencies.
-uninstall:
+## Install project's development dependencies.
+install-edit:
 	@$(call print_help,$@:)
-	@pip freeze | grep -v "^-e" | sed "s/@.*//" | xargs pip uninstall -y
+	@pip install --upgrade --editable ".[dev]"
 
 ## Delete builds and compiled python files.
 clean:
diff --git a/openfisca_tasks/publish.mk b/openfisca_tasks/publish.mk
index 28a4b40546..9bac9ae365 100644
--- a/openfisca_tasks/publish.mk
+++ b/openfisca_tasks/publish.mk
@@ -1,11 +1,11 @@
 .PHONY: build
 
-## Install openfisca-core for deployment and publishing.
+## Build & install openfisca-core for deployment and publishing.
 build:
 	@## This allows us to be sure tests are run against the packaged version
 	@## of openfisca-core, the same we put in the hands of users and reusers.
 	@$(call print_help,$@:)
-	@pip install --upgrade pip build twine
+	@pip install --upgrade build
 	@python -m build
 	@pip uninstall --yes openfisca-core
 	@find dist -name "*.whl" -exec pip install {}[dev] \;
diff --git a/setup.py b/setup.py
index 68f1739363..0eb2fa5624 100644
--- a/setup.py
+++ b/setup.py
@@ -1,4 +1,19 @@
-#! /usr/bin/env python
+"""Package config file.
+
+This file contains all package's metadata, including the current version and
+its third-party dependencies.
+
+Note:
+    For integration testing, OpenFisca-Core relies on two other packages,
+    listed below. Because these packages rely at the same time on
+    OpenFisca-Core, adding them as official dependencies creates a resolution
+    loop that makes it hard to contribute. We've therefore decided to install
+    them via the task manager (`make install-test`)::
+
+        openfisca-country-template = "*"
+        openfisca-extension-template = "*"
+
+"""
 
 from setuptools import setup, find_packages
 from pathlib import Path
@@ -40,8 +55,6 @@
     'flake8-print >= 3.1.0, < 4.0.0',
     'flake8-rst-docstrings == 0.2.3',
     'mypy == 0.910',
-    'openfisca-country-template >= 3.10.0, < 4.0.0',
-    'openfisca-extension-template >= 1.2.0rc0, < 2.0.0',
     'pycodestyle >= 2.8.0, < 2.9.0',
     'pylint == 2.10.2',
     'xdoctest >= 1.0.0, < 2.0.0',
@@ -49,7 +62,7 @@
 
 setup(
     name = 'OpenFisca-Core',
-    version = '35.11.2',
+    version = '35.12.0',
     author = 'OpenFisca Team',
     author_email = 'contact@openfisca.org',
     classifiers = [


Test patch:
diff --git a/openfisca_tasks/test_code.mk b/openfisca_tasks/test_code.mk
index 500cdcb073..63fdd4386a 100644
--- a/openfisca_tasks/test_code.mk
+++ b/openfisca_tasks/test_code.mk
@@ -4,6 +4,15 @@ openfisca = openfisca_core.scripts.openfisca_command
 ## The path to the installed packages.
 python_packages = $(shell python -c "import sysconfig; print(sysconfig.get_paths()[\"purelib\"])")
 
+## Run all tasks required for testing.
+install: install-deps install-edit install-test
+
+## Enable regression testing with template repositories.
+install-test:
+	@$(call print_help,$@:)
+	@pip install --upgrade --no-dependencies openfisca-country-template
+	@pip install --upgrade --no-dependencies openfisca-extension-template
+
 ## Run openfisca-core & country/extension template tests.
 test-code: test-core test-country test-extension
 	@##	Usage: