Skip to content

Commit

Permalink
Merge pull request #167 from boutproject/better-git-diff-fail
Browse files Browse the repository at this point in the history
Recommend editable installs for developers
  • Loading branch information
bendudson authored Jan 27, 2023
2 parents 88ac9fe + bedc9cc commit 8446529
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 3 deletions.
12 changes: 12 additions & 0 deletions doc/developer/developer.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,18 @@
Developing hypnotoad
====================

When installing from the source code git repo for development, it is
recommended to do an editable install ::

$ pip install --user -e .

This method means the installed modules and command line tools link to the
source code, so reflect changes you make, and avoids a possible error if the
repo has uncommitted changes (is 'dirty') where ``git diff`` fails to run on
the installed code. Note, if you use ``conda`` make sure all the dependencies
(see ``pyproject.toml``) are already installed to avoid them being
``pip``-installed and messing up dependency tracking.

.. toctree::

equilibrium
Expand Down
6 changes: 6 additions & 0 deletions doc/whats-new.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@ Release history
0.5.1 (18th January 2023)
-------------------------

### Bug fixes

- Document that editable installs are recommended for developers in manual and
exception message (#167)\
By [John Omotani](https://github.com/johnomotani)

### New features

- `PsiContour.plot()` and `FineContour.plot()` can be called with an `ax`
Expand Down
15 changes: 12 additions & 3 deletions hypnotoad/core/mesh.py
Original file line number Diff line number Diff line change
Expand Up @@ -2573,9 +2573,18 @@ def __init__(self, equilibrium, settings):

hypnotoad_path = Path(hypnotoad_init_file).parent

retval, self.git_diff = shell_safe(
"cd " + str(hypnotoad_path) + "&& git diff", pipe=True
)
try:
retval, self.git_diff = shell_safe(
"cd " + str(hypnotoad_path) + "&& git diff", pipe=True
)
except RuntimeError as e:
raise RuntimeError(
"`git diff` failed. It is recommended to do an editable install "
"using `pip --user -e .` when developing. If you did a "
"non-editable install, this error can occur if the repo was "
"'dirty' when installed.\n\nThe error message was:\n" + str(e)
)

self.git_diff = self.git_diff.strip()

# Generate MeshRegion object for each section of the mesh
Expand Down

0 comments on commit 8446529

Please sign in to comment.