Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: add instructions on how to use a custom version of ops in a Charm #1092

Merged
merged 4 commits into from
Jan 3, 2024

Conversation

tonyandrewmeyer
Copy link
Contributor

Figuring out how to test changes to ops locally (without just monkeypatching everything) wasn't straightforward when I started - this should make it easier for new people going forward.

I've included two variants:

  • If the code is in a Git branch then I find it's simplest to just have the charmcraft.yaml file make git available and use standard Python dependency specification.
  • If the code isn't easily installable by pip, then editing the .charm zip file is probably simplest - I've included @benhoyt's inject-ops.sh script to make it easy for people.

I've also added a small note about running in custom Juju versions, since that was something I had to learn today and seems like it might also come up for other people working on ops.

Copy link
Collaborator

@benhoyt benhoyt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Excellent idea to include this!

Trivial issue with mismatched braces, and a question about the #egg=ops syntax.

HACKING.md Outdated

```
#ops ~= 2.9
git+https://github.com/{your-username}}/operator@{your-branch-name}}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are mismatched braces here.

Also, do we need the #egg=ops thing at the end of the line here? I have always used it, but maybe it's not needed?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are mismatched braces here.

Thanks, fixed!

Also, do we need the #egg=ops thing at the end of the line here? I have always used it, but maybe it's not needed?

Hmm, the plain version definitely works for me. But good call, I checked the docs:

pip also looks at the egg fragment specifying the “project name”. In practice the egg fragment is only required to help pip determine the VCS clone location in editable mode. In all other circumstances, the egg fragment is not necessary and its use is discouraged.

So since editable mode isn't relevant here, I believe the #egg= should not be included.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, good to know.

@benhoyt benhoyt merged commit 8a08e8e into canonical:main Jan 3, 2024
18 checks passed
@tonyandrewmeyer tonyandrewmeyer deleted the readme-custom-ops-in-charm branch January 3, 2024 00:10
@benhoyt
Copy link
Collaborator

benhoyt commented Jan 3, 2024

Merged without further review, as this is a doc-only change. @tmihoc if you have further suggestions, let us know and we can always tweak later.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants