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

Create a Homebrew install #197

Closed
bee-san opened this issue Jul 25, 2020 · 7 comments · Fixed by #669
Closed

Create a Homebrew install #197

bee-san opened this issue Jul 25, 2020 · 7 comments · Fixed by #669
Assignees
Labels
enhancement New feature or request feature_request good first issue Good for newcomers help wanted Extra attention is needed

Comments

@bee-san
Copy link
Member

bee-san commented Jul 25, 2020

Homebrew is the package manager for Mac OS.

We would like Ciphey to feature on Homebrew.
If possible, we would like to use Homebrew core. However, we can use a normal Homebrew tap for now if it's easier for ya!

Homebrew core

Another pentesting tool, Pwncat, is in Homebrew core with 300 stars. This means that, Ciphey, with 200 stars, should be able to make it into Homebrew core.

To do this, we will need to re-create the Homebrew file and submit it as a pull request to Core.
Pwncat's Homebrew core file looks like:
https://github.com/Homebrew/homebrew-core/blob/master/Formula/pwncat.rb

It would be a good idea to take inspiration from Pwncat, as I have found the Homebrew documentation to be confusing.

The documentation for Homebrew core is here:
https://github.com/Homebrew/homebrew-core/blob/master/CONTRIBUTING.md#to-add-a-new-formula-for-foo-version-234-from-url.

I am looking for some help to do this, as I am not a Mac user. If anyone wants to help out, you will be added to the README along with all the other contributors :D
Links

https://github.com/Homebrew/homebrew-core

If you need help or support, DM us on Discord or leave a comment ✨

@bee-san bee-san added enhancement New feature or request help wanted Extra attention is needed good first issue Good for newcomers labels Jul 25, 2020
@bee-san bee-san self-assigned this Jul 25, 2020
@Ciphey Ciphey deleted a comment from issue-label-bot bot Jul 25, 2020
@harens
Copy link
Contributor

harens commented Aug 4, 2020

I'd like to help out with this issue, since I've had some experience submitting python packages to homebrew/core in the past, and I'd love to support the project!

I've started writing a formula, but I've had some problems with the dependency cipheycore. On the PyPi download page, the only file type present is Wheel, which is pre-built. This causes some issues whilst writing the formula, and isn't generally accepted by homebrew.

I was wondering if there was a Source Distribution present instead? These are a lot easier to work with. Thanks for your help.

@bee-san
Copy link
Member Author

bee-san commented Aug 4, 2020

Hey @harens ! Thanks SO much for taking this on, it's also really cool you've submitted to Core too. I've tried to read the documentation so many times, but It just confuses me too much.

@Cyclic3 knows the answer to this, as they are the CipheyCore creator / maintainer :)

@Cyclic3
Copy link
Member

Cyclic3 commented Aug 4, 2020

@harens The problem is that the project is built in two stages, with the C++ cmake build creating an autogenerated python module (using SWIG), and then a thin poetry wrapper is used to build the wheel. This means that the resultant source distribution actually just consists of a small python script and a compiled library.

CipheyCore uses cmake, and the build process is fairly standard, with an extra poetry build step at the end to create the wheel.

If you have discord, feel free to join our server! My responses will generally be a lot faster there, allowing me to help a lot quicker.

To echo what @brandonskerritt said, thanks so much for offering to help with this! We've been bashing our head against the wall with this one for quite some time.

@harens
Copy link
Contributor

harens commented Aug 6, 2020

Thanks for both of your replies. Just to give you an update on where I am at the moment. Thanks to the instructions from @Cyclic3, I've been able to build a source distribution, and the only problem I need to fix is how to package cipheycore.

poetry has clikit as a dependency, and clikit has poetry as a dependency. This is a known python-poetry/poetry#1975 bug and has caused issues for other people writing homebrew formulae.

I might need some more time on this if that's ok. Congrats on how well your project has been doing recently and thanks for your help so far!

@harens
Copy link
Contributor

harens commented Aug 9, 2020

Until the cyclic dependency issue is fixed upstream, either by poetry or clikit, I'm a bit stumped as to how to write the formula.

There are five dependencies that require poetry, and so unlike another homebrew formula, it seems impractical in this case to try and remove these dependencies:

  • cipheycore
  • cipheydists
  • rich
  • yaspin
  • (ciphey itself)

I've left my progress below in case either the issue is resolved or someone else wants to have a go (note that some spacing didn't format nicely in the code block).

Homebrew
Attempt 1 - Build cipheycore source distribution

This aimed to build cipheycore from source, and replace the original files with the source distribution. At the time, I was unsure how to retain the changes to cipheycore, though this can be done as shown here

