Skip to content

Commit

Permalink
Migrate to poetry
Browse files Browse the repository at this point in the history
- Migrate all invokes to `saritasa-invocations`
- Drop support of python 3.9
- Add support for python 3.12
- Add django 5.0 to ci matrix
- Migrate from `pip-tools` to `poetry`
- Add configuration for  `coverage` tool
- Add separate invoke for `coverage` tests run
- Remove makefiles
  • Loading branch information
yalef committed Dec 12, 2023
1 parent 2dc9b60 commit e368f65
Show file tree
Hide file tree
Showing 33 changed files with 3,024 additions and 796 deletions.
40 changes: 31 additions & 9 deletions .github/workflows/checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@ jobs:
fail-fast: false
matrix:
python-version:
- '3.9'
- '3.10'
- '3.11'
django-version:
- '>=3.2,<4.0'
- '>=4.0,<4.1'
- '>=4.1,<4.2'
- '>=4.2,<4.3'
- '>=5.0,<5.1'
name: python ${{ matrix.python-version }} - django ${{ matrix.django-version }}

steps:
Expand All @@ -37,20 +37,42 @@ jobs:
key: ${{ runner.os }}-pip-${{ hashFiles('requirements/*.txt') }}
restore-keys: |
${{ runner.os }}-pip-
- name: Install Dependencies
- name: Install Poetry
uses: snok/install-poetry@v1
with:
version: latest
virtualenvs-create: true
virtualenvs-in-project: true
installer-parallel: true

- name: Cache poetry dependencies
id: cached-poetry-dependencies
uses: actions/cache@v3
with:
path: .venv
key: ${{ runner.os }}-poetry-${{ matrix.python-version }}-${{ hashFiles('**/poetry.lock') }}

- name: Install local dependencies
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
run: poetry install --no-interaction

- name: Install Django
run: |
pip install --upgrade pip wheel setuptools
pip install --requirement requirements/local_build.txt
pip install 'django${{ matrix.django-version }}'
poetry run pip install 'django${{ matrix.django-version }}'
- name: Prepare env
run: |
inv ci.prepare
poetry run inv ci.prepare
- name: Run checks ${{ matrix.python-version }}
run: inv git.run-hooks
run: poetry run inv pre-commit.run-hooks

- name: Upload results to coveralls
run: |
pip install coveralls
coveralls --service=github
poetry run pip install coveralls
poetry run coveralls --service=github
env:
COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_REPO_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Expand Down
45 changes: 38 additions & 7 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,37 @@ repos:
- id: isort
name: isort (python)

- repo: https://github.com/pycqa/flake8
rev: 6.1.0
hooks:
- id: flake8
exclude: node_modules|migrations|scripts|.venv|__init__.py
additional_dependencies: [
# A flake8 plugin that checks django code style.
# https://github.com/rocioar/flake8-django
flake8-django,
# required by flake8-django
django,
django_extensions,
# A plugin for Flake8 finding likely bugs and design problems in your program.
# https://github.com/PyCQA/flake8-bugbear
flake8-bugbear,
# A flake8 plugin checking common style issues or inconsistencies with pytest-based tests.
# https://github.com/m-burst/flake8-pytest-style
flake8-pytest-style,
# A flake8 plugin that warn about backslashes usage.
# https://github.com/wemake-services/flake8-broken-line
flake8-broken-line,
# A simple module that adds an extension for the fantastic pydocstyle tool to flake8.
# https://github.com/PyCQA/flake8-docstrings
flake8-docstrings,
# McCabe complexity checker.
# https://github.com/PyCQA/mccabe
mccabe,
# A flake8 plug-in loading the configuration from pyproject.toml
flake8-pyproject,
]

- repo: https://github.com/asottile/add-trailing-comma
rev: v2.4.0
hooks:
Expand Down Expand Up @@ -44,20 +75,20 @@ repos:
types: [ file ]
stages: [ push ]

- id: linters
name: run linters
entry: inv linters.all
- id: tests
name: run tests
entry: inv ci.coverage
language: system
pass_filenames: false
types: [ python ]
stages: [ push ]

- id: tests
name: run tests
entry: inv tests.run-ci
- id: mypy
name: mypy
entry: inv mypy.run
language: system
pass_filenames: false
types: [ python ]
types: [ file ]
stages: [ push ]

- id: package_installation_verify
Expand Down
16 changes: 12 additions & 4 deletions .readthedocs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,19 @@ build:
os: ubuntu-22.04
tools:
python: "3.11"
jobs:
# Job for install dependencies with poetry
# Docs: https://docs.readthedocs.io/en/stable/build-customization.html#install-dependencies-with-poetry
post_create_environment:
# https://python-poetry.org/docs/#installing-manually
- pip install -U poetry
# Tell poetry to not use a virtual environment
- poetry config virtualenvs.create false
post_install:
# Install dependencies with 'docs' dependency group
# https://python-poetry.org/docs/managing-dependencies/#dependency-groups
- poetry install --with docs

