You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: package-structure-code/intro.md
+36-22Lines changed: 36 additions & 22 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,29 +1,10 @@
1
1
# Python package structure information
2
2
3
3
If you plan to submit a package for review to pyOpenSci and are looking for
4
-
some guidance on package structure, code formats and style, then this section is for you.
4
+
some guidance on package structure, code formats and style, then this section
5
+
is for you.
5
6
6
-
## Guidelines for pyOpenSci's packaging recommendations
7
-
8
-
<!-- Might belong on the LANDING page for this entire guide?-->
9
-
10
-
There are some differing opinions on what Python package structure should
11
-
look like and what tools to use across the Python ecosystem.
12
-
13
-
In this guide, we have made decisions around suggested standards and required
14
-
standards, based upon the commonly used approaches in the scientific Python
15
-
community. Our goal is to help standardize packaging across this ecosystem.
16
-
17
-
In some cases the suggestions here may diverge from those in the non-scientific parts of the Python ecosystem.
18
-
19
-
```{note}
20
-
The suggestions for package layout in this section are made with the
21
-
intent of being helpful; they are not specific requirements for your
22
-
package to be reviewed and accepted into our ecosystem.
23
-
```
24
-
25
-
In all cases, we try to align our suggestions with the most current, accepted
26
-
[PEP's (Python Enhancement Protocols)](https://peps.python.org/pep-0000/) and the [scientific-python community specs](https://scientific-python.org/specs/).
7
+
<!-- TODO: move this either to the top of this section or the landing page?-->
27
8
28
9
```{note}
29
10
Have a look at the
@@ -35,6 +16,39 @@ anyone who is just getting started with creating a Python package.
35
16
In general these are basic items that should be in any open software repository.
36
17
```
37
18
19
+
## Guidelines for pyOpenSci's packaging recommendations
20
+
21
+
<!-- Might belong on the LANDING page for this entire guide?-->
22
+
23
+
Python is a flexible programming language that is used across numerous
24
+
disciplines and domains. Python is so flexible that it is one of the few
25
+
languages that can be used to wrap around other languages.
26
+
27
+
If you are building a pure Python package, then your packaging setup can be
28
+
simple. However, some scientific packages have complex requirements as they may
29
+
need to support extensions or tools written in other languages such as C or C++.
30
+
31
+
To support the many different uses of Python, there are many ways to create a
32
+
Python package.
33
+
34
+
The ecosystem is dynamic, and constantly evolving to support
35
+
the numerous needs that developers (and scientists) have using Python.
36
+
37
+
This dynamic yet flexible environment is what many love about Python.
38
+
39
+
## What you will learn here
40
+
41
+
In this section of our Python packaging guide, we try to:
42
+
43
+
* Provide an overview of the options available to you when packaging your tool
44
+
* Suggest tools and approaches that both meet your needs and also support existing standards.
45
+
* 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.
46
+
* Align our suggestions with the most current, accepted
47
+
[PEPs (Python Enhancement Protocols)](https://peps.python.org/pep-0000/) and the [scientific-python community SPECs](https://scientific-python.org/specs/).
48
+
* In an effort to maintain consistency withint our community , we also align with existing best practices being implemented by developers of core Scientific Python packages such as numpy, scipy and others.
Other tools such as **Hatch** and **setuptools** support more complex builds
26
-
with custom steps.
34
+
There are, however back-ends such as and **setuptools.build**, **meson.build**
35
+
and **scikit-build** that support complex builds with custom steps. If your
36
+
build is particularly complex (ie you have more than a few `C`/`C++`
37
+
extensions), we suggest you consider using **meson.build** or **scikit-build**.
27
38
28
39
### Build front-ends
29
40
Each tool discussed below has a front-end interface that you can use to perform
30
41
different types of Python packaging tasks.
42
+
31
43
For instance, you can use **Flit**, **Hatch** and **PDM** to both build your
32
44
package and to publish your package to PyPI (or test PyPI). Setuptools,
33
45
on the other hand requires you to use **twine** to push to PyPI.
34
46
35
-
Using a tool like **Flit**, **Hatch** or **PDM** can makes your workflow
36
-
commands (and package requirements) consistent and simple.
47
+
Using a tool like **Flit**, **Hatch** or **PDM** will simplify your workflow.
37
48
38
49
Example to build your package with **Flit**:
39
50
@@ -53,21 +64,16 @@ twine check dist/*
53
64
twine upload -r testpypi dist/*
54
65
```
55
66
56
-
<!-- In the Python package build space **setuptools** is the original tool (i.e.
57
-
the OG) of build tools. With a tool like `setuptools` you have the flexibility
58
-
to publish python pure python packages and packages with custom build steps.
59
-
However, you will also need to use other tools such as **twine** -->
67
+
However each tool has different features and limits on the types of packaging
68
+
steps that it supports.
69
+
Below we describe the broader ecosystem of Python package build tools.
70
+
We also highlight the benefits and potential limitations presented by each tool.
60
71
61
72
## An ecosystem of Python build tools
62
73
63
74
Below we introduce several of the most commonly used Python packaging build
64
75
tools (see chart below).
65
76
66
-
Each tool has different features. There is no right or wrong tool to use as far
67
-
as pyOpenSci is concerned. We are just trying to help you find the tool that
68
-
works best for your workflow.
69
-
70
-
71
77
:::{figure-md} fig-target
72
78
73
79
<imgsrc="../images/python-package-tools-2022-survey-pypa.png"alt="Graph showing the results of the 2022 PyPA survey of Python packaging tools. On the x axis is percent response and on the y axis are the tools."width="700px">
0 commit comments