class Ciphey < Formula
    include Language::Python::Virtualenv
  
    desc "Automated decryption tool"
    homepage "https://github.com/Ciphey/Ciphey/"
    url "https://github.com/Ciphey/Ciphey/archive/5.0.0.tar.gz"
    sha256 "2437811b3cedb87fa2282efd70f122de32daba1401bd11e9eeefbfead87c4236"
    license "MIT"
    head "https://github.com/Ciphey/Ciphey.git"
  
    depends_on "boost" => :build
    depends_on "cmake" => :build
    depends_on "poetry" => :build
    depends_on "swig" => :build
    depends_on "python@3.8"
  
    resource "appdirs" do
      url "https://files.pythonhosted.org/packages/d7/d8/05696357e0311f5b5c316d7b95f46c669dd9c15aaeecbb48c7d0aeb88c40/appdirs-1.4.4.tar.gz"
      sha256 "7d5d0167b2b1ba821647616af46a749d1c653740dd0d2415100fe26e27afdf41"
    end
  
    resource "astroid" do
      url "https://files.pythonhosted.org/packages/ee/25/d3f01bc7e16641e0acb9a8c12decf1d5c2f04336c1f19ba69dc8e6927dff/astroid-2.4.2.tar.gz"
      sha256 "2f4078c2a41bf377eea06d71c9d2ba4eb8f6b1af2135bec27bbbb7d8f12bb703"
    end
  
    resource "base58" do
      url "https://files.pythonhosted.org/packages/66/0c/44d075d9b07bb25c4733421057a46fe1847e9c64286e8af11458815ff872/base58-2.0.1.tar.gz"
      sha256 "365c9561d9babac1b5f18ee797508cd54937a724b6e419a130abad69cec5ca79"
    end
  
    resource "cipheycore" do
      url "https://github.com/Ciphey/CipheyCore/archive/v0.2.9.tar.gz"
      sha256 "1f57da4dec6f71fe46e7764cec1160b7d9e296db980841adb108036144a6266a"
    end
  
    resource "cipheydists" do
      url "https://files.pythonhosted.org/packages/47/95/a83b8d3ca9f1e1942b6dcb645ece19a28d742bd1902e75832e238d9bb18d/cipheydists-0.3.18.tar.gz"
      sha256 "2ca056ea428b5e6328bff814ec0eb223c1571d6786dd6917297f9ac2bb281934"
    end
  
    resource "click" do
      url "https://files.pythonhosted.org/packages/27/6f/be940c8b1f1d69daceeb0032fee6c34d7bd70e3e649ccac0951500b4720e/click-7.1.2.tar.gz"
      sha256 "d2b5255c7c6349bc1bd1e59e08cd12acbbd63ce649f2588755783aa94dfb6b1a"
    end
  
    resource "click-spinner" do
      url "https://files.pythonhosted.org/packages/af/3a/7dbc558fcf0ae9e2e8b7ccc52daeb4eaf32b21f851497f5b409e1638dcee/click-spinner-0.1.10.tar.gz"
      sha256 "87eacf9d7298973a25d7615ef57d4782aebf913a532bba4b28a37e366e975daf"
    end
  
    resource "colorama" do
      url "https://files.pythonhosted.org/packages/82/75/f2a4c0c94c85e2693c229142eb448840fba0f9230111faa889d1f541d12d/colorama-0.4.3.tar.gz"
      sha256 "e96da0d330793e2cb9485e9ddfd918d456036c7149416295932478192f4436a1"
    end
  
    resource "commonmark" do
      url "https://files.pythonhosted.org/packages/60/48/a60f593447e8f0894ebb7f6e6c1f25dafc5e89c5879fdc9360ae93ff83f0/commonmark-0.9.1.tar.gz"
      sha256 "452f9dc859be7f06631ddcb328b6919c67984aca654e5fefb3914d54691aed60"
    end
  
    resource "flake8" do
      url "https://files.pythonhosted.org/packages/99/eb/cc2bbe9b242a79d2c5820911f21875a138aafa3dc2c3b9b34ba714f9fef9/flake8-3.8.3.tar.gz"
      sha256 "f04b9fcbac03b0a3e58c0ab3a0ecc462e023a9faf046d57794184028123aa208"
    end
  
    resource "isort" do
      url "https://files.pythonhosted.org/packages/43/00/8705e8d0c05ba22f042634f791a61f4c678c32175763dcf2ca2a133f4739/isort-4.3.21.tar.gz"
      sha256 "54da7e92468955c4fceacd0c86bd0ec997b0e1ee80d97f67c35a78b719dccab1"
    end
  
    resource "lazy-object-proxy" do
      url "https://files.pythonhosted.org/packages/07/3f/a3d687f83c7d44970f70ff0400677746c8860b11f0c08f6b4e07205f0cdc/lazy-object-proxy-1.4.3.tar.gz"
      sha256 "f3900e8a5de27447acbf900b4750b0ddfd7ec1ea7fbaf11dfa911141bc522af0"
    end
  
    resource "loguru" do
      url "https://files.pythonhosted.org/packages/6d/aa/1c523f7955c718f603d0a7c6e72f0593e7335d967fabdce589ab86afaa9e/loguru-0.5.1.tar.gz"
      sha256 "70201d5fce26da89b7a5f168caa2bb674e06b969829f56737db1d6472e53e7c3"
    end
  
    resource "mccabe" do
      url "https://files.pythonhosted.org/packages/06/18/fa675aa501e11d6d6ca0ae73a101b2f3571a565e0f7d38e062eec18a91ee/mccabe-0.6.1.tar.gz"
      sha256 "dd8d182285a0fe56bace7f45b5e7d1a6ebcbf524e8f3bd87eb0f125271b8831f"
    end
  
    resource "pprintpp" do
      url "https://files.pythonhosted.org/packages/06/1a/7737e7a0774da3c3824d654993cf57adc915cb04660212f03406334d8c0b/pprintpp-0.4.0.tar.gz"
      sha256 "ea826108e2c7f49dc6d66c752973c3fc9749142a798d6b254e1e301cfdbc6403"
    end
  
    resource "pybase62" do
      url "https://files.pythonhosted.org/packages/f6/24/d8c2de1d9befb05ceabdb7530cb6d2b782838429912a7e6783ed1f0ae305/pybase62-0.4.3.tar.gz"
      sha256 "0fbbe8474fc5fb020cc7f94dc88adfd12ef9bf38640c46612568ea07f046438c"
    end
  
    resource "pycodestyle" do
      url "https://files.pythonhosted.org/packages/bb/82/0df047a5347d607be504ad5faa255caa7919562962b934f9372b157e8a70/pycodestyle-2.6.0.tar.gz"
      sha256 "c58a7d2815e0e8d7972bf1803331fb0152f867bd89adf8a01dfd55085434192e"
    end
  
    resource "pyflakes" do
      url "https://files.pythonhosted.org/packages/f1/e2/e02fc89959619590eec0c35f366902535ade2728479fc3082c8af8840013/pyflakes-2.2.0.tar.gz"
      sha256 "35b2d75ee967ea93b55750aa9edbbf72813e06a66ba54438df2cfac9e3c27fc8"
    end
  
    resource "Pygments" do
      url "https://files.pythonhosted.org/packages/6e/4d/4d2fe93a35dfba417311a4ff627489a947b01dc0cc377a3673c00cf7e4b2/Pygments-2.6.1.tar.gz"
      sha256 "647344a061c249a3b74e230c739f434d7ea4d8b1d5f3721bc0f3558049b38f44"
    end
  
    resource "pylint" do
      url "https://files.pythonhosted.org/packages/3b/f0/ee19aeccaea881c38d129f015b2be7658724fcefa3a506d7c44747d764d9/pylint-2.5.3.tar.gz"
      sha256 "7dd78437f2d8d019717dbf287772d0b2dbdfd13fc016aa7faa08d67bccc46adc"
    end
  
    resource "PyYAML" do
      url "https://files.pythonhosted.org/packages/64/c2/b80047c7ac2478f9501676c988a5411ed5572f35d1beff9cae07d321512c/PyYAML-5.3.1.tar.gz"
      sha256 "b8eac752c5e14d3eca0e6dd9199cd627518cb5ec06add0de9d32baeee6fe645d"
    end
  
    resource "rich" do
      url "https://files.pythonhosted.org/packages/dd/dd/cc49e426f8b92c5e5d7f90e7a63d7ab1b8a9251d9424ed838e3e9d6fcbb2/rich-4.2.2.tar.gz"
      sha256 "89ea8935f40357d724ac8a2c0eac1f2042fc2ff63436a984042c12a9f111cce6"
    end
  
    resource "six" do
      url "https://files.pythonhosted.org/packages/6b/34/415834bfdafca3c5f451532e8a8d9ba89a21c9743a0c59fbd0205c7f9426/six-1.15.0.tar.gz"
      sha256 "30639c035cdb23534cd4aa2dd52c3bf48f06e5f4a941509c8bafd8ce11080259"
    end
  
    resource "toml" do
      url "https://files.pythonhosted.org/packages/da/24/84d5c108e818ca294efe7c1ce237b42118643ce58a14d2462b3b2e3800d5/toml-0.10.1.tar.gz"
      sha256 "926b612be1e5ce0634a2ca03470f95169cf16f939018233a670519cb4ac58b0f"
    end
  
    resource "typing-extensions" do
      url "https://files.pythonhosted.org/packages/6a/28/d32852f2af6b5ead85d396249d5bdf450833f3a69896d76eb480d9c5e406/typing_extensions-3.7.4.2.tar.gz"
      sha256 "79ee589a3caca649a9bfd2a8de4709837400dfa00b6cc81962a1e6a1815969ae"
    end
  
    resource "wrapt" do
      url "https://files.pythonhosted.org/packages/82/f7/e43cefbe88c5fd371f4cf0cf5eb3feccd07515af9fd6cf7dbf1d1793a797/wrapt-1.12.1.tar.gz"
      sha256 "b62ffa81fb85f4332a4f609cab4ac40709470da05643a082ec1eb88e6d9b97d7"
    end
  
    resource "yaspin" do
      url "https://files.pythonhosted.org/packages/15/18/8adfa773b48ac964284b32040f626262a1fbc0506f7d334dca3d46aef421/yaspin-0.17.0.tar.gz"
      sha256 "4330b240e3cb7ad990dbdc9c72891fecb1e1668cc19f0e44440bb01ffe2b1e56"
    end
  
    def install
      # ENV.deparallelize  # if your formula fails when building in parallel
      resource("cipheycore").stage do
        mkdir("build")
        system "cmake", "-S", ".", "-B", "build", "-DCIPHEY_CORE_TEST=OFF",
               "-DCIPHEY_CORE_PYTHON=#{CIPHEY_PYTHON_INCLUDE}"
        system "cmake", "--build", "build"
        system "cd build && poetry build -f sdist"
        system "mv build/dist/cipheycore-0.2.9.tar.gz cipheycore-0.2.9.tar.gz"
        system "find . -type f ! -iname '*.tar.gz' -delete"
        system "tar -xvf cipheycore-0.2.9.tar.gz --strip-components=1"
      end
      virtualenv_install_with_resources
    end
  
    test do
      # `test do` will create, run in and delete a temporary directory.
      #
      # This test will fail and we won't accept that! For Homebrew/homebrew-core
      # this will need to be a test that verifies the functionality of the
      # software. Run the test with `brew test Ciphey`. Options passed
      # to `brew install` such as `--HEAD` also need to be provided to `brew test`.
      #
      # The installed folder is not in the path, so use the entire path to any
      # executables being tested: `system "#{bin}/program", "do", "something"`.
      system "false"
    end
  end

