Skip to content

Commit

Permalink
Fix dependency conflicts (#1179)
Browse files Browse the repository at this point in the history
  • Loading branch information
bonjourmauko authored Jan 24, 2023
2 parents f7529a2 + 4f6ee1f commit fad5f69
Show file tree
Hide file tree
Showing 7 changed files with 95 additions and 25 deletions.
6 changes: 2 additions & 4 deletions .github/workflows/workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
64 changes: 64 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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.
Expand All @@ -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_:
Expand All @@ -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`:
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion openfisca_core/periods/period_.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
"""
Expand Down
18 changes: 7 additions & 11 deletions openfisca_core/taxbenefitsystems/tax_benefit_system.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand All @@ -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,
}

Expand Down
2 changes: 1 addition & 1 deletion openfisca_tasks/install.mk
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
9 changes: 7 additions & 2 deletions openfisca_tasks/publish.mk
Original file line number Diff line number Diff line change
@@ -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,$@:)
19 changes: 13 additions & 6 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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',
]
Expand All @@ -47,23 +48,25 @@

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',
] + api_requirements

setup(
name = 'OpenFisca-Core',
version = '38.0.2',
version = '38.0.3',
author = 'OpenFisca Team',
author_email = 'contact@openfisca.org',
classifiers = [
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit fad5f69

Please sign in to comment.