Skip to content

Commit

Permalink
Final edits to intro page
Browse files Browse the repository at this point in the history
  • Loading branch information
lwasser committed Dec 6, 2023
1 parent d3cff0b commit 6011ff6
Show file tree
Hide file tree
Showing 7 changed files with 138 additions and 74 deletions.
9 changes: 8 additions & 1 deletion _static/pyos.css
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ html, body {
}
}

/* Make sure the header nav is centered - not sure why it's not overriding*/
/* Make sure the header nav is centered */
.navbar-header-items .me-auto, .me-auto .navbar-header-items__center {
margin-left: auto!important;
margin-right: auto!important;
Expand All @@ -35,6 +35,13 @@ html, body {
margin-right: auto!important;
}

/* custom fonts */

html, body {
font-size: 1.02rem;
font-family: 'Poppins', sans-serif!important;
}

body p {
}

Expand Down
1 change: 1 addition & 0 deletions _templates/header.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<!-- custom head content-->

<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Itim&family=Poppins:wght@300;400;600&display=swap" rel="stylesheet">
Expand Down
1 change: 1 addition & 0 deletions _templates/nav.html
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<p>this is a test does it work?</p>
Binary file removed images/environment-package-install.png
Binary file not shown.
Binary file added images/tutorials/packaging-lifecycle.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
75 changes: 39 additions & 36 deletions tutorials/6-publish-pypi.md
Original file line number Diff line number Diff line change
@@ -1,35 +1,36 @@
# Publish your Python package to PyPI

<!-- TODOs:
In the previous lessons, you've learned the following:
* mention twine keyring - - https://twine.readthedocs.io/en/stable/#keyring-support
* emphasize that we recommended the trusted publisher github action for most maintainers
1. How to structure your code into a package like format that can be installed into a Python environment.
2. How to add a `README` and `LICENSE` file to your package
3. How to setup your `pyproject.toml` file with all of the metadata that PyPI requires and also metadata that will be helpful for users to find your package.
TODO: Go back to pyproj toml lesson and add a dev dependencies section with build and twine so they can just pip install -e .[dev] into their environment and be done
If you have gone through all of the above lessons, you are now ready to
build your package's distribution files which are needed for you to publish
to PyPI. Here, you will learn:
`pip install build`
-->

* How to set up your account and package on PyPI and
* How to manually publish to (test) PyPI using [twine](https://twine.readthedocs.io/en/stable/).

In a followup lesson, you will learn how to automate publishing to PyPI using GitHub actions.
In the previous lessons, you've learned:

1. How to make your code pip installable.
2. How to add a `README`, `LICENSE` & `CODE of CONDUCT` file file to your package
3. How to setup your `pyproject.toml` file to support publishing on PyPI.

:::{admonition} Learning Objectives
:class: tip

In this lesson you will learn how to:

- How to build your package's sdist and wheel distributions
- How to build your package's source (sdist) and wheel distributions
- Setup an account on testPyPI (the process is similar for the real PyPI)
- Publish your package to testPyPI
- Publish your package to testPyPI using [twine](https://twine.readthedocs.io/en/stable/)

Once your package is on PyPI you can then easily publish it to conda-forge
using the [grayskull](https://conda.github.io/grayskull/) tool. You do not need to build the package specifically
for conda, conda-forge will build from your PyPI source distribution file (sdist). You will learn how to publish to conda-forge in the [next lesson](7-publish-conda-forge.md).

In a followup lesson, you will learn how to automate publishing to PyPI using GitHub actions.
:::

:::{figure-md} build-workflow-tutorial
Expand All @@ -41,9 +42,7 @@ You need to build your Python package in order to publish it to PyPI (or Conda).
<!-- Pypa resource: https://packaging.python.org/en/latest/tutorials/packaging-projects/#uploading-the-distribution-archives
https://spdx.org/licenses/PSF-2.0.html (double check that we can use language from pypa tutorial??
https://packaging.python.org/en/latest/guides/using-testpypi/
-->

## Test PyPI.org vs PyPI
Expand All @@ -57,7 +56,7 @@ The steps for publishing on test PyPI vs. real PyPI are the same with the
exception of a different url. Thus, in this lesson you will use testPyPI
to practice and learn.

<!-- in xx lesson, you will learn how to setup an automated release workflow on GitHub
<!-- Add when this lesson is created - in xx lesson, you will learn how to setup an automated release workflow on GitHub
using GitHub actions that will automate the PyPI publication process whenever
you create a new software release. -->

Expand Down Expand Up @@ -125,8 +124,7 @@ files. This process is known as building your package.



<!-- ?? TODO: Go back to pyproj lesson and add a dev dependencies with build and twine?
`pip install build` -->


3. You are now ready to build your package! Note that here you are using the [PyPA build tool](https://github.com/pypa/build) as a "Front end" tool that builds
your package's sdist and wheel using the hatchling build back end. Remember that you defined your build backend here in the build system table of your `pyproject.toml` file. So build knows to use [hatchling](https://hatch.pypa.io/latest/).
Expand Down Expand Up @@ -175,7 +173,7 @@ lesson.
You've now created your package distribution. You're officially on
your way to publishing your package on PyPI.

## 2. Setup your testPyPI account
## Step 2. Setup your testPyPI account

Next, you'll setup an account on `testPyPI`. Remember that you
are using testPyPI here instead of the real PyPI as a way to
Expand Down Expand Up @@ -212,7 +210,7 @@ While you don't have to setup 2-factor authentication, we strongly
suggest that you do so.
:::

## 3. Create a package upload token
## Step 3. Create a package upload token

To upload your package to PyPI, you will need to create a token. Ideally
this token is specific to the package that you are publishing.
Expand Down Expand Up @@ -269,6 +267,7 @@ NOTE: the `.pypirc` file stores your token in plain text format. Thus, in anothe
:::


:::{admonition} using a .pypirc file if your always publishing manually
### Create your `.pypirc` file with authentication information

To create your `.pypirc` file, do the following.
Expand Down Expand Up @@ -297,6 +296,8 @@ Save the file and then check that it looks correct in bash using the `cat` comma
$ cat ~/.pypirc
```

:::

Now, install twine:

::::{tab-set}
Expand Down Expand Up @@ -436,6 +437,23 @@ you wish to install your newly published package in.
::::


:::{admonition} The value of end-to-end tools like hatch, flit and poetry
In this lesson we are using core tools including:

* hatchling
* PyPA's build
* twine

to build and publish your package to PyPI.

End-to-end packaging tools such as Hatch, PDM, Poetry and
Flit can manage all of the above steps but have to be
configured.

For example, while twine users a `.pypirc` file, Hatch will cache your PyPI token information to make publishing to PyPI from your computer easier. Be sure the read the documentation for any end-to-end publication tool that you chose to use.
:::


<!-- TODO: venv will always be different for windows - do we need a third tab?? Also is conda different on windows? i forget -->

<!--TODO: teach them to setup trusted publisher for actions... in the actions lesson
Expand All @@ -455,7 +473,8 @@ related to PyPI publication.
You will learn how to create the automated trusted publisher workflow in a followup lesson.


### If you want to use a manual token-based publication workflow
### OPTIONAL: If you want to use a manual token-based publication workflow

If you plan to use your token regularly to publish to PyPI, we strongly recommend going through the above steps again to create
a token specific to your new package.

Expand All @@ -470,22 +489,6 @@ To do this:

And you're all done!

:::{admonition} The value of end-to-end tools like hatch, flit and poetry
In this lesson we are using core tools including:

* hatchling
* PyPA's build
* twine

to build and publish your package to PyPI.

End-to-end packaging tools such as Hatch, PDM, Poetry and
Flit can manage all of the above steps but have to be
configured.

For example, while twine users a `.pypirc` file, Hatch will cache your PyPI token information to make publishing to PyPI from your computer easier. Be sure the read the documentation for any end-to-end publication tool that you chose to use.
:::

## You have published your package to (test) PyPI!

Congratulations. You have now successfully published your package to testPyPI. If you have a package that is ready for real-world use on the real pyPi, then you can follow the same steps to publish it on PyPI.org .
Expand Down
Loading

0 comments on commit 6011ff6

Please sign in to comment.