Attempt 2 - Install from Poetry

I realised that there's no point building a source distribution when you can install cipheycore directly through poetry. With hindsight, I should've set poetry to not create a virtual environment.

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

    desc "Automated decryption tool"
    homepage "https://github.com/Ciphey/Ciphey/"
    url "https://github.com/Ciphey/Ciphey/archive/5.0.0.tar.gz"
    sha256 "2437811b3cedb87fa2282efd70f122de32daba1401bd11e9eeefbfead87c4236"
    license "MIT"
    head "https://github.com/Ciphey/Ciphey.git"
  
    depends_on "boost" => :build
    depends_on "cmake" => :build
    depends_on "poetry" => :build
    depends_on "swig" => :build
    depends_on "python@3.8"
  
    resource "appdirs" do
      url "https://files.pythonhosted.org/packages/d7/d8/05696357e0311f5b5c316d7b95f46c669dd9c15aaeecbb48c7d0aeb88c40/appdirs-1.4.4.tar.gz"
      sha256 "7d5d0167b2b1ba821647616af46a749d1c653740dd0d2415100fe26e27afdf41"
    end
  
    resource "astroid" do
      url "https://files.pythonhosted.org/packages/ee/25/d3f01bc7e16641e0acb9a8c12decf1d5c2f04336c1f19ba69dc8e6927dff/astroid-2.4.2.tar.gz"
      sha256 "2f4078c2a41bf377eea06d71c9d2ba4eb8f6b1af2135bec27bbbb7d8f12bb703"
    end
  
    resource "base58" do
      url "https://files.pythonhosted.org/packages/66/0c/44d075d9b07bb25c4733421057a46fe1847e9c64286e8af11458815ff872/base58-2.0.1.tar.gz"
      sha256 "365c9561d9babac1b5f18ee797508cd54937a724b6e419a130abad69cec5ca79"
    end
  
    resource "cipheycore" do
      url "https://github.com/Ciphey/CipheyCore/archive/v0.2.9.tar.gz"
      sha256 "1f57da4dec6f71fe46e7764cec1160b7d9e296db980841adb108036144a6266a"
    end
  
    resource "cipheydists" do
      url "https://files.pythonhosted.org/packages/47/95/a83b8d3ca9f1e1942b6dcb645ece19a28d742bd1902e75832e238d9bb18d/cipheydists-0.3.18.tar.gz"
      sha256 "2ca056ea428b5e6328bff814ec0eb223c1571d6786dd6917297f9ac2bb281934"
    end
  
    resource "click" do
      url "https://files.pythonhosted.org/packages/27/6f/be940c8b1f1d69daceeb0032fee6c34d7bd70e3e649ccac0951500b4720e/click-7.1.2.tar.gz"
      sha256 "d2b5255c7c6349bc1bd1e59e08cd12acbbd63ce649f2588755783aa94dfb6b1a"
    end
  
    resource "click-spinner" do
      url "https://files.pythonhosted.org/packages/af/3a/7dbc558fcf0ae9e2e8b7ccc52daeb4eaf32b21f851497f5b409e1638dcee/click-spinner-0.1.10.tar.gz"
      sha256 "87eacf9d7298973a25d7615ef57d4782aebf913a532bba4b28a37e366e975daf"
    end
  
    resource "colorama" do
      url "https://files.pythonhosted.org/packages/82/75/f2a4c0c94c85e2693c229142eb448840fba0f9230111faa889d1f541d12d/colorama-0.4.3.tar.gz"
      sha256 "e96da0d330793e2cb9485e9ddfd918d456036c7149416295932478192f4436a1"
    end
  
    resource "commonmark" do
      url "https://files.pythonhosted.org/packages/60/48/a60f593447e8f0894ebb7f6e6c1f25dafc5e89c5879fdc9360ae93ff83f0/commonmark-0.9.1.tar.gz"
      sha256 "452f9dc859be7f06631ddcb328b6919c67984aca654e5fefb3914d54691aed60"
    end
  
    resource "flake8" do
      url "https://files.pythonhosted.org/packages/99/eb/cc2bbe9b242a79d2c5820911f21875a138aafa3dc2c3b9b34ba714f9fef9/flake8-3.8.3.tar.gz"
      sha256 "f04b9fcbac03b0a3e58c0ab3a0ecc462e023a9faf046d57794184028123aa208"
    end
  
    resource "isort" do
      url "https://files.pythonhosted.org/packages/43/00/8705e8d0c05ba22f042634f791a61f4c678c32175763dcf2ca2a133f4739/isort-4.3.21.tar.gz"
      sha256 "54da7e92468955c4fceacd0c86bd0ec997b0e1ee80d97f67c35a78b719dccab1"
    end
  
    resource "lazy-object-proxy" do
      url "https://files.pythonhosted.org/packages/07/3f/a3d687f83c7d44970f70ff0400677746c8860b11f0c08f6b4e07205f0cdc/lazy-object-proxy-1.4.3.tar.gz"
      sha256 "f3900e8a5de27447acbf900b4750b0ddfd7ec1ea7fbaf11dfa911141bc522af0"
    end
  
    resource "loguru" do
      url "https://files.pythonhosted.org/packages/6d/aa/1c523f7955c718f603d0a7c6e72f0593e7335d967fabdce589ab86afaa9e/loguru-0.5.1.tar.gz"
      sha256 "70201d5fce26da89b7a5f168caa2bb674e06b969829f56737db1d6472e53e7c3"
    end
  
    resource "mccabe" do
      url "https://files.pythonhosted.org/packages/06/18/fa675aa501e11d6d6ca0ae73a101b2f3571a565e0f7d38e062eec18a91ee/mccabe-0.6.1.tar.gz"
      sha256 "dd8d182285a0fe56bace7f45b5e7d1a6ebcbf524e8f3bd87eb0f125271b8831f"
    end
  
    resource "pprintpp" do
      url "https://files.pythonhosted.org/packages/06/1a/7737e7a0774da3c3824d654993cf57adc915cb04660212f03406334d8c0b/pprintpp-0.4.0.tar.gz"
      sha256 "ea826108e2c7f49dc6d66c752973c3fc9749142a798d6b254e1e301cfdbc6403"
    end
  
    resource "pybase62" do
      url "https://files.pythonhosted.org/packages/f6/24/d8c2de1d9befb05ceabdb7530cb6d2b782838429912a7e6783ed1f0ae305/pybase62-0.4.3.tar.gz"
      sha256 "0fbbe8474fc5fb020cc7f94dc88adfd12ef9bf38640c46612568ea07f046438c"
    end
  
    resource "pycodestyle" do
      url "https://files.pythonhosted.org/packages/bb/82/0df047a5347d607be504ad5faa255caa7919562962b934f9372b157e8a70/pycodestyle-2.6.0.tar.gz"
      sha256 "c58a7d2815e0e8d7972bf1803331fb0152f867bd89adf8a01dfd55085434192e"
    end
  
    resource "pyflakes" do
      url "https://files.pythonhosted.org/packages/f1/e2/e02fc89959619590eec0c35f366902535ade2728479fc3082c8af8840013/pyflakes-2.2.0.tar.gz"
      sha256 "35b2d75ee967ea93b55750aa9edbbf72813e06a66ba54438df2cfac9e3c27fc8"
    end
  
    resource "Pygments" do
      url "https://files.pythonhosted.org/packages/6e/4d/4d2fe93a35dfba417311a4ff627489a947b01dc0cc377a3673c00cf7e4b2/Pygments-2.6.1.tar.gz"
      sha256 "647344a061c249a3b74e230c739f434d7ea4d8b1d5f3721bc0f3558049b38f44"
    end
  
    resource "pylint" do
      url "https://files.pythonhosted.org/packages/3b/f0/ee19aeccaea881c38d129f015b2be7658724fcefa3a506d7c44747d764d9/pylint-2.5.3.tar.gz"
      sha256 "7dd78437f2d8d019717dbf287772d0b2dbdfd13fc016aa7faa08d67bccc46adc"
    end
  
    resource "PyYAML" do
      url "https://files.pythonhosted.org/packages/64/c2/b80047c7ac2478f9501676c988a5411ed5572f35d1beff9cae07d321512c/PyYAML-5.3.1.tar.gz"
      sha256 "b8eac752c5e14d3eca0e6dd9199cd627518cb5ec06add0de9d32baeee6fe645d"
    end
  
    resource "rich" do
      url "https://files.pythonhosted.org/packages/dd/dd/cc49e426f8b92c5e5d7f90e7a63d7ab1b8a9251d9424ed838e3e9d6fcbb2/rich-4.2.2.tar.gz"
      sha256 "89ea8935f40357d724ac8a2c0eac1f2042fc2ff63436a984042c12a9f111cce6"
    end
  
    resource "six" do
      url "https://files.pythonhosted.org/packages/6b/34/415834bfdafca3c5f451532e8a8d9ba89a21c9743a0c59fbd0205c7f9426/six-1.15.0.tar.gz"
      sha256 "30639c035cdb23534cd4aa2dd52c3bf48f06e5f4a941509c8bafd8ce11080259"
    end
  
    resource "toml" do
      url "https://files.pythonhosted.org/packages/da/24/84d5c108e818ca294efe7c1ce237b42118643ce58a14d2462b3b2e3800d5/toml-0.10.1.tar.gz"
      sha256 "926b612be1e5ce0634a2ca03470f95169cf16f939018233a670519cb4ac58b0f"
    end
  
    resource "typing-extensions" do
      url "https://files.pythonhosted.org/packages/6a/28/d32852f2af6b5ead85d396249d5bdf450833f3a69896d76eb480d9c5e406/typing_extensions-3.7.4.2.tar.gz"
      sha256 "79ee589a3caca649a9bfd2a8de4709837400dfa00b6cc81962a1e6a1815969ae"
    end
  
    resource "wrapt" do
      url "https://files.pythonhosted.org/packages/82/f7/e43cefbe88c5fd371f4cf0cf5eb3feccd07515af9fd6cf7dbf1d1793a797/wrapt-1.12.1.tar.gz"
      sha256 "b62ffa81fb85f4332a4f609cab4ac40709470da05643a082ec1eb88e6d9b97d7"
    end
  
    resource "yaspin" do
      url "https://files.pythonhosted.org/packages/15/18/8adfa773b48ac964284b32040f626262a1fbc0506f7d334dca3d46aef421/yaspin-0.17.0.tar.gz"
      sha256 "4330b240e3cb7ad990dbdc9c72891fecb1e1668cc19f0e44440bb01ffe2b1e56"
    end
  
    def install
      # ENV.deparallelize  # if your formula fails when building in parallel
      virtualenv_create(libexec, "python3")
      resource("cipheycore").stage do
        mkdir("build")
        system "cmake", "-S", ".", "-B", "build", "-DCIPHEY_CORE_TEST=OFF",
               "-DCIPHEY_CORE_PYTHON=#{CIPHEY_PYTHON_INCLUDE}"
        system "cmake", "--build", "build"
        system "cd build && poetry install"
      end
      venv.pip_install resources
      venv.pip_install_and_link buildpath
    end
    test do
      # `test do` will create, run in and delete a temporary directory.
      #
      # This test will fail and we won't accept that! For Homebrew/homebrew-core
      # this will need to be a test that verifies the functionality of the
      # software. Run the test with `brew test Ciphey`. Options passed
      # to `brew install` such as `--HEAD` also need to be provided to `brew test`.
      #
      # The installed folder is not in the path, so use the entire path to any
      # executables being tested: `system "#{bin}/program", "do", "something"`.
      system "false"
    end
  end
 

