Skip to content

Commit 47ca25a

Browse files
lwasserradoering
andcommitted
Fix: edits to package guide from review
Fix: merge conflict fix Fix: edits to package guide from review rebase 7 Fix: remove chunk of commented text Fix: edits to package guide Fix: edits to package guide Continued edits to pages Update package-structure-code/python-package-build-tools.md Co-authored-by: Randy Döring <[email protected]>
1 parent db390c8 commit 47ca25a

File tree

7 files changed

+827
-252
lines changed

7 files changed

+827
-252
lines changed

conf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@
128128
html_theme = 'pydata_sphinx_theme'
129129
html_static_path = ["_static"]
130130
html_css_files = ["pyos.css"]
131-
html_title = "pyOpenSci Package Guide"
131+
html_title = "pyOpenSci Python Packaging Guide"
132132
html_logo = "images/logo/logo.png"
133133

134134
# Add any paths that contain custom static files (such as style sheets) here,

index.md

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

33

4+
45
```{toctree}
56
:hidden:
67
:caption: Documentation
78
8-
Documentation <documentation/index>
9-
```
9+
Documentation Overview <documentation/index>
1010
11+
```
1112
```{toctree}
1213
:hidden:
1314
:caption: Packaging
1415
15-
Packaging <python-packaging/intro>
16+
Packaging <package-structure-code/intro>
17+
1618
```
1719

1820
```{toctree}
@@ -120,31 +122,6 @@ This guide is now a work in progress. If you have ideas of things you'd like
120122
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).
121123

122124

123-
```{toctree}
124-
:hidden:
125-
:caption: Documentation
126-
127-
Documentation Overview <documentation/index>
128-
129-
```
130-
131-
132-
```{toctree}
133-
:hidden:
134-
:caption: Package structure & code style
135-
136-
Intro <python-packaging/intro>
137-
Intro <package-structure-code/intro>
138-
139-
Python package structure <package-structure-code/python-package-structure>
140-
Package Build Tools <package-structure-code/python-package-build-tools>
141-
Package Versions <package-structure-code/python-package-versions>
142-
package-structure-code/overview
143-
package-structure-code/collaboration
144-
Code Style & Format <package-structure-code/code-structure-style>
145-
```
146-
147-
148125

149126

150127
<!--
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
# Complex Python package builds
2+
3+
4+
* link to ralf's blog and book on complex builds
5+
* keep this page high level so we don't get weight downsides
6+
* can use the examplePy repo stefan and I are working on that will test various build combinations
7+
8+
9+
10+
11+
* pdm, hatch and poetry all have "ways" of supporting c extensions via pdm-build, hatchling and poetry's build back end.
12+
* poetry's support for C extensions is not fully developed and documented (yet). * Poetry doesn't offer a way to facilitate "communication" between poetry front end and another back end like meson to build via a build hook. so while some have used it with other back end builds it's not ideal for this application
13+
* pdm and poetry both rely on setuptools for C extensions. pdm's support claims to be fully developed and documented. poetry claims nothing, and doesn't document it.
14+
* hatch both offers a plugin type approach to support custom build steps
15+
PDM (right now) is the only tool that supports other back ends (hatch is working on this - 2 minor releases away)
16+
At some point a build becomes so complex that you need to use a tool like scikit or meson to support that complexity.
17+
18+
19+
20+
**Setuptools** is the oldest tool in the above list. While it doesn't have a
21+
friendly user front end, because "OG" tool that has been used for Python packaging for over a decade, we discuss it here.
22+
23+
**Hatch** and PDM are newer, more modern tool that support customization of any
24+
part of your packaging steps. These tools also support some C and C++
25+
extensions.
26+
27+
28+
29+
<!-- TODO: add - compatible with other build back ends eg pdm can work with hatchling
30+
31+
Eli:
32+
poetry: supports it, but is undocumented and uses setuptools under the hood, they plan to change how this works and then document it
33+
pdm-backend: supports it, and documents it -- and also uses setuptools under the hood
34+
hatchling: permits you to define hooks for you to write your own custom build steps, including to build C++ extensions
35+
36+
-->
37+
38+
39+
40+
<!-- from eli about pdm
41+
It would be more accurate to say that PDM supports using PDM and setuptools at the same time, so you run setuptools to produce the C extensions and then PDM receives the compiled extension files (.so, .pyd) and packages it up alongside the pure Python files.
42+
43+
Comment about hatch.
44+
https://github.com/pyOpenSci/python-package-guide/pull/23#discussion_r1081108118
45+
46+
From ralf: There are no silver bullets here yet, no workflow tool is complete. Both Hatch and PDM are single-author tools, which is another concern. @eli-schwartz's assessment is unfortunately correct here I believe (at a high level at least, not sure about details). Hatch has the worst take on building compiled code by some distance. Unless its author starts developing an understanding of build systems / needs, and implements support for PEP 517 build backend hooks in pyproject.toml, it's pretty much a dead end.
47+
48+
-->
49+
50+
<!--TODO Add examples of builds using each of the tools below?
51+
52+
pdm, hatch and poetry all have "ways" of supporting c extensions via pdm-build, hatchling and poetry's build back end.
53+
poetry's support for C extensions is not fully developed and documented (yet). Poetry doesn't offer a way to facilitate "communication" between poetry front end and another back end like meson to build via a build hook.
54+
PDM and hatch both offer a plugin type approach to support custom build steps
55+
PDM (right now) is the only tool that supports other back ends (hatch is working on this - 2 minor releases away)
56+
At some point a build becomes so complex that you need to use a tool like scikit or meson to support that complexity.
57+
58+
CORRECTIONS:
59+
pdm doesn't use plugins. Hatch does.
60+
pdm and poetry both rely on setuptools for C extensions. pdm's support claims to be fully developed and documented. poetry claims nothing, and doesn't document it.
61+
62+
-->
63+
64+
```{note}
65+
??
66+
Poetry supports extensions written in other languages but this functionality is
67+
currently undocumented.
68+
69+
Tools such as Setuptools, PDM, Hatch and Poetry all have some level of support
70+
for C and C++ extensions.
71+
Some Python packaging tools,
72+
such as **Flit** and the **flit-core** build back-end only support pure-Python
73+
package builds.
74+
Some front-end packaging tools, such as PDM, allow you to use other
75+
build back-ends such as **meson** and **scikit-build**.
76+
77+
```

