Skip to content

Commit a6bb0d3

Browse files
authored
Add: packaging tools & layout section to the guide 🎉
(Review 2) Packaging section - part 2 (Reviews Welcome)
2 parents 26f5aa8 + 6d1cd13 commit a6bb0d3

14 files changed

+19700
-59
lines changed
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
name: Book Preview
2+
3+
on: [status]
4+
5+
jobs:
6+
circleci_artifacts_redirector_job:
7+
runs-on: ubuntu-latest
8+
if: "${{ github.event.context == 'ci/circleci: build_book' }}"
9+
name: Run CircleCI artifacts redirector
10+
steps:
11+
- name: GitHub Action step
12+
id: step1
13+
uses: larsoner/circleci-artifacts-redirector-action@master
14+
with:
15+
repo-token: ${{ secrets.GITHUB_TOKEN }}
16+
artifact-path: 0/html/index.html
17+
circleci-jobs: build_book
18+
job-title: Click to preview rendered book

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,4 @@ tmp/
55
.DS_Store
66
.nox
77
__pycache__
8+
*notes-from-review.md

conf.py

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,12 @@
1717

1818
# -- Project information -----------------------------------------------------
1919

20-
project = 'python-package-guide'
21-
copyright = '2023, pyOpenSci'
22-
author = 'pyOpenSci Community'
20+
project = "python-package-guide"
21+
copyright = "2023, pyOpenSci"
22+
author = "pyOpenSci Community"
2323

2424
# The full version, including alpha/beta/rc tags
25-
release = '0.1'
25+
release = "0.1"
2626

2727
# -- General configuration ---------------------------------------------------
2828

@@ -47,7 +47,7 @@
4747
myst_heading_anchors = 3
4848

4949
# For generating sitemap
50-
html_baseurl = 'https://www.pyopensci.org/software-peer-review/'
50+
html_baseurl = "https://www.pyopensci.org/software-peer-review/"
5151

5252
# Link to our repo for easy PR/ editing
5353
html_theme_options = {
@@ -81,7 +81,7 @@
8181
"header_links_before_dropdown": 4,
8282
"use_edit_page_button": True,
8383
"show_toc_level": 1,
84-
#"navbar_align": "left", # [left, content, right] For testing that the navbar items align properly
84+
# "navbar_align": "left", # [left, content, right] For testing that the navbar items align properly
8585
"github_url": "https://github.com/pyopensci/python-package-guide",
8686
"twitter_url": "https://twitter.com/pyopensci",
8787
"footer_items": ["copyright"],
@@ -99,11 +99,11 @@
9999

100100
# Add analytics to furo theme
101101
gtagjs_ids = [
102-
'UA-141260825-1',
102+
"UA-141260825-1",
103103
]
104104

105105
# Add any paths that contain templates here, relative to this directory.
106-
templates_path = ['_templates']
106+
templates_path = ["_templates"]
107107

108108
# List of patterns, relative to source directory, that match files and
109109
# directories to ignore when looking for source files.
@@ -114,20 +114,20 @@
114114
".DS_Store",
115115
".github",
116116
".nox",
117-
"README.md"
118-
]
117+
"README.md",
118+
]
119119

120120
# For sitemap
121-
html_baseurl = 'https://www.pyopensci.org/package-review-guide/'
121+
html_baseurl = "https://www.pyopensci.org/package-review-guide/"
122122

123123
# -- Options for HTML output -------------------------------------------------
124124

125125
# The theme to use for HTML and HTML Help pages. See the documentation for
126126
# a list of builtin themes.
127127
#
128-
html_theme = 'pydata_sphinx_theme'
128+
html_theme = "pydata_sphinx_theme"
129129
html_static_path = ["_static"]
130130
html_css_files = ["pyos.css"]
131+
html_title = "pyOpenSci Python Packaging Guide"
131132
html_js_files = ["matomo.js"]
132-
html_title = "pyOpenSci Package Guide"
133133
html_logo = "images/logo/logo.png"
18.2 KB
Loading
302 KB
Loading

images/python-package-tools-decision-tree.svg

Lines changed: 18546 additions & 0 deletions
Loading

index.md

Lines changed: 20 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,19 @@
11
# pyOpenSci Python Open Source Package Development Guide
22

3-
43
```{toctree}
54
:hidden:
65
:caption: Documentation
76
87
Documentation <documentation/index>
8+
99
```
1010