Attempt 3 - Remove poetry manually

I tried removing the pyproject.toml from each project and replacing it with a suitable setup.py using dephell. If this had worked, I would then try and automate this by staging each resource.

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

  desc "Automated decryption tool"
  homepage "https://github.com/Ciphey/Ciphey/"
  url "https://github.com/harens/Ciphey/archive/master.tar.gz"
  sha256 "f939d46ba845d65d8613daf14fbebb4f3a6bd1a2278f08647b9145ffe24294be"
  version "5.1.0"
  license "MIT"
  head "https://github.com/harens/Ciphey.git"

  depends_on "python@3.8"

  resource "appdirs" do
    url "https://files.pythonhosted.org/packages/d7/d8/05696357e0311f5b5c316d7b95f46c669dd9c15aaeecbb48c7d0aeb88c40/appdirs-1.4.4.tar.gz"
    sha256 "7d5d0167b2b1ba821647616af46a749d1c653740dd0d2415100fe26e27afdf41"
  end

  resource "astroid" do
    url "https://files.pythonhosted.org/packages/ee/25/d3f01bc7e16641e0acb9a8c12decf1d5c2f04336c1f19ba69dc8e6927dff/astroid-2.4.2.tar.gz"
    sha256 "2f4078c2a41bf377eea06d71c9d2ba4eb8f6b1af2135bec27bbbb7d8f12bb703"
  end

  resource "base58" do
    url "https://files.pythonhosted.org/packages/66/0c/44d075d9b07bb25c4733421057a46fe1847e9c64286e8af11458815ff872/base58-2.0.1.tar.gz"
    sha256 "365c9561d9babac1b5f18ee797508cd54937a724b6e419a130abad69cec5ca79"
  end

  resource "cipheycore" do
    url "https://github.com/harens/cipheycore---sdist/archive/master.tar.gz"
    sha256 "a6af030d71374284b120c9d86c8ae9f85c1570d091a58e2cfbd49318e24aa616"
  end

  resource "cipheydists" do
    url "https://github.com/harens/CipheyDists/archive/master.tar.gz"
    sha256 "9a073713b99908aaf0ede6cb84359e597177e2ecc64bee59565df55c25d899e9"
  end

  resource "click" do
    url "https://files.pythonhosted.org/packages/27/6f/be940c8b1f1d69daceeb0032fee6c34d7bd70e3e649ccac0951500b4720e/click-7.1.2.tar.gz"
    sha256 "d2b5255c7c6349bc1bd1e59e08cd12acbbd63ce649f2588755783aa94dfb6b1a"
  end

  resource "click-spinner" do
    url "https://files.pythonhosted.org/packages/af/3a/7dbc558fcf0ae9e2e8b7ccc52daeb4eaf32b21f851497f5b409e1638dcee/click-spinner-0.1.10.tar.gz"
    sha256 "87eacf9d7298973a25d7615ef57d4782aebf913a532bba4b28a37e366e975daf"
  end

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

  resource "commonmark" do
    url "https://files.pythonhosted.org/packages/60/48/a60f593447e8f0894ebb7f6e6c1f25dafc5e89c5879fdc9360ae93ff83f0/commonmark-0.9.1.tar.gz"
    sha256 "452f9dc859be7f06631ddcb328b6919c67984aca654e5fefb3914d54691aed60"
  end

  resource "flake8" do
    url "https://files.pythonhosted.org/packages/99/eb/cc2bbe9b242a79d2c5820911f21875a138aafa3dc2c3b9b34ba714f9fef9/flake8-3.8.3.tar.gz"
    sha256 "f04b9fcbac03b0a3e58c0ab3a0ecc462e023a9faf046d57794184028123aa208"
  end

  resource "isort" do
    url "https://files.pythonhosted.org/packages/43/00/8705e8d0c05ba22f042634f791a61f4c678c32175763dcf2ca2a133f4739/isort-4.3.21.tar.gz"
    sha256 "54da7e92468955c4fceacd0c86bd0ec997b0e1ee80d97f67c35a78b719dccab1"
  end

  resource "lazy-object-proxy" do
    url "https://files.pythonhosted.org/packages/07/3f/a3d687f83c7d44970f70ff0400677746c8860b11f0c08f6b4e07205f0cdc/lazy-object-proxy-1.4.3.tar.gz"
    sha256 "f3900e8a5de27447acbf900b4750b0ddfd7ec1ea7fbaf11dfa911141bc522af0"
  end

  resource "loguru" do
    url "https://files.pythonhosted.org/packages/6d/aa/1c523f7955c718f603d0a7c6e72f0593e7335d967fabdce589ab86afaa9e/loguru-0.5.1.tar.gz"
    sha256 "70201d5fce26da89b7a5f168caa2bb674e06b969829f56737db1d6472e53e7c3"
  end

  resource "mccabe" do
    url "https://files.pythonhosted.org/packages/06/18/fa675aa501e11d6d6ca0ae73a101b2f3571a565e0f7d38e062eec18a91ee/mccabe-0.6.1.tar.gz"
    sha256 "dd8d182285a0fe56bace7f45b5e7d1a6ebcbf524e8f3bd87eb0f125271b8831f"
  end

  resource "pprintpp" do
    url "https://files.pythonhosted.org/packages/06/1a/7737e7a0774da3c3824d654993cf57adc915cb04660212f03406334d8c0b/pprintpp-0.4.0.tar.gz"
    sha256 "ea826108e2c7f49dc6d66c752973c3fc9749142a798d6b254e1e301cfdbc6403"
  end

  resource "pybase62" do
    url "https://files.pythonhosted.org/packages/f6/24/d8c2de1d9befb05ceabdb7530cb6d2b782838429912a7e6783ed1f0ae305/pybase62-0.4.3.tar.gz"
    sha256 "0fbbe8474fc5fb020cc7f94dc88adfd12ef9bf38640c46612568ea07f046438c"
  end

  resource "pycodestyle" do
    url "https://files.pythonhosted.org/packages/bb/82/0df047a5347d607be504ad5faa255caa7919562962b934f9372b157e8a70/pycodestyle-2.6.0.tar.gz"
    sha256 "c58a7d2815e0e8d7972bf1803331fb0152f867bd89adf8a01dfd55085434192e"
  end

  resource "pyflakes" do
    url "https://files.pythonhosted.org/packages/f1/e2/e02fc89959619590eec0c35f366902535ade2728479fc3082c8af8840013/pyflakes-2.2.0.tar.gz"
    sha256 "35b2d75ee967ea93b55750aa9edbbf72813e06a66ba54438df2cfac9e3c27fc8"
  end

  resource "Pygments" do
    url "https://files.pythonhosted.org/packages/6e/4d/4d2fe93a35dfba417311a4ff627489a947b01dc0cc377a3673c00cf7e4b2/Pygments-2.6.1.tar.gz"
    sha256 "647344a061c249a3b74e230c739f434d7ea4d8b1d5f3721bc0f3558049b38f44"
  end

  resource "pylint" do
    url "https://files.pythonhosted.org/packages/3b/f0/ee19aeccaea881c38d129f015b2be7658724fcefa3a506d7c44747d764d9/pylint-2.5.3.tar.gz"
    sha256 "7dd78437f2d8d019717dbf287772d0b2dbdfd13fc016aa7faa08d67bccc46adc"
  end

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

  resource "rich" do
    url "https://github.com/harens/rich/archive/master.tar.gz"
    sha256 "116aa1e90396a77896f68a0061d44496008f5eeecb0834eab4a2879c58a1e438"
  end

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

  resource "toml" do
    url "https://files.pythonhosted.org/packages/da/24/84d5c108e818ca294efe7c1ce237b42118643ce58a14d2462b3b2e3800d5/toml-0.10.1.tar.gz"
    sha256 "926b612be1e5ce0634a2ca03470f95169cf16f939018233a670519cb4ac58b0f"
  end

  resource "typing-extensions" do
    url "https://files.pythonhosted.org/packages/6a/28/d32852f2af6b5ead85d396249d5bdf450833f3a69896d76eb480d9c5e406/typing_extensions-3.7.4.2.tar.gz"
    sha256 "79ee589a3caca649a9bfd2a8de4709837400dfa00b6cc81962a1e6a1815969ae"
  end

  resource "wrapt" do
    url "https://files.pythonhosted.org/packages/82/f7/e43cefbe88c5fd371f4cf0cf5eb3feccd07515af9fd6cf7dbf1d1793a797/wrapt-1.12.1.tar.gz"
    sha256 "b62ffa81fb85f4332a4f609cab4ac40709470da05643a082ec1eb88e6d9b97d7"
  end

  resource "yaspin" do
    url "https://github.com/harens/yaspin/archive/master.tar.gz"
    sha256 "5a054cd1af14aad6949d5b39fb40bdea3356362c3ec4f30e875f3ef60f2e2505"
  end

  def install
    virtualenv_install_with_resources
  end
  test do
    # `test do` will create, run in and delete a temporary directory.
    #
    # This test will fail and we won't accept that! For Homebrew/homebrew-core
    # this will need to be a test that verifies the functionality of the
    # software. Run the test with `brew test Ciphey`. Options passed
    # to `brew install` such as `--HEAD` also need to be provided to `brew test`.
    #
    # The installed folder is not in the path, so use the entire path to any
    # executables being tested: `system "#{bin}/program", "do", "something"`.
    system "false"
  end