package-structure-code/intro.md

Lines changed: 47 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,11 @@ package to be reviewed and accepted into our ecosystem.
2424

2525
In all cases, we try to align our suggestions with the most current, accepted
2626
[PEP's (Python Enhancement Protocols)](https://peps.python.org/pep-0000/) and the [scientific-python community specs](https://scientific-python.org/specs/).
27+
If you plan to submit a package for review to pyOpenSci and are looking for
28+
some guidance on package structure, code formats and style, then this section
29+
is for you.
30+
31+
<!-- TODO: move this either to the top of this section or the landing page?-->
2732

2833
```{note}
2934
Have a look at the
@@ -35,14 +40,38 @@ anyone who is just getting started with creating a Python package.
3540
In general these are basic items that should be in any open software repository.
3641
```
3742

43+
## Guidelines for pyOpenSci's packaging recommendations
3844

39-
<!--
45+
<!-- Might belong on the LANDING page for this entire guide?-->
46+
47+
Python is a flexible programming language that is used across numerous
48+
disciplines and domains. Python is so flexible that it is one of the few
49+
languages that can be used to wrap around other languages.
50+
51+
If you are building a pure Python package, then your packaging setup can be
52+
simple. However, some scientific packages have complex requirements as they may
53+
need to support extensions or tools written in other languages such as C or C++.
54+
55+
To support the many different uses of Python, there are many ways to create a
56+
Python package.
57+
58+
The ecosystem is dynamic, and constantly evolving to support
59+
the numerous needs that developers (and scientists) have using Python.
60+
61+
This dynamic yet flexible environment is what many love about Python.
62+
63+
## What you will learn here
64+
65+
In this section of our Python packaging guide, we try to:
66+
67+
* Provide an overview of the options available to you when packaging your tool
68+
* Suggest tools and approaches that both meet your needs and also support existing standards.
69+
* 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.
70+
* Align our suggestions with the most current, accepted
71+
[PEPs (Python Enhancement Protocols)](https://peps.python.org/pep-0000/) and the [scientific-python community SPECs](https://scientific-python.org/specs/).
72+
* 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.
4073

41-
These checks include several items
4274

43-
- **Sufficient Documentation** The package has sufficient documentation available online (README, sphinx docs) to allow us to evaluate package function and scope *without installing the package*. This includes:
44-
Get started tutorials or vignettes that help a user understand how to use the package and what it can do for them (often these have a name like "Getting started")
45-
- **API documentation** - this includes clearly written doc strings with variables defined using a standard docstring format -->
4675
<!--
4776
```{tip}
4877
### Python packaging resources that we love
@@ -57,3 +86,16 @@ the `src` directory.
5786
* [PyPA packaging guide](https://packaging.python.org/en/latest/)
5887
```
5988
-->
89+
90+
91+
```{toctree}
92+
:hidden:
93+
:caption: Package structure & code style
94+
95+
Intro <self>
96+
97+
Python package structure <python-package-structure>
98+
What are SDIst & Wheel Files? <python-package-distribution-files-sdist-wheel>
99+
Package Build Tools <python-package-build-tools>
100+
Complex Builds <complex-python-package-builds>
101+
```

0 commit comments

Comments
 (0)