1111
```{toctree}
1212
:hidden:
1313
:caption: Packaging
1414
15-
Packaging <python-packaging/intro>
15+
Packaging <package-structure-code/intro>
16+
1617
```
1718

1819
```{toctree}
@@ -28,7 +29,8 @@ https://github.com/pyOpenSci/python-package-guide/community -->
2829
## Welcome, Python open source enthusiast!
2930

3031
Here you will find guidelines for what we look for in your scientific
31-
Python package when reviewing. You will also find best practice recommendations and curated lists of community resources surrounding packaging and documentation.
32+
Python package when reviewing. You will also find best practice recommendations and curated lists of community resources surrounding packaging and documentation. Our goal is to help the
33+
community make decisions around how to create scientific Python packages. We are working towards a shared vision of packaging that helps users better understand where to start.
3234

3335
::::{grid} 2
3436
:reverse:
@@ -43,7 +45,6 @@ Python package when reviewing. You will also find best practice recommendations
4345
:columns: 8
4446
:class: sd-fs-3
4547

46-
4748
```{button-link} https://www.pyopensci.org/about-peer-review/
4849
:color: primary
4950
:class: sd-rounded-pill float-left
@@ -59,7 +60,6 @@ Learn about our open peer review process
5960
:::
6061
::::
6162

62-
6363
<!-- I think this is the end of the header - below begins the next grid-->
6464

6565
::::{grid} 1 1 2 2
@@ -80,6 +80,15 @@ documentation that are
8080
commonly used in the scientific Python community.
8181
:::
8282

83+
:::{grid-item-card}
84+
:link: package-structure-code/intro
85+
:link-type: doc
86+
:class-header: bg-light
87+
88+
✨ Python packaging tools & structure ✨
89+
^^^
90+
All of the modern tools discussed in this guide will help you build an efficient packaging workflow. This section helps you select the tool that will work best for you.
91+
:::
8392

8493
:::{grid-item-card}
8594
:link: CONTRIBUTING
@@ -94,21 +103,22 @@ contribute.
94103
::::
95104

96105
## Who this guidebook is for
106+
97107
We assume that you are here because you are:
98108

109+
1. Looking for guidance on creating a Python package.
110+
1. Looking for resources associated with Python packaging.
99111
1. Considering submitting a package to pyOpenSci and want to understand what we are looking for when we review your package
100-
2. Looking for guidance on creating a Python package.
101-
3. Looking for resources associated with Python packaging.
102112

103113
Well, friend, you've come to the right place!
104114

105115
## What you will find in this guidebook
106116

107117
This guidebook contains:
108118

109-
* Explanation for "Good enough" minimum requirements associated with being reviewed by pyOpenSci
110-
* Explanation of better and best practices in case you want to set the bar higher for your package (which we hope you will)!
111-
* A curated list of resources to help you get your package into documented, usable and tested shape.
119+
- Explanation for "Good enough" minimum requirements associated with being reviewed by pyOpenSci
120+
- Explanation of better and best practices in case you want to set the bar higher for your package (which we hope you will)!
121+
- A curated list of resources to help you get your package into documented, usable and tested shape.
112122

113123
## Where this guide is headed
114124

@@ -118,38 +128,3 @@ Good meets the requirements. Going beyond the minimum can make package maintenan
118128

