Skip to content

Commit 9751371

Browse files
ucoderylwasser
authored andcommitted
some packaging improvements
1 parent 34d85c7 commit 9751371

File tree

5 files changed

+28
-19
lines changed

5 files changed

+28
-19
lines changed

package-structure-code/intro.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,7 @@ simple. However, some scientific packages have complex requirements as they may
5858
need to support extensions or tools written in other languages such as C or C++.
5959

6060
To support the many different uses of Python, there are many ways to create a
61-
Python package. In this guide, we suggest approaches for packaging approaches
62-
and tools based on:
61+
Python package. In this guide, we suggest packaging approaches and tools based on:
6362

6463
1. What we think will be best and easiest to adopt for those who are newer to
6564
packaging.

package-structure-code/pyproject-toml-python-package-metadata.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,14 +77,14 @@ In this example package setup you use:
7777
- **setuptools_scm** to manage package version updates using version control tags
7878

7979
In the example below `[build-system]` is the first table
80-
of values. It has two keys that specify the build frontend and backend for a package:
80+
of values. It has two keys that specify the build backend API and containing package:
8181

8282
1. `requires =`
8383
1. `build-back-end =`
8484

8585
```
8686
[build-system]
87-
requires = ["setuptools>=45"]
87+
requires = ["setuptools>=61"]
8888
build-backend = "setuptools.build_meta"
8989
9090
[project]

package-structure-code/python-package-build-tools.md

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ to a package build that does not have extensions that are written in another
6868
programming language (such as `C` or `C++`).
6969

7070
Other packages that have C and C++ extensions (or that wrap other languages such as fortran) require additional code compilation steps when built.
71-
Back-ends such as and **setuptools.build**, **meson.build**
71+
Back-ends such as **setuptools.build**, **meson.build**
7272
and **scikit-build** support complex builds with custom steps. If your
7373
build is particularly complex (i.e. you have more than a few `C`/`C++`
7474
extensions), then we suggest you use **meson.build** or **scikit-build**.
@@ -78,7 +78,7 @@ extensions), then we suggest you use **meson.build** or **scikit-build**.
7878
A packaging front-end tool refers to a tool that makes it easier for you to
7979
perform common packaging tasks using similar commands. These tasks include:
8080

81-
- [Build your packages (create the sdist and wheel distributions](python-package-distribution-files-sdist-wheel)
81+
- [Build your packages (create the sdist and wheel distributions)](python-package-distribution-files-sdist-wheel)
8282
- Installing your package in a development mode (so it updates when you update your code)
8383
- Publishing to PyPI
8484
- Running tests
@@ -260,6 +260,14 @@ Build your sdist and wheel distributions|✅| Similar to all of the other tools
260260
✨Optional use of PEP 582 / local environment directory✨|✅| PDM is currently the only tool that optionally supports PEP 582 (having a local environment configuration stored within a `__pypackages__` directory in your working directory).
261261
```
262262

263+
```{admonition} PEP 582 was rejected
264+
:class: important
265+
266+
While [PEP 582](https://peps.python.org/pep-0582), use of local packages directory `__pypackages__`,
267+
sought to implement a more lightweight form of Python environment management it currently stands
268+
as a rejected standard in the broader Python community.
269+
```
270+
263271
```{admonition} PDM vs. Poetry
264272
The functionality of PDM is similar to Poetry. However, PDM also offers
265273
additional, documented support for C extensions and version control based
@@ -349,7 +357,7 @@ Publish to PyPI and test PyPI|✅|Hatch supports publishing to both test PyPI an
349357
Version Control based versioning|✅ | Hatch offers `hatch_vcs` which is a plugin that uses setuptools_scm to support versioning using git tags. The workflow with `hatch_vcs` is the same as that with `setuptools_scm`.
350358
Version bumping| ✅ | Hatch supports you bumping the version of your package using standard semantic version terms patch; minor; major
351359
Follows current packaging standards|✅|Hatch supports current packaging standards for adding metadata to the **pyproject.toml** file.
352-
Install your package in editable mode|✖✅| You can install your package in editable mode using `pip install -e .` Hatch mentions [editable installs](https://hatch.pypa.io/latest/config/build/#dev-mode) but refers to pip in its documentation.
360+
Install your package in editable mode|✔️| You can install your package in editable mode using `pip install -e .` Hatch mentions [editable installs](https://hatch.pypa.io/latest/config/build/#dev-mode) but refers to pip in its documentation.
353361
Build your sdist and wheel distributions|✅| Hatch will build the sdist and wheel distributions
354362
✨Matrix environment creation to support testing across Python versions✨|✅| The matrix environment creation is a feature that is unique to Hatch in the packaging ecosystem. This feature is useful if you wish to test your package locally across Python versions (instead of using a tool such as tox).
355363
✨[Nox / MAKEFILE like functionality](https://hatch.pypa.io/latest/environment/#selection)✨| ✅| This feature is also unique to Hatch. This functionality allows you to create workflows in the **pyproject.toml** configuration to do things like serve docs locally and clean your package build directory. This means you may have one less tool in your build workflow.
@@ -395,7 +403,7 @@ Lock files| ✅ | Poetry creates a **poetry.lock** file that you can use if you
395403
Publish to PyPI and test PyPI|✅|Poetry supports publishing to both test PyPI and PyPI
396404
Version Control based versioning|✅ | The plugin [Poetry dynamic versioning](https://github.com/mtkennerly/poetry-dynamic-versioning) supports versioning using git tags with Poetry.
397405
Version bumping| ✅ | Poetry supports you bumping the version of your package using standard semantic version terms patch; minor; major
398-
Follows current packaging standards|✖✅|Poetry does not quite support current packaging standards for adding metadata to the **pyproject.toml** file but plans to fix this in an upcoming release.
406+
Follows current packaging standards|✔️|Poetry does not quite support current packaging standards for adding metadata to the **pyproject.toml** file but plans to fix this in an upcoming release.
399407
Install your package in editable mode|✅|Poetry supports installing your package in editable mode using `--editable`
400408
Build your sdist and wheel distributions|✅|Poetry will build your sdist and wheel distributions using `poetry build`
401409
```
@@ -477,6 +485,6 @@ when using setuptools. For instance:
477485

