Skip to content

Make commitizen homebrew installable #256

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

Closed
Lee-W opened this issue Sep 1, 2020 · 11 comments · Fixed by #278
Closed

Make commitizen homebrew installable #256

Lee-W opened this issue Sep 1, 2020 · 11 comments · Fixed by #278
Labels
type: feature A new enhacement proposal

Comments

@Lee-W
Copy link
Member

Lee-W commented Sep 1, 2020

Description

Make commitizen homebrew installable

Possible Solution

Publish to homebrew

Additional context

Related Issue

@Lee-W Lee-W added the type: feature A new enhacement proposal label Sep 1, 2020
@harens
Copy link
Contributor

harens commented Sep 1, 2020

Hi there. I tried having a quick go at this now, but I didn't realise that commitizen uses Poetry, which doesn't play nicely with Homebrew. As a result, you might find it difficult to write a formula due to a known cyclic dependency issue found here python-poetry/poetry#1975.

Hopefully this saves you some time for something more productive. I've left my code below in case it helps.

Homebrew Formula

class Commitizen < Formula
  include Language::Python::Virtualenv

  desc "Create committing rules for projects, auto bump versions and auto changelog generation"
  homepage "https://commitizen-tools.github.io/commitizen/"
  url "https://github.com/commitizen-tools/commitizen/archive/v2.2.0.tar.gz"
  sha256 "ef983be8eafbd72220cc0802c86b907c4966701d9628431ed70ba69534bf86e8"
  license "MIT"

  depends_on "[email protected]"

  resource "colorama" do
    url "https://files.pythonhosted.org/packages/82/75/f2a4c0c94c85e2693c229142eb448840fba0f9230111faa889d1f541d12d/colorama-0.4.3.tar.gz"
    sha256 "e96da0d330793e2cb9485e9ddfd918d456036c7149416295932478192f4436a1"
  end

  resource "decli" do
    url "https://files.pythonhosted.org/packages/9f/30/064f53ca7b75c33a892dcc4230f78a1e01bee4b5b9b49c0be1a61601c9bd/decli-0.5.2.tar.gz"
    sha256 "f2cde55034a75c819c630c7655a844c612f2598c42c21299160465df6ad463ad"
  end

  resource "Jinja2" do
    url "https://files.pythonhosted.org/packages/64/a7/45e11eebf2f15bf987c3bc11d37dcc838d9dc81250e67e4c5968f6008b6c/Jinja2-2.11.2.tar.gz"
    sha256 "89aab215427ef59c34ad58735269eb58b1a5808103067f7bb9d5836c651b3bb0"
  end

  resource "MarkupSafe" do
    url "https://files.pythonhosted.org/packages/b9/2e/64db92e53b86efccfaea71321f597fa2e1b2bd3853d8ce658568f7a13094/MarkupSafe-1.1.1.tar.gz"
    sha256 "29872e92839765e546828bb7754a68c418d927cd064fd4708fab9fe9c8bb116b"
  end

  resource "packaging" do
    url "https://files.pythonhosted.org/packages/55/fd/fc1aca9cf51ed2f2c11748fa797370027babd82f87829c7a8e6dbe720145/packaging-20.4.tar.gz"
    sha256 "4357f74f47b9c12db93624a82154e9b120fa8293699949152b22065d556079f8"
  end

  resource "prompt-toolkit" do
    url "https://files.pythonhosted.org/packages/18/0f/ae4b350b969dc1d8ecfcbdc1060d59ff025336a23f153ece49aa662a1309/prompt_toolkit-3.0.7.tar.gz"
    sha256 "822f4605f28f7d2ba6b0b09a31e25e140871e96364d1d377667b547bb3bf4489"
  end

  resource "pyparsing" do
    url "https://files.pythonhosted.org/packages/c1/47/dfc9c342c9842bbe0036c7f763d2d6686bcf5eb1808ba3e170afdb282210/pyparsing-2.4.7.tar.gz"
    sha256 "c203ec8783bf771a155b207279b9bccb8dea02d8f0c9e5f8ead507bc3246ecc1"
  end

  resource "PyYAML" do
    url "https://files.pythonhosted.org/packages/64/c2/b80047c7ac2478f9501676c988a5411ed5572f35d1beff9cae07d321512c/PyYAML-5.3.1.tar.gz"
    sha256 "b8eac752c5e14d3eca0e6dd9199cd627518cb5ec06add0de9d32baeee6fe645d"
  end

  resource "questionary" do
    url "https://files.pythonhosted.org/packages/9e/94/d92feac9a32fee5e7ca63b6e51fbff1d2ec83daabe7f1fe8b9845826b77e/questionary-1.5.2.tar.gz"
    sha256 "f6e41e36b6c86fe0c3ff12a30c6c6a4e80129efba5ad0a115d71fd5df119c726"
  end

  resource "six" do
    url "https://files.pythonhosted.org/packages/6b/34/415834bfdafca3c5f451532e8a8d9ba89a21c9743a0c59fbd0205c7f9426/six-1.15.0.tar.gz"
    sha256 "30639c035cdb23534cd4aa2dd52c3bf48f06e5f4a941509c8bafd8ce11080259"
  end

  resource "termcolor" do
    url "https://files.pythonhosted.org/packages/8a/48/a76be51647d0eb9f10e2a4511bf3ffb8cc1e6b14e9e4fab46173aa79f981/termcolor-1.1.0.tar.gz"
    sha256 "1d6d69ce66211143803fbc56652b41d73b4a400a2891d7bf7a1cdf4c02de613b"
  end

  resource "tomlkit" do
    url "https://files.pythonhosted.org/packages/53/10/1f1186fcd453d10254450a7e947e92e6dbb0bf1418484aa4da2829be44f9/tomlkit-0.5.11.tar.gz"
    sha256 "f044eda25647882e5ef22b43a1688fb6ab12af2fc50e8456cdfc751c873101cf"
  end

  resource "wcwidth" do
    url "https://files.pythonhosted.org/packages/89/38/459b727c381504f361832b9e5ace19966de1a235d73cdbdea91c771a1155/wcwidth-0.2.5.tar.gz"
    sha256 "c4d647b99872929fdb7bdcaa4fbe7f01413ed3d98077df798530e5b04f116c83"
  end

  def install
    virtualenv_install_with_resources
  end

  test do
    # TODO
    system "false"
  end
