Skip to content

Commit

Permalink
build(make): adapt to win
Browse files Browse the repository at this point in the history
  • Loading branch information
bonjourmauko committed Sep 27, 2024
1 parent b57ed83 commit e96c619
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 26 deletions.
7 changes: 4 additions & 3 deletions openfisca_tasks/install.mk
Original file line number Diff line number Diff line change
@@ -1,20 +1,21 @@
## Uninstall project's dependencies.
uninstall:
@$(call print_help,$@:)
@pip freeze | grep -v "^-e" | sed "s/@.*//" | xargs pip uninstall -y
@python -m 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
@python -m pip install --upgrade pip

## Install project's development dependencies.
install-edit:
@$(call print_help,$@:)
@pip install --upgrade --editable ".[dev]"
@python -m pip install --upgrade --editable ".[dev]"

## Delete builds and compiled python files.
clean:
@$(call print_help,$@:)
@ls -d * | grep "build\|dist" | xargs rm -rf
@find . -name "__pycache__" | xargs rm -rf
@find . -name "*.pyc" | xargs rm -rf
16 changes: 8 additions & 8 deletions openfisca_tasks/lint.mk
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ check-syntax-errors: .
## Run linters to check for syntax and style errors.
check-style: $(shell git ls-files "*.py" "*.pyi")
@$(call print_help,$@:)
@isort --check $?
@black --check $?
@flake8 $?
@python -m isort --check $?
@python -m black --check $?
@python -m flake8 $?
@$(call print_pass,$@:)

## Run linters to check for syntax and style errors in the doc.
Expand All @@ -32,14 +32,14 @@ lint-doc-%:
@## able to integrate documentation improvements progresively.
@##
@$(call print_help,$(subst $*,%,$@:))
@flake8 --select=D101,D102,D103,DAR openfisca_core/$*
@pylint openfisca_core/$*
@python -m flake8 --select=D101,D102,D103,DAR openfisca_core/$*
@python -m pylint openfisca_core/$*
@$(call print_pass,$@:)

## Run static type checkers for type errors.
check-types:
@$(call print_help,$@:)
@mypy \
@python -m mypy \
openfisca_core/commons \
openfisca_core/entities \
openfisca_core/types.py
Expand All @@ -48,6 +48,6 @@ check-types:
## Run code formatters to correct style errors.
format-style: $(shell git ls-files "*.py" "*.pyi")
@$(call print_help,$@:)
@isort $?
@black $?
@python -m isort $?
@python -m black $?
@$(call print_pass,$@:)
8 changes: 4 additions & 4 deletions openfisca_tasks/publish.mk
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
## Install project's build dependencies.
install-dist:
@$(call print_help,$@:)
@pip install .[ci,dev]
@python -m pip install .[ci,dev]
@$(call print_pass,$@:)

## Build & install openfisca-core for deployment and publishing.
Expand All @@ -12,14 +12,14 @@ build:
@## of openfisca-core, the same we put in the hands of users and reusers.
@$(call print_help,$@:)
@python -m build
@pip uninstall --yes openfisca-core
@find dist -name "*.whl" -exec pip install --no-deps {} \;
@python -m pip uninstall --yes openfisca-core
@find dist -name "*.whl" -exec python -m pip install --no-deps {} \;
@$(call print_pass,$@:)

## Upload to PyPi.
publish:
@$(call print_help,$@:)
@twine upload dist/* --username $PYPI_USERNAME --password $PYPI_TOKEN
@python -m twine upload dist/* --username $PYPI_USERNAME --password $PYPI_TOKEN
@git tag `python setup.py --version`
@git push --tags # update the repository version
@$(call print_pass,$@:)
29 changes: 18 additions & 11 deletions openfisca_tasks/test_code.mk
Original file line number Diff line number Diff line change
@@ -1,17 +1,21 @@
## The openfisca command module.
openfisca = openfisca_core.scripts.openfisca_command

## The path to the installed packages.
python_packages = $(shell python -c "import sysconfig; print(sysconfig.get_paths()[\"purelib\"])")
## The path to the templates' tests.
ifeq ($(OS),Windows_NT)
tests = $(shell python -c "import os, $(1); print(repr(os.path.join($(1).__path__[0], 'tests')))")
else
tests = $(shell python -c "import $(1); print($(1).__path__[0])")/tests
endif

## 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
@python -m pip install --upgrade --no-deps openfisca-country-template
@python -m pip install --upgrade --no-deps openfisca-extension-template

## Run openfisca-core & country/extension template tests.
test-code: test-core test-country test-extension
Expand All @@ -29,25 +33,26 @@ test-code: test-core test-country test-extension
@$(call print_pass,$@:)

## Run openfisca-core tests.
test-core: $(shell pytest --quiet --quiet --collect-only 2> /dev/null | cut -f 1 -d ":")
test-core: $(shell git ls-files "*test_*.py")
@$(call print_help,$@:)
@pytest --capture=no --xdoctest --xdoctest-verbose=0 \
@python -m pytest --capture=no --xdoctest --xdoctest-verbose=0 \
openfisca_core/commons \
openfisca_core/entities \
openfisca_core/holders \
openfisca_core/periods \
openfisca_core/projectors
@PYTEST_ADDOPTS="$${PYTEST_ADDOPTS} ${pytest_args}" \
coverage run -m \
${openfisca} test $? \
python -m coverage run -m ${openfisca} test \
$? \
${openfisca_args}
@$(call print_pass,$@:)

## Run country-template tests.
test-country:
@$(call print_help,$@:)
@PYTEST_ADDOPTS="$${PYTEST_ADDOPTS} ${pytest_args}" \
openfisca test ${python_packages}/openfisca_country_template/tests \
python -m ${openfisca} test \
$(call tests,"openfisca_country_template") \
--country-package openfisca_country_template \
${openfisca_args}
@$(call print_pass,$@:)
Expand All @@ -56,7 +61,8 @@ test-country:
test-extension:
@$(call print_help,$@:)
@PYTEST_ADDOPTS="$${PYTEST_ADDOPTS} ${pytest_args}" \
openfisca test ${python_packages}/openfisca_extension_template/tests \
python -m ${openfisca} test \
$(call tests,"openfisca_extension_template") \
--country-package openfisca_country_template \
--extensions openfisca_extension_template \
${openfisca_args}
Expand All @@ -65,4 +71,5 @@ test-extension:
## Print the coverage report.
test-cov:
@$(call print_help,$@:)
@coverage report
@python -m coverage report
@$(call print_pass,$@:)

0 comments on commit e96c619

Please sign in to comment.