diff --git a/.github/workflows/workflow.yml b/.github/workflows/workflow.yml index 8c676c6b55..c2d5334e43 100644 --- a/.github/workflows/workflow.yml +++ b/.github/workflows/workflow.yml @@ -28,7 +28,7 @@ jobs: build-${{ env.pythonLocation }}- - name: Build package - run: make install-deps install-test build + run: make install-deps install-dist install-test clean build - name: Cache release id: restore-release @@ -63,9 +63,7 @@ jobs: run: make test-core - name: Submit coverage to Coveralls - run: | - pip install coveralls - coveralls --service=github + run: coveralls --service=github test-country-template: runs-on: ubuntu-20.04 diff --git a/CHANGELOG.md b/CHANGELOG.md index be50852276..c79d9d0de5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,13 +1,49 @@ # Changelog +### 38.0.3 [#1179](https://github.com/openfisca/openfisca-core/pull/1179) + +#### Bug fix + +- Do not install dependencies outside the `setup.py` + - Dependencies installed outside the `setup.py` are not taken into account by + `pip`'s dependency resolver. + - In case of conflicting transient dependencies, the last library installed + will "impose" its dependency version. + - This makes the installation and build of the library non-deterministic and + prone to unforeseen bugs caused by external changes in dependencies' + versions. + +#### Note + +A definite way to solve this issue is to clearly separate library dependencies +(with a `virtualenv`) and a universal dependency installer for CI requirements +(like `pipx`), taking care of: + +- Always running tests inside the `virtualenv` (for example with `nox`). +- Always building outside of the `virtualenv` (for example with `poetry` + installed by `pipx`). + +Moreover, it is indeed even better to have a lock file for dependencies, +using `pip freeze`) or with tools providing such features (`pipenv`, etc.). + ### 38.0.2 [#1178](https://github.com/openfisca/openfisca-core/pull/1178) #### Technical changes - Remove use of `importlib_metadata`. +### 38.0.1 - + +> Note: Version `38.0.1` has been unpublished as was deployed by mistake. +> Please use versions `38.0.2` and subsequents. + + # 38.0.0 [#989](https://github.com/openfisca/openfisca-core/pull/989) +> Note: Version `38.0.0` has been unpublished as `35.11.1` introduced a bug +> preventing users to load a tax-benefit system. Please use versions `38.0.2` +> and subsequents. + #### New Features - Upgrade OpenAPI specification of the API to v3 from Swagger v2. @@ -20,18 +56,30 @@ ### 37.0.2 [#1170](https://github.com/openfisca/openfisca-core/pull/1170) +> Note: Version `37.0.2` has been unpublished as `35.11.1` introduced a bug +> preventing users to load a tax-benefit system. Please use versions `38.0.2` +> and subsequents. + #### Technical changes - Always import numpy ### 37.0.1 [#1169](https://github.com/openfisca/openfisca-core/pull/1169) +> Note: Version `37.0.1` has been unpublished as `35.11.1` introduced a bug +> preventing users to load a tax-benefit system. Please use versions `38.0.2` +> and subsequents. + #### Technical changes - Unify casing of NumPy. # 37.0.0 [#1142](https://github.com/openfisca/openfisca-core/pull/1142) +> Note: Version `37.0.0` has been unpublished as `35.11.1` introduced a bug +> preventing users to load a tax-benefit system. Please use versions `38.0.2` +> and subsequents. + #### Deprecations - In _periods.Instant_: @@ -45,6 +93,10 @@ # 36.0.0 [#1149](https://github.com/openfisca/openfisca-core/pull/1162) +> Note: Version `36.0.0` has been unpublished as `35.11.1` introduced a bug +> preventing users to load a tax-benefit system. Please use versions `38.0.2` +> and subsequents. + #### Breaking changes - In `ParameterScaleBracket`: @@ -53,18 +105,30 @@ ## 35.12.0 [#1160](https://github.com/openfisca/openfisca-core/pull/1160) +> Note: Version `35.12.0` has been unpublished as `35.11.1` introduced a bug +> preventing users to load a tax-benefit system. Please use versions `38.0.2` +> and subsequents. + #### New Features - Lighter install by removing test packages from systematic install. ### 35.11.2 [#1166](https://github.com/openfisca/openfisca-core/pull/1166) +> Note: Version `35.11.2` has been unpublished as `35.11.1` introduced a bug +> preventing users to load a tax-benefit system. Please use versions `38.0.2` +> and subsequents. + #### Technical changes - Fix Holder's doctests. ### 35.11.1 [#1165](https://github.com/openfisca/openfisca-core/pull/1165) +> Note: Version `35.11.1` has been unpublished as it introduced a bug +> preventing users to load a tax-benefit system. Please use versions `38.0.2` +> and subsequents. + #### Bug fix - Fix documentation diff --git a/openfisca_core/periods/period_.py b/openfisca_core/periods/period_.py index 7de0459bdf..8eb5fadcd1 100644 --- a/openfisca_core/periods/period_.py +++ b/openfisca_core/periods/period_.py @@ -28,7 +28,7 @@ def __repr__(self): >>> repr(period('day', '2014-2-3')) "Period(('day', Instant((2014, 2, 3)), 1))" """ - return '{}({})'.format(self.__class__.__name__, super(Period, self).__repr__()) + return '{}({})'.format(self.__class__.__name__, super(self.__class__, self).__repr__()) def __str__(self): """ diff --git a/openfisca_core/taxbenefitsystems/tax_benefit_system.py b/openfisca_core/taxbenefitsystems/tax_benefit_system.py index 10b22f68c4..9a8831269d 100644 --- a/openfisca_core/taxbenefitsystems/tax_benefit_system.py +++ b/openfisca_core/taxbenefitsystems/tax_benefit_system.py @@ -6,10 +6,10 @@ import functools import glob import importlib +import importlib_metadata import inspect import logging import os -import pkg_resources import sys import traceback import typing @@ -457,8 +457,9 @@ def get_package_metadata(self) -> Dict[str, str]: package_name = module.__package__.split('.')[0] try: - distribution = pkg_resources.get_distribution(package_name) - except pkg_resources.DistributionNotFound: + distribution = importlib_metadata.distribution(package_name) + + except importlib_metadata.PackageNotFoundError: return fallback_metadata source_file = inspect.getsourcefile(module) @@ -469,17 +470,12 @@ def get_package_metadata(self) -> Dict[str, str]: else: location = "" - home_page_metadatas = [ - metadata.split(':', 1)[1].strip(' ') - for metadata in distribution._get_metadata(distribution.PKG_INFO) # type: ignore - if 'Home-page' in metadata - ] - repository_url = home_page_metadatas[0] if home_page_metadatas else '' + metadata = distribution.metadata return { - 'name': distribution.key, + 'name': metadata["Name"].lower(), 'version': distribution.version, - 'repository_url': repository_url, + 'repository_url': metadata["Home-page"], 'location': location, } diff --git a/openfisca_tasks/install.mk b/openfisca_tasks/install.mk index d4ffd8667a..0a8c81115b 100644 --- a/openfisca_tasks/install.mk +++ b/openfisca_tasks/install.mk @@ -6,7 +6,7 @@ uninstall: ## Install project's overall dependencies install-deps: @$(call print_help,$@:) - @pip install --upgrade pip twine wheel + @pip install --upgrade pip ## Install project's development dependencies. install-edit: diff --git a/openfisca_tasks/publish.mk b/openfisca_tasks/publish.mk index 9bac9ae365..aeeb51141b 100644 --- a/openfisca_tasks/publish.mk +++ b/openfisca_tasks/publish.mk @@ -1,12 +1,17 @@ .PHONY: build +## Install project's build dependencies. +install-dist: + @$(call print_help,$@:) + @pip install .[ci,dev] + @$(call print_pass,$@:) + ## 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 build @python -m build @pip uninstall --yes openfisca-core - @find dist -name "*.whl" -exec pip install {}[dev] \; + @find dist -name "*.whl" -exec pip install --no-deps {} \; @$(call print_pass,$@:) diff --git a/setup.py b/setup.py index a05a4ebed9..4d1c1b8ee9 100644 --- a/setup.py +++ b/setup.py @@ -26,13 +26,14 @@ # functional and integration breaks caused by external code updates. general_requirements = [ + 'PyYAML >= 3.10', 'dpath >= 1.5.0, < 3.0.0', + 'importlib-metadata < 4.3.0', # Required for Python 3.7 and Flake8 'nptyping == 1.4.4', 'numexpr >= 2.7.0, <= 3.0', 'numpy >= 1.11, < 1.21', 'psutil >= 5.4.7, < 6.0.0', 'pytest >= 4.4.1, < 6.0.0', # For openfisca test - 'PyYAML >= 3.10', 'sortedcontainers == 2.2.2', 'typing-extensions >= 4.0.0, < 5.0.0', ] @@ -47,15 +48,17 @@ dev_requirements = [ 'autopep8 >= 1.4.0, < 1.6.0', - 'coverage == 6.0.2', + 'coverage >= 6.0.2, < 7.0.0', 'darglint == 1.8.0', 'flake8 >= 4.0.0, < 4.1.0', 'flake8-bugbear >= 19.3.0, < 20.0.0', 'flake8-docstrings == 1.6.0', 'flake8-print >= 3.1.0, < 4.0.0', 'flake8-rst-docstrings == 0.2.3', + 'idna >= 3.4.0, < 4.0.0', + 'isort >= 5.0.0, < 6.0.0', 'mypy == 0.910', - 'openapi-spec-validator >= 0.3.0', + 'openapi-spec-validator >= 0.5.0, < 0.6.0', 'pycodestyle >= 2.8.0, < 2.9.0', 'pylint == 2.10.2', 'xdoctest >= 1.0.0, < 2.0.0', @@ -63,7 +66,7 @@ setup( name = 'OpenFisca-Core', - version = '38.0.2', + version = '38.0.3', author = 'OpenFisca Team', author_email = 'contact@openfisca.org', classifiers = [ @@ -100,9 +103,13 @@ extras_require = { 'web-api': api_requirements, 'dev': dev_requirements, - 'tracker': [ - 'openfisca-tracker == 0.4.0', + 'ci': [ + 'build >= 0.9.0, < 1.0.0', + 'coveralls >= 3.0.0, < 4.0.0', + 'twine >= 4.0.0, < 5.0.0', + 'wheel < 1.0.0', ], + 'tracker': ['openfisca-tracker == 0.4.0'], }, include_package_data = True, # Will read MANIFEST.in install_requires = general_requirements,