Merge pull request #19250 from Homebrew/ww/warn-pypi-info-no-dist
[Homebrew/brew.git] / docs / Adding-Software-to-Homebrew.md
blob694c0b24aa9900c10a3f9a1e01df85215a9a708b
1 ---
2 last_review_date: "1970-01-01"
3 ---
5 # Adding Software to Homebrew
7 Is your favourite software missing from Homebrew? Then you're the perfect person to resolve this problem.
9 If you want to add software that is either closed source or a GUI-only program, you will want to follow the guide for [Casks](#casks). Otherwise follow the guide for [Formulae](#formulae) (see also: [Homebrew Terminology](Formula-Cookbook.md#homebrew-terminology)).
11 Before you start, please check the open pull requests for [Homebrew/homebrew-core](https://github.com/Homebrew/homebrew-core/pulls) or [Homebrew/homebrew-cask](https://github.com/Homebrew/homebrew-cask/pulls) to make sure no one else beat you to the punch.
13 Next, you will want to go through the [Acceptable Formulae](Acceptable-Formulae.md) or [Acceptable Casks](Acceptable-Casks.md) documentation to determine if the software is an appropriate addition to Homebrew. If you are creating a formula for an alternative version of software already in Homebrew (e.g. a major/minor version that differs significantly from the existing version), be sure to read the [Versions](Versions.md) documentation to understand versioned formulae requirements.
15 If everything checks out, you're ready to get started on a new formula!
17 ## Formulae
19 ### Writing the formula
21 1. It's a good idea to find existing formulae in Homebrew that have similarities to the software you want to add. This will help you to understand how specific languages, build methods, etc. are typically handled. Start by tapping `homebrew/core`: first set `HOMEBREW_NO_INSTALL_FROM_API=1` in your shell environment, then run `brew tap --force homebrew/core` to clone the `homebrew/core` tap to the path returned by `brew --repository homebrew/core`.
23 1. If you're starting from scratch, you can use the [`brew create` command](Manpage.md#create-options-url) to produce a basic version of your formula. This command accepts a number of options and you may be able to save yourself some work by using an appropriate template option like `--python`.
25 1. You will now have to develop the boilerplate code from `brew create` into a full-fledged formula. Your main references will be the [Formula Cookbook](Formula-Cookbook.md), similar formulae in Homebrew, and the upstream documentation for your chosen software. Be sure to also take note of the Homebrew documentation for writing [Python](Python-for-Formula-Authors.md) and [Node](Node-for-Formula-Authors.md) formulae, if applicable.
27 1. Make sure you write a good test as part of your formula. Refer to the [Add a test to the formula](Formula-Cookbook.md#add-a-test-to-the-formula) section of the Cookbook for help with this.
29 1. Try installing your formula using `brew install --build-from-source <formula>`, where *\<formula>* is the name of your formula. If any errors occur, correct your formula and attempt to install it again. The formula installation should finish without errors by the end of this step.
31 If you're stuck, ask for help on GitHub or the [Homebrew discussion forum](https://github.com/orgs/Homebrew/discussions). The maintainers are very happy to help but we also like to see that you've put effort into trying to find a solution first.
33 ### Testing and auditing the formula
35 1. Run `brew audit --strict --new --online <formula>` with your formula. If any errors occur, correct your formula and run the audit again. The audit should finish without any errors by the end of this step.
37 1. Run your formula's test using `brew test <formula>`. The test should finish without any errors.
39 ### Submitting the formula
41 You're finally ready to submit your formula to the [homebrew-core](https://github.com/Homebrew/homebrew-core) repository. If you haven't done this before, you can refer to the [How to Open a Homebrew Pull Request](How-To-Open-a-Homebrew-Pull-Request.md#formulae-related-pull-request) documentation for help. Maintainers will review the pull request and provide feedback about any areas that need to be addressed before the formula can be added to Homebrew.
43 If you've made it this far, congratulations on submitting a Homebrew formula! We appreciate the hard work you put into this and you can take satisfaction in knowing that your work may benefit other Homebrew users as well.
45 ## Casks
47 **Note:** Before taking the time to craft a new cask:
49 * make sure it can be accepted by checking the [Rejected Casks FAQ](Acceptable-Casks.md#rejected-casks), and
50 * check that the cask was not [already refused](https://github.com/Homebrew/homebrew-cask/search?q=is%3Aclosed&type=Issues).
52 ### Writing the cask
54 Making a new cask is easy. Follow the directions in [How to Open a Homebrew Pull Request](How-To-Open-a-Homebrew-Pull-Request.md#cask-related-pull-request) to begin.
56 #### Examples
58 Here’s a cask for `dixa` as an example. Note the `verified` parameter below the `url`, which is needed when [the url and homepage hostnames differ](Cask-Cookbook.md#when-url-and-homepage-domains-differ-add-verified).
60 ```ruby
61 cask "dixa" do
62   version "4.0.12"
63   sha256 "a4e1a30d074e724ba24e9e2674a72bc4050f00161fb7dc23295a2c189ecda5bb"
65   url "https://github.com/dixahq/dixa-desktop-app-release/releases/download/v#{version}/dixa-#{version}.dmg",
66       verified: "github.com/dixahq/dixa-desktop-app-release/"
67   name "Dixa"
68   desc "Customer service platform"
69   homepage "https://dixa.com/"
71   livecheck do
72     url :url
73     strategy :github_latest
74   end
76   app "Dixa.app"
78   zap trash: [
79     "~/Library/Application Support/Dixa",
80     "~/Library/Logs/Dixa",
81     "~/Library/Preferences/dixa.plist",
82     "~/Library/Saved Application State/dixa.savedState",
83   ]
84 end
85 ```
87 And here is one for `pomello`. Note that it has an unversioned download (the download `url` does not contain the version number, unlike the example above). It also suppresses the checksum with `sha256 :no_check`, which is necessary because since the download `url` does not contain the version number, its checksum will change when a new version is made available.
89 ```ruby
90 cask "pomello" do
91   version "0.10.17"
92   sha256 :no_check
94   url "https://pomelloapp.com/download/mac/latest"
95   name "Pomello"
96   desc "Turns your Trello cards into Pomodoro tasks"
97   homepage "https://pomelloapp.com/"
99   livecheck do
100     url :url
101     strategy :header_match
102   end
104   app "Pomello.app"
106   zap trash: [
107     "~/Library/Application Support/com.apple.sharedfilelist/com.apple.LSSharedFileList.ApplicationRecentDocuments/com.tinynudge.pomello.*",
108     "~/Library/Application Support/Pomello",
109     "~/Library/Caches/com.tinynudge.pomello",
110     "~/Library/Caches/com.tinynudge.pomello.ShipIt",
111     "~/Library/HTTPStorages/com.tinynudge.pomello",
112     "~/Library/Preferences/com.tinynudge.pomello.plist",
113     "~/Library/Saved Application State/com.tinynudge.pomello.savedState",
114   ]
118 Here is a last example for `fabfilter-one`, which uses a `pkg` installer to install the application instead of a stand-alone application bundle (`.app`). Note the [`uninstall pkgutil` stanza](Cask-Cookbook.md#uninstall-pkgutil), which is needed to uninstall all files that were installed using the installer.
120 You will also see how to adapt `version` to the download `url`. Use [our custom `version` methods](Cask-Cookbook.md#version-methods) to do so, resorting to the standard [Ruby String methods](https://ruby-doc.org/core/String.html) when they don’t suffice.
122 ```ruby
123 cask "fabfilter-one" do
124   version "3.37"
125   sha256 "4059594580e365237ded16a213d8d549cbb01c4b8bad80895c61f44bcff7eb68"
127   url "https://download.fabfilter.com/ffone#{version.no_dots}.dmg"
128   name "FabFilter One"
129   desc "Synthesizer plug-in"
130   homepage "https://www.fabfilter.com/products/volcano-2-powerful-filter-plug-in"
132   livecheck do
133     url "https://www.fabfilter.com/download"
134     strategy :page_match do |page|
135       match = page.match(/ffone(\d)(\d+)\.dmg/i)
136       next if match.blank?
138       "#{match[1]}.#{match[2]}"
139     end
140   end
142   depends_on macos: ">= :sierra"
144   pkg "FabFilter One #{version} Installer.pkg"
146   uninstall pkgutil: "com.fabfilter.One.#{version.major}"
148   # No zap stanza required
152 #### Generating a token for the cask
154 The cask **token** is the mnemonic string people will use to interact with the cask via `brew install`, etc. The name of the cask **file** is simply the token with the extension `.rb` appended.
156 The easiest way to generate a token for a cask is to run `generate_cask_token`:
158 ```bash
159 $(brew --repository homebrew/cask)/developer/bin/generate_cask_token "/full/path/to/new/software.app"
162 If the software you wish to create a cask for is not installed, or does not have an associated App bundle, just give the full proper name of the software instead of a pathname:
164 ```bash
165 $(brew --repository homebrew/cask)/developer/bin/generate_cask_token "Google Chrome"
168 If the `generate_cask_token` script does not work for you, see [Cask Token Details](#cask-token-details).
170 #### Creating the cask file
172 Once you know the token, create your cask with the `brew create --cask` command:
174 ```bash
175 brew create --cask download-url --set-name my-new-cask
178 This will open `EDITOR` with a template for your new cask, to be stored in the file `my-new-cask.rb`.
180 #### Cask stanzas
182 Fill in the following stanzas for your cask:
184 | name               | value       |
185 | ------------------ | ----------- |
186 | `version`          | application version |
187 | `sha256`           | SHA-256 checksum of the file downloaded from `url`, calculated by the command `shasum -a 256 <file>`. Can be suppressed by using the special value `:no_check`. (see [`sha256` Stanza Details](Cask-Cookbook.md#stanza-sha256)) |
188 | `url`              | URL to the `.dmg`/`.zip`/`.tgz`/`.tbz2` file that contains the application.<br />A [`verified` parameter](Cask-Cookbook.md#when-url-and-homepage-domains-differ-add-verified) must be added if the hostnames in the `url` and `homepage` stanzas differ. [Block syntax](Cask-Cookbook.md#using-a-block-to-defer-code-execution) is available for URLs that change on every visit. |
189 | `name`             | the full and proper name defined by the vendor, and any useful alternate names (see [`name` Stanza Details](Cask-Cookbook.md#stanza-name)) |
190 | `desc`             | one-line description of the software (see [`desc` Stanza Details](Cask-Cookbook.md#stanza-desc)) |
191 | `homepage`         | application homepage; used for the `brew home` command |
192 | `livecheck`        | Ruby block describing how to find updates for this cask (see [`livecheck` Stanza Details](Cask-Cookbook.md#stanza-livecheck)) |
193 | `app`              | relative path to an `.app` bundle that should be moved into the `/Applications` folder on installation (see [`app` Stanza Details](Cask-Cookbook.md#stanza-app)) |
194 | `zap`              | additional procedures for a more complete uninstall, including configuration files and shared resources (see [`zap` Stanza Details](Cask-Cookbook.md#stanza-zap)) |
196 Other commonly used stanzas are:
198 | name               | value       |
199 | ------------------ | ----------- |
200 | `pkg`              | relative path to a `.pkg` file containing the distribution (see [`pkg` Stanza Details](Cask-Cookbook.md#stanza-pkg)) |
201 | `caveats`          | string or Ruby block providing the user with cask-specific information at install time (see [`caveats` Stanza Details](Cask-Cookbook.md#stanza-caveats)) |
202 | `uninstall`        | procedures to uninstall a cask; optional unless the `pkg` stanza is used (see [`uninstall` Stanza Details](Cask-Cookbook.md#stanza-uninstall)) |
204 Additional [`artifact` stanzas](Cask-Cookbook.md#at-least-one-artifact-stanza-is-also-required) may be needed for special use cases. Even more special-use stanzas are listed at [Optional Stanzas](Cask-Cookbook.md#optional-stanzas).
206 #### Cask token details
208 If a token conflicts with an already-existing cask, authors should manually make the new token unique by prepending the vendor name. Example: [unison.rb](https://github.com/Homebrew/homebrew-cask/blob/HEAD/Casks/u/unison.rb) and [panic-unison.rb](https://github.com/Homebrew/homebrew-cask/blob/HEAD/Casks/p/panic-unison.rb).
210 If possible, avoid creating tokens that differ only by the placement of hyphens.
212 To generate a token manually, or to learn about exceptions for unusual cases, see the [Token Reference](Cask-Cookbook.md#token-reference).
214 #### Archives with subfolders
216 When a downloaded archive expands to a subfolder, the subfolder name must be included in the `app` value.
218 Example:
220 1. Simple Floating Clock is downloaded to the file `sfc.zip`.
221 1. `sfc.zip` unzips to a folder called `Simple Floating Clock`.
222 1. The folder `Simple Floating Clock` contains the application `SimpleFloatingClock.app`.
223 1. So, the `app` stanza should include the subfolder as a relative path:
225    ```ruby
226 app "Simple Floating Clock/SimpleFloatingClock.app"
227    ```
229 ### Testing and auditing the cask
231 Give it a shot with:
233 ```bash
234 export HOMEBREW_NO_AUTO_UPDATE=1
235 export HOMEBREW_NO_INSTALL_FROM_API=1
236 brew install my-new-cask
239 Did it install? If something went wrong, edit your cask with `brew edit my-new-cask` to fix it.
241 Test also if the uninstall works successfully:
243 ```bash
244 brew uninstall my-new-cask
247 If everything looks good, you’ll also want to make sure your cask passes audit with:
249 ```bash
250 brew audit --new --cask my-new-cask
253 You should also check stylistic details with `brew style`:
255 ```bash
256 brew style --fix my-new-cask
259 Keep in mind that all these checks will be made when you submit your PR, so by doing them in advance you’re saving everyone a lot of time and trouble.
261 If your application and Homebrew Cask do not work well together, feel free to [file an issue](https://github.com/Homebrew/homebrew-cask#reporting-bugs) after checking out open issues.
263 ### Submitting the cask
265 #### Finding a home for your cask
267 See the [Acceptable Casks documentation](Acceptable-Casks.md#finding-a-home-for-your-cask).
269 Hop into your tap and check to make sure your new cask is there:
271 ```console
272 $ cd "$(brew --repository)"/Library/Taps/homebrew/homebrew-cask
273 $ git status
274 On branch master
275 Untracked files:
276   (use "git add <file>..." to include in what will be committed)
277         Casks/m/my-new-cask.rb
280 So far, so good. Now make a feature branch `my-new-cask-branch` that you’ll use in your pull request:
282 ```console
283 $ git checkout -b my-new-cask-branch
284 Switched to a new branch 'my-new-cask-branch'
287 Stage your cask with:
289 ```bash
290 git add Casks/m/my-new-cask.rb
293 You can view the changes that are to be committed with:
295 ```bash
296 git diff --cached
299 Commit your changes with:
301 ```bash
302 git commit -v
305 #### Commit messages
307 For any Git project, some good rules for commit messages are:
309 * The first line is the commit summary, 50 characters or less,
310 * Followed by an empty line,
311 * Followed by an explanation of the commit, wrapped to 72 characters.
313 See [A Note About Git Commit Messages](https://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html) for more.
315 The first line of a commit message becomes the **title** of a pull request on GitHub, like the subject line of an email. Including the key info in the first line will help us respond faster to your pull request.
317 For cask commits in the Homebrew Cask project, we like to include the application name, version number, and purpose of the commit in the first line.
319 Examples of good, clear commit summaries:
321 * `transmission 1.0 (new cask)`
322 * `transmission 2.82`
323 * `transmission: fix checksum`
324 * `codebox latest (new cask)`
326 Examples of difficult, unclear commit summaries:
328 * `Upgrade to v2.82`
329 * `Checksum was bad`
331 #### Pushing
333 Push your changes on the branch `my-new-cask-branch` to your GitHub account:
335 ```bash
336 git push {{my-github-username}} my-new-cask-branch
339 If you are using [GitHub two-factor authentication](https://docs.github.com/en/authentication/securing-your-account-with-two-factor-authentication-2fa) and have set your remote repository as HTTPS you will need to [set up a personal access token](https://docs.github.com/en/repositories/creating-and-managing-repositories/troubleshooting-cloning-errors#provide-an-access-token) and use that instead of your password.
341 #### Filing a pull request on GitHub
343 ##### a) use suggestion from `git push`
345 The `git push` command prints a suggestion for how to create a pull request:
347     remote: Create a pull request for 'new-cask-cask' on GitHub by visiting:
348     remote:      https://github.com/{{my-github-username}}/homebrew-cask/pull/new/my-new-cask-branch
350 ##### b) use suggestion from GitHub's website
352 Now go to the [`homebrew-cask` GitHub repository](https://github.com/Homebrew/homebrew-cask). GitHub will often show your `my-new-cask-branch` branch with a handy button to `Compare & pull request`.
354 ##### c) manually create a pull request on GitHub
356 Otherwise, click the `Contribute > Open pull request` button and choose to `compare across forks`. The base fork should be `Homebrew/homebrew-cask @ master`, and the head fork should be `my-github-username/homebrew-cask @ my-new-cask-branch`. You can also add any further comments to your pull request at this stage.
358 ##### Congratulations!
360 You are done now, and your cask should be pulled in or otherwise noticed in a while. If a maintainer suggests some changes, just make them on the `my-new-cask-branch` branch locally and [push](#pushing).
362 ### Cleaning up
364 After your pull request is submitted, you should get yourself back onto `master`, so that `brew update` will pull down new casks properly:
366 ```bash
367 cd "$(brew --repository)"/Library/Taps/homebrew/homebrew-cask
368 git checkout master
371 If earlier you set the variable `HOMEBREW_NO_AUTO_UPDATE` and `HOMEBREW_NO_INSTALL_FROM_API` then clean it up with:
373 ```bash
374 unset HOMEBREW_NO_AUTO_UPDATE
375 unset HOMEBREW_NO_INSTALL_FROM_API