end

MacPorts
ciphey

This was probably the closest I got to packaging ciphey. The only issue was that a lot of the dependencies don't have portfiles, and I wan't sure how to package them.

# -*- coding: utf-8; mode: tcl; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- vim:fenc=utf-8:ft=tcl:et:sw=4:ts=4:sts=4

PortSystem          1.0
PortGroup           python 1.0

name                ciphey
version             5.1.0
platforms           darwin
supported_archs     noarch
license             MIT
maintainers         {@harens gmail.com:harensdeveloper} \
			        openmaintainer

description         Automated Decryption Tool
long_description    ${description}

homepage            https://pypi.org/project/ciphey

checksums           rmd160  94d92b6a1e1d2dfc00b2c486b92621177c03ae19 \
                    sha256  14163ecdf4967617746b17146b42eba9a98eda4955a0b681df8d0dc690f1ca63 \
                    size    41545

# For some reason there's segmentation fault on 37 and 38
python.versions     36

if {${name} ne ${subport}} {
    depends_build-append \
                    port:py${python.version}-setuptools

    depends_lib-append \
                    port:py${python.version}-appdirs \
                    port:py${python.version}-base58 \
                    port:py${python.version}-cipheycore \
                    port:py${python.version}-cipheydists \
                    port:py${python.version}-click \
                    port:py${python.version}-click-spinner \
                    port:py${python.version}-flake8 \
                    port:py${python.version}-loguru \
                    port:py${python.version}-pybase62 \
                    port:py${python.version}-pylint \
                    port:py${python.version}-pyyaml \
                    port:py${python.version}-rich \
                    port:py${python.version}-yaspin

    livecheck.type  none
} else {
	livecheck.type  pypi
}

