-
Notifications
You must be signed in to change notification settings - Fork 55
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add: packaging tools & layout section to the guide 🎉
(Review 2) Packaging section - part 2 (Reviews Welcome)
- Loading branch information
Showing
14 changed files
with
19,700 additions
and
59 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
name: Book Preview | ||
|
||
on: [status] | ||
|
||
jobs: | ||
circleci_artifacts_redirector_job: | ||
runs-on: ubuntu-latest | ||
if: "${{ github.event.context == 'ci/circleci: build_book' }}" | ||
name: Run CircleCI artifacts redirector | ||
steps: | ||
- name: GitHub Action step | ||
id: step1 | ||
uses: larsoner/circleci-artifacts-redirector-action@master | ||
with: | ||
repo-token: ${{ secrets.GITHUB_TOKEN }} | ||
artifact-path: 0/html/index.html | ||
circleci-jobs: build_book | ||
job-title: Click to preview rendered book |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,3 +5,4 @@ tmp/ | |
.DS_Store | ||
.nox | ||
__pycache__ | ||
*notes-from-review.md |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# Complex Python package builds | ||
|
||
This guide is focused on packages that are either pure-python or that | ||
have a few simple extensions in another language such as C or C++. | ||
|
||
In the future, we want to provide resources for packaging workflows that require more complex builds. If you have questions about these types of package, please [add a question to our discourse](https://pyopensci.discourse.group/) or open an [issue about this guide specifically in the GitHub repo for this guide](https://github.com/pyOpenSci/python-package-guide/issues). There are many nuances to building and distributing Python packages that have compiled extensions requiring non-Python dependencies at build time. For an overview and thorough discussion of these nuances, please see [this site.](https://pypackaging-native.github.io/) | ||
|
||
## Pure Python Packages vs. packages with extensions in other languages | ||
|
||
You can classify Python package complexity into three general categories. These | ||
categories can in turn help you select the correct package front-end and | ||
back-end tools. | ||
|
||
1. **Pure-python packages:** these are packages that only rely on Python to function. Building a pure Python package is simpler. As such, you can chose a tool below that | ||
has the features that you want and be done with your decision! | ||
2. **Python packages with non-Python extensions:** These packages have additional components called extensions written in other languages (such as C or C++). If you have a package with non-python extensions, then you need to select a build back-end tool that allows you to add additional build steps needed to compile your extension code. Further, if you wish to use a front-end tool to support your workflow, you will need to select a tool that | ||
supports additional build setps. In this case, you could use setuptools. However, we suggest that you chose build tool that supports custom build steps such as Hatch with Hatchling or PDM. PDM is an excellent choice as it allows you to also select your build back-end of choice. We will discuss this at a high level on the complex builds page. 3.**Python packages that have extensions written in different languages (e.g. Fortran and C++) or that have non Python dependencies that are difficult to install (e.g. GDAL)** These packages often have complex build steps (more complex than a package with just a few C extensions for instance). As such, these packages require tools such as [scikit-build](https://scikit-build.readthedocs.io/en/latest/) | ||
or [meson-python](https://mesonbuild.com/Python-module.html) to build. NOTE: you can use meson-python with PDM. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
# Python package structure information | ||
|
||
This section provides guidance on your Python package's structure, code formats and style. It also reviews the various packaging tools that you can use to | ||
support building and publishing your package. | ||
|
||
If you are confused by Python packaging, you are not alone! | ||
The good news is there are some great modern packaging | ||
tools that ensure that you're following best practices. Here, we | ||
review tool features and suggest tools that might be best fitted for your workflow. | ||
|
||
```{note} | ||
If you are considering submitting a package for peer review, have a look at the | ||
bare-minimum [editor checks](https://www.pyopensci.org/software-peer-review/how-to/editor-in-chief-guide.html#editor-checklist-template) that pyOpenSci | ||
performs before a review begins. These checks are useful to explore | ||
for both authors planning to submit a package to us for review and for | ||
anyone who is just getting started with creating a Python package. | ||
``` | ||
|
||
## What you will learn here | ||
|
||
In this section of our Python packaging guide, we: | ||
|
||
- Provide an overview of the options available to you when packaging your tool | ||
- Suggest tools and approaches that both meet your needs and also support existing standards. | ||
- Suggest tools and approaches that will allow you to expand upon a workflow that may begin as a pure Python tool and evolve into a tool that requires addition layers of complexity in the packaging build. | ||
- Align our suggestions with the most current, accepted | ||
[PEPs (Python Enhancement Protocols)](https://peps.python.org/pep-0000/) and the [scientific-python community SPECs](https://scientific-python.org/specs/). | ||
- In an effort to maintain consistency within our community, we also align with existing best practices being implemented by developers of core Scientific Python packages such as Numpy, SciPy and others. | ||
|
||
## Guidelines for pyOpenSci's packaging recommendations | ||
|
||
<!-- Might belong on the LANDING page for this entire guide?--> | ||
|
||
The flexibility of the Python programming language lends itself to a diverse | ||
range of tool options for creating a Python package. Python is so flexible that | ||
it is one of the few languages that can be used to wrap around other languages. The ability of Python to wrap other languages one the reasons why you will often hear Python described as a ["glue" language](https://numpy.org/doc/stable/user/c-info.python-as-glue.html)" | ||
|
||
If you are building a pure Python package, then your packaging setup can be | ||
simple. However, some scientific packages have complex requirements as they may | ||
need to support extensions or tools written in other languages such as C or C++. | ||
|
||
To support the many different uses of Python, there are many ways to create a | ||
Python package. In this guide, we suggest approaches for packaging approaches and tools based | ||
upon: | ||
|
||
1. What we think will be best and easiest to adopt for those who are newer to packaging | ||
2. Tools that we think are well maintained and documented. | ||
3. A shared goal of standardizing packaging approaches across this (scientific) Python ecosystem. | ||
|
||
Here, we also try to align our suggestions with the most current, accepted | ||
[Python community](https://packaging.python.org/en/latest/) and [scientific community](https://scientific-python.org/specs/). | ||
|
||
```{admonition} Suggestions in this guide are not pyOpenSci review requirements | ||
:class: important | ||
The suggestions for package layout in this section are made with the | ||
intent of being helpful; they are not specific requirements for your | ||
package to be reviewed and accepted into our pyOpenSci open source ecosystem. | ||
Please check out our [package scope page](https://www.pyopensci.org/software-peer-review/about/package-scope.html) and [review requirements in our author guide](https://www.pyopensci.org/software-peer-review/how-to/author-guide.html#) if you are looking for pyOpenSci's Python package review requirements! | ||
``` | ||
|
||
```{toctree} | ||
:hidden: | ||
:caption: Package structure & code style | ||
Intro <self> | ||
Python package structure <python-package-structure> | ||
pyproject.toml Package Metadata <pyproject-toml-python-package-metadata> | ||
What are SDist & Wheel Files? <python-package-distribution-files-sdist-wheel> | ||
Package Build Tools <python-package-build-tools> | ||
Complex Builds <complex-python-package-builds> | ||
``` |
Oops, something went wrong.