Skip to content

Commit

Permalink
Include poetry setup guide
Browse files Browse the repository at this point in the history
  • Loading branch information
glatterf42 committed Mar 6, 2024
1 parent 5bb8d03 commit aad5861
Showing 1 changed file with 88 additions and 0 deletions.
88 changes: 88 additions & 0 deletions CONTRIBUTING.rst
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,94 @@ believe that when posting ideas or submitting code to an open-source project,
it should be obvious and self-evident that any such contributions
are made in the spirit of open collaborative development.

Setup
-----

.. code-block:: bash
# Install Poetry, minimum version >=1.2 required
curl -sSL https://install.python-poetry.org | python -
# You may have to reinitialize your shell at this point.
source ~/.bashrc
# Activate in-project virtualenvs
poetry config virtualenvs.in-project true
# Add dynamic versioning plugin
poetry self add "poetry-dynamic-versioning[plugin]"
# Install dependencies
# (using "--with docs" if docs dependencies should be installed as well)
poetry install --with docs,server,dev
# Activate virtual environment
poetry shell
# Copy the template environment configuration
cp template.env .env
Update poetry
^^^^^^^^^^^^^

Developing ixmp4 requires poetry ``>= 1.2``.

If you already have a previous version of poetry installed you will need to update. The
first step is removing the old poetry version:

.. code-block:: bash
curl -sSL https://install.python-poetry.org | python3 - --uninstall
after that, the latest poetry version can be installed using:

.. code-block:: bash
curl -sSL https://install.python-poetry.org | python3 -
details can be found here in the poetry docs:
https://python-poetry.org/docs/#installation.

Resolve conflicts in poetry.lock
--------------------------------

When updating dependencies it can happen that a conflict between the current and the
target poetry.lock file occurs. In this case the following steps should be taken to
resolve the conflict.

#. Do not attempt to manually resolve in the GitHub web interface.
#. Instead checkout the target branch locally and merge into your branch:

.. code-block:: bash
git checkout main
git pull origin main
git checkout my-branch
git merge main
#. After the last step you'll have a merge conflict in poetry.lock.
#. Instead of resolving the conflict, directly checkout the one from main and rewrite
it:

.. code-block:: bash
# Get poetry.lock to look like it does in master
git checkout main poetry.lock
# Rewrite the lock file
poetry lock --no-update
#. After that simply add poetry.lock to mark the conflict as resolved and commit to
finalize the merge:

.. code-block:: bash
git add poetry.lock
git commit
# and most likely needed
poetry install
(Taken from https://www.peterbe.com/plog/how-to-resolve-a-git-conflict-in-poetry.lock)

.. _`pep8`: https://www.python.org/dev/peps/pep-0008/

.. _`numpydoc docstring guide`: https://numpydoc.readthedocs.io/en/latest/format.html
Expand Down

0 comments on commit aad5861

Please sign in to comment.