# Build documentation in the docs/ directory with Sphinx
sphinx:
configuration: docs/conf.py

python:
install:
- requirements: requirements/development.txt
11 changes: 4 additions & 7 deletions CONTRIBUTING.rst
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,9 @@ Ready to contribute? Here's how to set up `django-import-export-extensions` for
3. Setup virtual environment using pyenv::

$ pyenv install 3.11
$ pyenv virtualenv 3.11 django-import-export-extensions
$ pyenv local django-import-export-extensions
$ pyenv activate django-import-export-extensions
$ pip install -r requirements/local_build.txt
$ inv project.init
$ pyenv shell $(pyenv latest 3.11)
$ poetry config virtualenvs.in-project true
$ poetry env use $(which python) && poetry install && source .venv/bin/activate

4. Create a branch for local development::

Expand All @@ -82,8 +80,7 @@ Ready to contribute? Here's how to set up `django-import-export-extensions` for
5. When you're done making changes, check that your changes pass flake8 and the
tests::

$ inv tests.run
$ inv linters.all
$ inv pre-commit.run-hooks

6. Commit your changes and push your branch to GitHub::

Expand Down
3 changes: 3 additions & 0 deletions HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,13 @@ History

UNRELEASED
------------------
* Drop support of python 3.9
* Migrate from pip-tools to poetry
* Add base model for ``ImportJob`` and ``ExportJob``
* Extend import results template: show validation errors in table
* Add force-import feature: skip rows with errors while importing
* Add ``skip_parse_step`` parameter for importing API
* Remove Makefile in favor of ``invoke`` commands

0.4.1 (2023-09-25)
------------------
Expand Down
2 changes: 1 addition & 1 deletion MANIFEST.in
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ include LICENSE
include README.rst

recursive-include import_export_extensions/ *
recursive-include docs *.rst conf.py Makefile make.bat *.jpg *.png *.gif
recursive-include docs *.rst conf.py *.jpg *.png *.gif

recursive-exclude * __pycache__
recursive-exclude * *.py[co]
73 changes: 0 additions & 73 deletions Makefile

This file was deleted.

22 changes: 0 additions & 22 deletions docs/Makefile

This file was deleted.

5 changes: 4 additions & 1 deletion docs/api_admin.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,10 @@ Admin
.. automodule:: import_export_extensions.admin.model_admins.mixins
:members:

.. automodule:: import_export_extensions.admin.forms.export_admin_form
.. automodule:: import_export_extensions.admin.forms.export_job_admin_form
:members:

.. automodule:: import_export_extensions.admin.forms.import_job_admin_form
:members:

.. automodule:: import_export_extensions.admin.forms.import_admin_form
Expand Down
16 changes: 0 additions & 16 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,22 +37,6 @@
copyright = "2022-2023, Saritasa"
author = "Saritasa"


# The version info for the project you're documenting, acts as replacement for
# |version| and |release|, also used in various other places throughout the
# built documents.
#
try:
from import_export_extensions import __version__

# The short X.Y version.
version = ".".join(__version__.split(".")[:2])
# The full version, including alpha/beta/rc tags.
release = __version__
except ImportError:
version = release = "dev"


# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
#
Expand Down
14 changes: 6 additions & 8 deletions docs/extensions.rst
Original file line number Diff line number Diff line change
Expand Up @@ -185,9 +185,8 @@ Force import
This package provides *force import* feature. When force import is enabled,
then rows with errors will be skipped and rest of the rows will be handled.

__________
Admin page
__________
^^^^^^^^^^

This functionality available in admin:

Expand All @@ -197,9 +196,8 @@ In case if some rows contain any errors it will be reported on parse/import stag

.. figure:: _static/images/force_import_results.png

___
API
___
^^^

In api there're 2 fields: ``force_import`` and ``skip_parse_step``.

Expand All @@ -217,7 +215,7 @@ Widgets
This package also provides additional widgets for some types of data.

FileWidget
__________
^^^^^^^^^^

Working with file fields is a common issue. ``FileWidget`` allows to import/export files
including links to external resources that store files and save them in ``DEFAULT_FILE_STORAGE``.
Expand All @@ -227,7 +225,7 @@ also supports ``AWS_STORAGE_BUCKET_NAME`` setting.


IntermediateManyToManyWidget
____________________________
^^^^^^^^^^^^^^^^^^^^^^^^^^^^

``IntermediateManyToManyWidget`` allows to import/export objects with related items.
Default M2M widget store just IDs of related objects. With intermediate widget
Expand All @@ -238,15 +236,15 @@ Fields
------

M2MField
________
^^^^^^^^

This is resource field for M2M fields. Provides faster import of related fields.

This implementation deletes intermediate models, which were excluded
and creates intermediate models only for newly added models.

IntermediateManyToManyField
___________________________
^^^^^^^^^^^^^^^^^^^^^^^^^^^

This is resource field for M2M with custom ``through`` model.

Expand Down

0 comments on commit e368f65

Please sign in to comment.