end

@woile
Copy link
Member

woile commented Sep 1, 2020

Would it help to have a setup.py? What if we generate the setup.py using something like dep-hell inside a github action and from there we publish the homebrew package. We do all this inside the github action, so we wouldn't have to commit the setup.py

@harens
Copy link
Contributor

harens commented Sep 2, 2020

Thanks for your reply. I've tried using dephell for another project that used Poetry here: bee-san/Ciphey#197 (comment), but I was unable to get the formula to work (although you're right, it should work in theory).

I found two projects that were able to use both Poetry and Homebrew, dvc and jrnl. Unfortunately, it's not very well documented as to how they did it. Although I don't think there is a simple solution, I will try doing some more research into this.

@harens
Copy link
Contributor

harens commented Sep 3, 2020

I'm still unsure as to how to get Poetry and Homebrew to work together, but the dephell method of creating a setup.py seems to work for MacPorts.

I'll open a seperate issue to discuss this if that's ok.

@woile
Copy link
Member

woile commented Oct 4, 2020

Coming back to this issue, poetry 1.1.0 was released, if we update the build-system on commitizen and decli to the new one, would it make it possible to create the homebrew?

@harens
Copy link
Contributor

harens commented Oct 4, 2020

Thanks for mentioning this @woile. I updated the homebrew formula to the latest version of commitizen and it seems to work perfectly?! (at least on my machine)

Assuming everything goes as planned, I'll write a test and send a PR to homebrew/homebrew-core tomorrow. I'll let you know if I need help on anything.

@harens
Copy link
Contributor

harens commented Oct 5, 2020

🎉 Commitizen has been added to Homebrew! 🎉 (though I presume it'll take some time to show up)

The final result can be seen here

I'm more than happy to keep updating the formula for as long as I can, since I'm notified whenever you release a new version. However, you might want to automate the process with each release using the following Github Action: https://github.com/marketplace/actions/homebrew-bump-formula.

If you choose not to automate it, and in the unlikely chance I forget, it's a pretty simple process of manually updating it. You just ran brew bump-formula-pr and send a PR.

@Lee-W
Copy link
Member Author

Lee-W commented Oct 6, 2020

@harens It's awesome. 🎉🎉🎉 I just try it on my local machine. It works great! Thanks for your help! Would you like to update the documentation and GitHub action for commitizen? Or, I think I might have time to do so this weekend.

@woile
Copy link
Member

woile commented Oct 6, 2020

Wow awesome news! Thanks a lot!
I was gonna ask you the same about the docs if you have time.
And feel free to create draft PR with the github action, doesn't have to be perfect, we could continue with it.

Thanks a lot again.

@harens
Copy link
Contributor

harens commented Oct 6, 2020

Sure, I'd love to add it to the docs. Just to check, is the only thing that needs updating the README?

I'll have a go at the homebrew automation, but please feel free to modify any PR I send (I'm more of a travis sort of person, so I'm not as experienced with github actions).

I'll also continue working on the MacPorts installation, since it also seems to be going well.

@woile
Copy link
Member

woile commented Oct 6, 2020

I think the README would be enough.

It quite similar to travis, you'll need one step to checkout the repo and then the homebew step, this is a good start:

name: Publish to homebrew

on:
  push:
    tags:
      - 'v*'
jobs:
  deploy:
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v2
      with:
        token: '${{ secrets.PERSONAL_ACCESS_TOKEN }}'
        fetch-depth: 0
   # add here any extra step if needed
   # - name: My extra step
   #   run: |
   #     python ...
    - name: Update Homebrew formula
      uses: dawidd6/action-homebrew-bump-formula@v3
      with:
        # GitHub token, required, not the default one
        token: ${{secrets.PERSONAL_ACCESS_TOKEN}}
        # Formula name, required
        formula: FORMULA
        

@harens harens mentioned this issue Oct 6, 2020
4 tasks
@Lee-W Lee-W closed this as completed in #278 Nov 5, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: feature A new enhacement proposal
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants