Skip to content

Commit c30b37a

Browse files
authored
Tidy grammar and language for packaging.md
No major changes. Just some proofreading.
1 parent d2a95a7 commit c30b37a

1 file changed

Lines changed: 74 additions & 75 deletions

File tree

src/tutorial/packaging.md

Lines changed: 74 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -5,35 +5,35 @@ it is time to package and release it!
55

66
There are a few approaches,
77
and we'll look at three of them
8-
from "quickest to set up" to "most convenient for users".
8+
from quickest to set up to most convenient for users.
99

1010
## Quickest: `cargo publish`
1111

1212
The easiest way to publish your app is with cargo.
1313
Do you remember how we added external dependencies to our project?
14-
Cargo downloaded them from its default "crate registry", [crates.io].
14+
Cargo downloaded them from its default crate registry: [crates.io].
1515
With `cargo publish`,
16-
you too can publish crates to [crates.io].
17-
And this works for all crates,
16+
you can publish crates to [crates.io],
17+
and this works for all crates,
1818
including those with binary targets.
1919

20-
Publishing a crate to [crates.io] is pretty straightforward:
21-
If you haven't already, create an account on [crates.io].
22-
Currently, this is done via authorizing you on GitHub,
20+
Publishing a crate to [crates.io] can be done in a few steps.
21+
First, if you haven't already, create an account on [crates.io],
22+
which is done by authorizing you on GitHub,
2323
so you'll need to have a GitHub account
24-
(and be logged in there).
25-
Next, you log in using cargo on your local machine.
24+
and be logged in there.
25+
Second, you log in using cargo on your local machine.
2626
For that, go to your
2727
[crates.io account page],
2828
create a new token,
29-
and then run `cargo login <your-new-token>`.
29+
and run `cargo login <your-new-token>`.
3030
You only need to do this once per computer.
3131
You can learn more about this
3232
in cargo's [publishing guide].
3333

34-
Now that cargo as well as crates.io know you,
34+
Now that cargo and crates.io know you,
3535
you are ready to publish crates.
36-
Before you hastily go ahead and publish a new crate (version),
36+
Before you hastily go ahead and publish a new crate version,
3737
it's a good idea to open your `Cargo.toml` once more
3838
and make sure you added the necessary metadata.
3939
You can find all the possible fields you can set
@@ -59,11 +59,11 @@ categories = ["command-line-utilities"]
5959
**Note:**
6060
This example includes the mandatory license field
6161
with a common choice for Rust projects:
62-
The same license that is also used for the compiler itself.
62+
The same license that is used for the compiler itself.
6363
It also refers to a `README.md` file.
64-
It should include a quick description of what your project is about,
64+
It should include a quick description of what your project is about
6565
and will be included not only on the crates.io page of your crate,
66-
but also what GitHub shows by default on repository pages.
66+
but GitHub shows it by default on repository pages.
6767

6868
</aside>
6969

@@ -78,16 +78,16 @@ We've seen how to publish a crate to crates.io,
7878
and you might be wondering how to install it.
7979
In contrast to libraries,
8080
which cargo will download and compile for you
81-
when you run `cargo build` (or a similar command),
81+
when you run `cargo build` or a similar command,
8282
you'll need to tell it to explicitly install binaries.
8383

8484
This is done using
8585
`cargo install <crate-name>`.
86-
It will by default download the crate,
86+
It will download the crate by default,
8787
compile all the binary targets it contains
8888
(in "release" mode, so it might take a while)
8989
and copy them into the `~/.cargo/bin/` directory.
90-
(Make sure that your shell knows to look there for binaries!)
90+
Make sure that your shell knows to look there for binaries!
9191

9292
It's also possible to
9393
install crates from git repositories,
@@ -98,33 +98,33 @@ Have a look at `cargo install --help` for details.
9898
### When to use it
9999

100100
`cargo install` is a simple way to install a binary crate.
101-
It's very convenient for Rust developers to use,
101+
It's very convenient for Rust developers to use
102102
but has some significant downsides:
103103
Since it will always compile your source from scratch,
104104
users of your tool will need to have
105-
Rust, cargo, and all other system dependencies your project requires
106-
to be installed on their machine.
107-
Compiling large Rust codebases can also take some time.
105+
Rust, cargo, and all other system dependencies that your project requires
106+
installed on their machine.
107+
Compiling large Rust codebases can take some time.
108108

109109
It's best to use this for distributing tools
110110
that are targeted at other Rust developers.
111-
For example:
112-
A lot of cargo subcommands
111+
For example,
112+
a lot of cargo subcommands
113113
like `cargo-tree` or `cargo-outdated`
114114
can be installed with it.
115115

116116
## Distributing binaries
117117

