Skip to content

Add build clarification to package guide #101

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

Merged
merged 8 commits into from
Nov 1, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Fix: more review edits
  • Loading branch information
lwasser committed Oct 12, 2023
commit b5cb005644222af6c10daf5b65b05ceba6b47574
7 changes: 3 additions & 4 deletions package-structure-code/intro.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,8 @@ src layout, flat layout and where should tests folders live? No matter what your

✨ 2. Learn about building your package ✨
^^^
Building a Python package refers to the process of placing your package code
metadata (and tests) into a specific format that PyPI can read and that
your users can install. Learn more about building a Python package here.
Building a Python package is a great way to share your code with scientists to support open science workflow. The act of "building" refers to the process of placing your package code and
metadata into a format that can be published on PyPI. Once published on PyPI, your users can easily install it locally using pip. Learn more about building a Python package here.
:::

:::{grid-item-card}
Expand Down Expand Up @@ -155,7 +154,7 @@ if you are looking for pyOpenSci's Python package review requirements!
Intro <self>

Python package structure <python-package-structure>
pyproject.toml Package Metadata <pyproject-toml-python-package-metada>
pyproject.toml Package Metadata <pyproject-toml-python-package-metadata>
Build Your Package <python-package-distribution-files-sdist-wheel>
Package Build Tools <python-package-build-tools>
Complex Builds <complex-python-package-builds>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# Learn about Building a Python Package

:::{figure-md} build-workflow
<img src="/images/python-package-development-process.png" alt="Alt tag to be added when image is final" width="700px">
<img src="../images/python-package-development-process.png" alt="Alt tag to be added when image is final" width="700px">

You need to build your Python package in order to publish it to PyPI or Conda. For PyPI, the build process essentially organizes your code and metadata into a distribution format that PyPI can read and provide to potential users.
You need to build your Python package in order to publish it to PyPI (or Conda). The build process organizes your code and metadata into a distribution format that can be uploaded to PyPI and subsequently downloaded and installed by users.
:::

## What is building a Python package?
Expand Down Expand Up @@ -56,7 +56,7 @@ You could in theory create your own scripts to organize your code the way PyPI w
There are a suite of packaging tools that can either help you with
the entire packaging process or just one step of the process. For instance
setuptools is a commonly used build back end that can be used to create your
SDist and wheel. Whereas tools like Hatch, PDM, Poetry and flit help with other
sdist and wheel. Whereas tools like Hatch, PDM, Poetry and flit help with other
parts of the packaging process.

While this can cause some confusion and
Expand All @@ -65,20 +65,20 @@ the same distribution output (with minor differences that most users may not
care about). Learn more about those tools on this page.
```

Below, you will learn about the two distribution files that PyPI expects you to publish: SDist and Wheel. You will learn about
Below, you will learn about the two distribution files that PyPI expects you to publish: sdist and wheel. You will learn about
their structure and what files belong in each.

There are two core distribution files
that you need to create to publish your Python package to
PyPI source distribution (often called an sdist) and wheel. The sdist contains the raw source
code for your package. The Wheel (.whl) contains the built / compiled files
code for your package. The wheel (.whl) contains the built / compiled files
that can be directly installed onto anyones' computer.

Learn more about both distributions below.

```{note}
If your package is a pure python package with no additional
build / compilation steps then the sdist and Wheel distributions will have
build / compilation steps then the sdist and wheel distributions will have
similar content. However if your package has extensions in other languages
or is more complex in its build, the two distributions will be very different.

Expand Down Expand Up @@ -150,13 +150,13 @@ stravalib-1.1.0.post2-SDist.tar.gz file contents

```

```{admonition} GitHub archive vs SDist
```{admonition} GitHub archive vs sdist
:class: tip
When you make a release on GitHub, it creates a `git archive` that contains all
of the files in your GitHub repository. While these files are similar to an
SDist, these two archives are not the same. The SDist contains a few other
sdist, these two archives are not the same. The sdist contains a few other
items including a metadata directory and if you use `setuptools_scm` or `hatch_vcs`
the SDist may also contain a file that stores the version.
the sdist may also contain a file that stores the version.
```

### Wheel (.whl files):
Expand Down