119129
This guide is now a work in progress. If you have ideas of things you'd like
120130
to see here, [we invite you to open an issue on GitHub that details any changes or additions that you'd like to see.](https://github.com/pyOpenSci/python-package-guide/issues).
121-
122-
123-
124-
125-
<!--
126-
COMMENTED OUT TEXT TO BE MOVED
127-
128-
129-
# TODO LINK TO CI BUILDS FOR Documentation>
130-
Maybe we can curate a list of CI builds that people can use??? or is that moving too close to a cookie cutter situation
131-
132-
The text below is being moved to the packaging infrastructure section which
133-
doesn't exist YET... but will soon .
134-
pyOpenSci packages must:
135-
136-
- Contain full documentation for any user-facing functions.
137-
- Have a test suite that covers the major functionality of the package.
138-
- Use continuous integration.
139-
- Use an OSI approved software license.
140-
141-
142-
## Other recommendations
143-
### Python version support
144-
You should always be explicit about which versions of Python your package supports.
145-
Keeping compatibility with old Python versions can be difficult as functionality changes.
146-
A good rule of thumb is that the package should support, at least,
147-
the latest three Python versions (e.g., 3.8, 3.7, 3.6).
148-
149-
### Code Style
150-
pyOpenSci encourages authors to consult [PEP 8](https://www.python.org/dev/peps/pep-0008/) for information on how to style your code.
151-
152-
### Linting
153-
An automatic linter (e.g. flake8) can help ensure your code is clean and free of syntax errors. These can be integrated with your CI.
154-
155-
-->
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Complex Python package builds
2+
3+
This guide is focused on packages that are either pure-python or that
4+
have a few simple extensions in another language such as C or C++.
5+
6+
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/)
7+
8+
## Pure Python Packages vs. packages with extensions in other languages
9+
10+
You can classify Python package complexity into three general categories. These
11+
categories can in turn help you select the correct package front-end and
12+
back-end tools.
13+
14+
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
15+
has the features that you want and be done with your decision!
16+
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
17+
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/)
18+
or [meson-python](https://mesonbuild.com/Python-module.html) to build. NOTE: you can use meson-python with PDM.

package-structure-code/intro.md

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
# Python package structure information
2+
3+
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
4+
support building and publishing your package.
5+
6+
If you are confused by Python packaging, you are not alone!
7+
The good news is there are some great modern packaging
8+
tools that ensure that you're following best practices. Here, we
9+
review tool features and suggest tools that might be best fitted for your workflow.
10+
11+
```{note}
12+
If you are considering submitting a package for peer review, have a look at the
13+
bare-minimum [editor checks](https://www.pyopensci.org/software-peer-review/how-to/editor-in-chief-guide.html#editor-checklist-template) that pyOpenSci
14+
performs before a review begins. These checks are useful to explore
15+
for both authors planning to submit a package to us for review and for
16+
anyone who is just getting started with creating a Python package.
17+
18+
```
19+
20+
## What you will learn here
21+
22+
In this section of our Python packaging guide, we:
23+
24+
- Provide an overview of the options available to you when packaging your tool
25+
- Suggest tools and approaches that both meet your needs and also support existing standards.
26+
- 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.
27+
- Align our suggestions with the most current, accepted
28+
[PEPs (Python Enhancement Protocols)](https://peps.python.org/pep-0000/) and the [scientific-python community SPECs](https://scientific-python.org/specs/).
29+
- 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.
30+
31+
## Guidelines for pyOpenSci's packaging recommendations
32+
33+
<!-- Might belong on the LANDING page for this entire guide?-->
34+
35+
The flexibility of the Python programming language lends itself to a diverse
36+
range of tool options for creating a Python package. Python is so flexible that
37+
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)"
38+
39+
If you are building a pure Python package, then your packaging setup can be
40+
simple. However, some scientific packages have complex requirements as they may
41+
need to support extensions or tools written in other languages such as C or C++.
42+
43+
To support the many different uses of Python, there are many ways to create a
44+
Python package. In this guide, we suggest approaches for packaging approaches and tools based
45+
upon:
46+
47+
1. What we think will be best and easiest to adopt for those who are newer to packaging
48+
2. Tools that we think are well maintained and documented.
49+
3. A shared goal of standardizing packaging approaches across this (scientific) Python ecosystem.
50+
51+
Here, we also try to align our suggestions with the most current, accepted
52+
[Python community](https://packaging.python.org/en/latest/) and [scientific community](https://scientific-python.org/specs/).
53+
54+
```{admonition} Suggestions in this guide are not pyOpenSci review requirements
55+
:class: important
56+
57+
The suggestions for package layout in this section are made with the
58+
intent of being helpful; they are not specific requirements for your
59+
package to be reviewed and accepted into our pyOpenSci open source ecosystem.
60+
61+
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!
62+
```
63+
64+
```{toctree}
65+
:hidden:
66+
:caption: Package structure & code style
67+
68+
Intro <self>
69+
70+
Python package structure <python-package-structure>
71+
pyproject.toml Package Metadata <pyproject-toml-python-package-metadata>
72+
What are SDist & Wheel Files? <python-package-distribution-files-sdist-wheel>
73+
Package Build Tools <python-package-build-tools>
74+
Complex Builds <complex-python-package-builds>
75+
```

0 commit comments

Comments
 (0)