118118
Rust is a language that compiles to native code
119-
and by default statically links all dependencies.
119+
and statically links all dependencies by default.
120120
When you run `cargo build`
121121
on your project that contains a binary called `grrs`,
122122
you'll end up with a binary file called `grrs`.
123-
Try it out:
123+
Try it out!
124124
Using `cargo build`, it'll be `target/debug/grrs`,
125125
and when you run `cargo build --release`, it'll be `target/release/grrs`.
126126
Unless you use crates
127-
that explicitly need external libraries to be installed on the target system
127+
that explicitly need external libraries installed on the target system
128128
(like using the system's version of OpenSSL),
129129
this binary will only depend on common system libraries.
130130
That means,
@@ -138,14 +138,14 @@ There is no need to have Rust installed on the user's machine,
138138
and instead of it taking a minute to compile,
139139
they can instantly run the binary.
140140

141-
So, as we've seen,
141+
As we've seen,
142142
`cargo build` _already_ builds binaries for us.
143-
The only issue is,
143+
The issue is that
144144
those are not guaranteed to work on all platforms.
145145
If you run `cargo build` on your Windows machine,
146146
you won't get a binary that works on a Mac by default.
147147
Is there a way to generate these binaries
148-
for all the interesting platforms
148+
for all of the target platforms
149149
automatically?
150150

151151
### Building binary releases on CI
@@ -154,15 +154,15 @@ If your tool is open sourced
154154
and hosted on GitHub,
155155
it's quite easy to set up a free CI (continuous integration) service
156156
like [Travis CI].
157-
(There are other services that also work on other platforms, but Travis is very popular.)
158-
This basically runs setup commands
157+
There are other services that offer this functionality, but Travis is very popular.
158+
This runs setup commands
159159
in a virtual machine
160160
each time you push changes to your repository.
161161
What those commands are,
162162
and the types of machines they run on,
163163
is configurable.
164-
For example:
165-
A good idea is to run `cargo test`
164+
For example,
165+
a good idea is to run `cargo test`
166166
on a machine with Rust and some common build tools installed.
167167
If this fails,
168168
you know there are issues in the most recent changes.
@@ -171,39 +171,39 @@ you know there are issues in the most recent changes.
171171

172172
We can also use this
173173
to build binaries and upload them to GitHub!
174-
Indeed, if we run
174+
If we run
175175
`cargo build --release`
176176
and upload the binary somewhere,
177177
we should be all set, right?
178178
Not quite.
179179
We still need to make sure the binaries we build
180180
are compatible with as many systems as possible.
181181
For example,
182-
on Linux we can compile not for the current system,
183-
but instead for the `x86_64-unknown-linux-musl` target,
184-
to not depend on default system libraries.
182+
on Linux we can compile for the current system
183+
or the `x86_64-unknown-linux-musl` target and
184+
not depend on default system libraries.
185185
On macOS, we can set `MACOSX_DEPLOYMENT_TARGET` to `10.7`
186186
to only depend on system features present in versions 10.7 and older.
187187

188188
You can see one example of building binaries using this approach
189189
[here][wasm-pack-travis] for Linux and macOS
190-
and [here][wasm-pack-appveyor] for Windows (using AppVeyor).
190+
and [here][wasm-pack-appveyor] for Windows using AppVeyor.
191191

192192
[wasm-pack-travis]: https://github.com/rustwasm/wasm-pack/blob/51e6351c28fbd40745719e6d4a7bf26dadd30c85/.travis.yml#L74-L91
193193
[wasm-pack-appveyor]: https://github.com/rustwasm/wasm-pack/blob/51e6351c28fbd40745719e6d4a7bf26dadd30c85/.appveyor.yml
194194

195-
Another way is to use pre-built (Docker) images
195+
Another way is to use pre-built (i.e. Docker) images
196196
that contain all the tools we need
197197
to build binaries.
198-
This allows us to easily target more exotic platforms, too.
198+
This allows us to easily target more exotic platforms as well.
199199
The [trust] project contains
200200
scripts that you can include in your project
201-
as well as instructions on how to set this up.
201+
and instructions on how to set this up.
202202
It also includes support for Windows using AppVeyor.
203203

204204
If you'd rather set this up locally
205205
and generate the release files on your own machine,
206-
still have a look at trust.
206+
have a look at [trust].
207207
It uses [cross] internally,
208208
which works similar to cargo
209209
but forwards commands to a cargo process inside a Docker container.
@@ -218,23 +218,23 @@ The definitions of the images are also available in
218218
You point your users to your release page
219219
that might look something [like this one][wasm-pack-release],
220220
and they can download the artifacts we've just created.
221-
The release artifacts we've just generated are nothing special:
222-
At the end, they are just archive files that contain our binaries!
221+
The release artifacts we've generated are nothing special.
222+
They are just archive files that contain our binaries!
223223
This means that users of your tool
224224
can download them with their browser,
225-
extract them (often happens automatically),
225+
extract them (often automatically),
226226
and copy the binaries to a place they like.
227227

228228
[wasm-pack-release]: https://github.com/rustwasm/wasm-pack/releases/tag/v0.5.1
229229

230-
This does require some experience with manually "installing" programs,
230+
This does require some experience with manually installing programs,
231231
so you want to add a section to your README file
232232
on how to install this program.
233233

234234
<aside class="note">
235235

236236
**Note:**
237-
If you used [trust] to build your binaries and added them to GitHub releases,
237+
If you use [trust] to build your binaries and add them to GitHub releases,
238238
you can also tell people to run
239239
`curl -LSfs https://japaric.github.io/trust/install.sh | sh -s -- --git your-name/repo-name`
240240
if you think that makes it easier.
@@ -243,12 +243,12 @@ if you think that makes it easier.
243243

244244
### When to use it
245245

246-
Having binary releases is a good idea in general,
247-
there's hardly any downside to it.
246+
Having binary releases is a good idea in general.
247+
There's hardly any downside to it.
248248
It does not solve the problem of users having to manually
249249
install and update
250250
your tools,
251-
but they can quickly get the latest releases version
251+
but they can quickly get the latest release's version
252252
without the need to install Rust.
253253

254254
### What to package in addition to your binaries
@@ -257,20 +257,19 @@ Right now,
257257
when a user downloads our release builds,
258258
they will get a `.tar.gz` file
259259
that only contains binary files.
260-
So, in our example project,
261-
they will just get a single `grrs` file they can run.
262-
But there are some more files we already have in our repository
260+
In our example project,
261+
they will just get a single `grrs` file they can run,
262+
but there are more files we already have in our repository
263263
that they might want to have.
264-
The README file that tells them how to use this tool,
264+
The README file that tells them how to use this tool
265265
and the license file(s),
266266
for example.
267267
Since we already have them,
268268
they are easy to add.
269269

270-
There are some more interesting files
271-
that make sense especially for command-line tools,
272-
though:
273-
How about we also ship a man page in addition to that README file,
270+
There are more interesting files
271+
that make sense, especially for command-line tools.
272+
How about we ship a man page in addition to that README file
274273
and config files that add completions of the possible flags to your shell?
275274
You can write these by hand,
276275
but _clap_, the argument parsing library we use
@@ -286,13 +285,13 @@ for more details.
286285
## Getting your app into package repositories
287286

288287
Both approaches we've seen so far
289-
are not how you typically install software on your machine.
290-
Especially command-line tools
288+
are not how you typically install software on your machine,
289+
especially for command-line tools that
291290
you install using global package managers
292291
on most operating systems.
293292
The advantages for users are quite obvious:
294-
There is no need to think about how to install your program,
295-
if it can be installed the same way as they install the other tools.
293+
There is no need to think about how to install your program
294+
if it can be installed the same way as they install other tools.
296295
These package managers also allow users to update their programs
297296
when a new version is available.
298297

@@ -301,7 +300,7 @@ you'll have to look at how these different systems work.
301300
For some,
302301
it might be as easy as adding a file to your repository
303302
(e.g. adding a Formula file like [this][rg-formula] for macOS's `brew`),
304-
but for others you'll often need to send in patches yourself
303+
but for others, you'll often need to send in patches yourself
305304
and add your tool to their repositories.
306305
There are helpful tools like
307306
[cargo-bundle](https://crates.io/crates/cargo-bundle),
@@ -323,17 +322,17 @@ and that is available in many different package managers.
323322
It's quite successful and is packaged for many operating systems:
324323
Just look at [the "Installation" section][rg-install] of its README!
325324

326-
Note that it lists a few different options how you can install it:
327-
It starts with a link to the GitHub releases
328-
which contain the binaries so you can download them directly;
329-
then it lists how to install it using a bunch of different package managers;
330-
finally, you can also install it using `cargo install`.
331-
332-
This seems like a very good idea:
333-
Don't pick and choose one of the approaches presented here,
334-
but start with `cargo install`,
335-
add binary releases,
336-
and finally start distributing your tool using system package managers.
325+
Note that it lists a few different options on how you can install it:
326+
It starts with a link to the GitHub releases,
327+
which contain the binaries so that you can download them directly,
328+
it lists how to install it using a bunch of different package managers,
329+
and you can also install it using `cargo install`.
330+
331+
This seems like a very good idea.
332+
Don't pick and choose one of the approaches presented here.
333+
Start with `cargo install`
334+
and add binary releases
335+
before finally distributing your tool using system package managers.
337336

338337
[ripgrep]: https://github.com/BurntSushi/ripgrep
339338
[rg-install]: https://github.com/BurntSushi/ripgrep/tree/31adff6f3c4bfefc9e77df40871f2989443e6827#installation

0 commit comments

Comments
 (0)