478486
- setuptools will build a project without a name or version if you are not using a **pyproject.toml** file
479487
to store metadata.
480-
\*Setuptools also will include all of the files in your package
488+
- setuptools also will include all of the files in your package
481489
repository if you do not explicitly tell it to exclude files using a
482490
**MANIFEST.in** file

package-structure-code/python-package-distribution-files-sdist-wheel.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ Also note that we are not discussing conda build workflows in this section.
2424
package. These are the "raw / as-is" files that you store on GitHub or whatever
2525
platform you use to manage your code.
2626

27-
**S**ource **D**istributions are referred to as sdist. As the name implies, a SDIST contains the source code; it has not been
27+
**S**ource **Dist**ributions are referred to as sdist. As the name implies, a SDIST contains the source code; it has not been
2828
built or compiled in any way. Thus, when a user installs your source
2929
distribution using pip, pip needs to run a build step first. For this reason, you could define a source distribution as a compressed archive that contains everything required to build a wheel (except for project dependencies) without network access.
3030

@@ -103,7 +103,7 @@ distribution.
103103
The wheel (.whl) is your built binary distribution. **Binary files** are the built / compiled source files. These files are ready to be installed. A wheel (**.whl**) is a **zip** file containing all of the files needed to directly install your package. All of the files in a wheel are binaries - this means that code is already compiled / built. Wheels are thus faster to install - particularly if you have a package that requires build steps.
104104

105105
The wheel does not contain any of your
106-
packages configuration files such as **setup.cfg** or **pyproject.toml**. This
106+
package's configuration files such as **setup.cfg** or **pyproject.toml**. This
107107
distribution is already built so it's ready to install.
108108

109109
Because it is built, the wheel file will be faster to install for pure Python

package-structure-code/python-package-structure.md

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ We understand that it would be tremendous effort for existing
1616
maintainers to move to a new layout.
1717
1818
The overview on this page presents recommendations that we think are best for
19-
something getting started with Python packaging or someone who's package is
19+
someone getting started with Python packaging or someone who's package
2020
has a simple build and might be open to moving to a more fail-proof approach.
2121
```
2222

@@ -32,10 +32,10 @@ myPackageRepoName
3232
│ └── ... │
3333
├── LICENSE │
3434
├── README.md ┘
35-
├── pyproject.toml
36-
├── src
37-
│ └── myPackage │ Package source code, metadata,
38-
│ ├── __init__.py │ and build instructions
35+
├── pyproject.toml ] Package metadata and build configuration
36+
├── src
37+
│ └── myPackage │
38+
│ ├── __init__.py │ Package source code
3939
│ ├── moduleA.py │
4040
│ └── moduleB.py ┘
4141
└── tests ┐
@@ -58,6 +58,8 @@ include:
5858
- LICENSE.txt
5959
- README.md
6060

61+
<!-- TODO: CHANGELOG is not mentioned in either documentation nor peer review -->
62+
6163
```{button-link} https://www.pyopensci.org/python-package-guide/documentation
6264
:color: primary
6365
:class: sd-rounded-pill
@@ -213,9 +215,9 @@ There are some benefits to the scientific community in using the flat layout.
213215

214216
- This structure has historically been used across the ecosystem and packages
215217
using it are unlikely to change.
216-
- You can directly import the package directly from the root directory. For
217-
some this is engrained in their respective workflows. However, for a beginner
218-
the danger of doing this is that you are not developing and testing against the
218+
- You can import the package directly from the root directory. For some this
219+
is engrained in their respective workflows. However, for a beginner the
220+
danger of doing this is that you are not developing and testing against the
219221
installed version of your package. Rather, you are working directly with the
220222
flat files.
221223

0 commit comments

Comments
 (0)