cipheydists

This appears to work fine. I might submit it to macports/ports and see what the response is.

# -*- coding: utf-8; mode: tcl; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- vim:fenc=utf-8:ft=tcl:et:sw=4:ts=4:sts=4

PortSystem          1.0
PortGroup           python 1.0
name                cipheydists
version             0.3.18


categories          crypto python
platforms           darwin
supported_archs     noarch
license             unlicense
maintainers         {@harens gmail.com:harensdeveloper} \
			        openmaintainer

description         A collection of distributions, character sets and dictionaries for use in ciphey
long_description    ${description}

homepage            https://www.github.com/Ciphey/${name}
master_sites        pypi:[string index ${name} 0]/${name}
distname            ${name}-${version}

checksums           rmd160  74ebdb064b1a8e28c06d5f91de2a661a4dfd1a8d \
                    sha256  2ca056ea428b5e6328bff814ec0eb223c1571d6786dd6917297f9ac2bb281934 \
                    size    9988280

python.versions     38

if {${name} ne ${subport}} {
    livecheck.type  none
} else {
    livecheck.type  regex
	livecheck.url   https://pypi.python.org/pypi/${name}
	livecheck.regex "${name}/(\\d+(?:\\.\\d+)*(-p\\d+)?)"
}

Sorry I was unable to write a formula, but I hope this helps.

@harens
Copy link
Contributor

harens commented Feb 9, 2021

Just looking back at this issue more than six months later, who would've thought that Ciphey would finally be added to MacPorts.

For any future readers, the poetry cyclic dependency issue is no longer a problem, and please don't use the Formulae/Portfiles I attached as a basis for anything (looking back on them, they're not great...). I left my thoughts in Ciphey/CipheyCore#17 for anyone who wants to attempt this.

@bee-san
Copy link
Member Author

bee-san commented Feb 9, 2021

Woah! So awesome @harens 👏 We're currently re-writing Ciphey without the C++ core to make it more compatible for other OS' :D

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request feature_request good first issue Good for newcomers help wanted Extra attention is needed
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants