Skip to content

Commit d24d55f

Browse files
authored
Merge pull request #249 from UCL/saransh/fix-packaging
fix: hatch requires extra config if __init__.py is not present
2 parents 63cc37c + 981e53c commit d24d55f

File tree

1 file changed

+17
-14
lines changed

1 file changed

+17
-14
lines changed

ch04packaging/03Packaging.ipynb.py

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
# and complex packaging. Some of the recommended ones are listed below -
2626
# - [Python Packaging User Guide](https://packaging.python.org/en/latest/)
2727
# - [pyOpenSci Python Package Guide](https://www.pyopensci.org/python-package-guide/)
28-
# - [Scientific Python Packaging Guide]https://learn.scientific-python.org/development/tutorials/packaging/
28+
# - [Scientific Python Packaging Guide](https://learn.scientific-python.org/development/tutorials/packaging/)
2929
#
3030
# Besides the guides, there are numerous "cookie" templates available for developers. These templates
3131
# allow developers to generate an empty Python package following good practices and guidelines with a
@@ -97,7 +97,7 @@
9797
# |-- LICENSE.md
9898
# |-- CITATION.md
9999
# |-- README.md
100-
# `-- setup.py
100+
# `-- pyproject.toml
101101
# ```
102102
#
103103
#
@@ -147,7 +147,8 @@
147147
# In this case, we'll be using `hatch` to build our package, so we list it in the `requires` field. Technically speaking, `hatch` is the front-end (a CLI utility)
148148
# for the actual build-backend `hatchling`. `hatchling` is installed with hatch and can be specified as the `build-backend` in `pyproject.toml`.
149149
#
150-
# Finally, we can set specific options for `hatch` using additional sections in `pyproject.toml`: in this case, we will tell `hatch` that it needs to find **and include** all of the files in our `src` folder.
150+
# Finally, we can set specific options for `hatch` using additional sections in `pyproject.toml`: in this case, we will tell `hatch` that it needs to find **and include** all of the files in our `src/greetings` folder.
151+
# We could have skipped adding the directory manually if our package had a `__init__.py` file (more on this below).
151152
# The best way to look at all the options of a build-backend is by going through its documentation.
152153

153154
# %%
@@ -161,9 +162,9 @@
161162
name = "Greetings"
162163
version = "0.1.0"
163164

164-
[tool.hatch.build.targets.sdist]
165-
include = [
166-
"src*",
165+
[tool.hatch.build.targets.wheel]
166+
packages = [
167+
"src/greetings",
167168
]
168169

169170
# %% [markdown]
@@ -343,9 +344,9 @@ def process():
343344
[project.scripts]
344345
greet = "greetings.command:process"
345346

346-
[tool.hatch.build.targets.sdist]
347-
include = [
348-
"greetings/",
347+
[tool.hatch.build.targets.wheel]
348+
packages = [
349+
"src/greetings",
349350
]
350351

351352
# %% language="bash"
@@ -422,9 +423,9 @@ def process():
422423
[project.scripts]
423424
greet = "greetings.command:process"
424425

425-
[tool.hatch.build.targets.sdist]
426-
include = [
427-
"src/",
426+
[tool.hatch.build.targets.wheel]
427+
packages = [
428+
"src/greetings",
428429
]
429430

430431

@@ -676,8 +677,10 @@ def test_greeter(fixture):
676677
[project.optional-dependencies]
677678
dev = ["pytest >= 6"]
678679

679-
[tool.hatch.build.targets.sdist]
680-
include = ["src*"]
680+
[tool.hatch.build.targets.wheel]
681+
packages = [
682+
"src/greetings",
683+
]
681684

682685

683686
# %% [markdown]

0 commit comments

Comments
 (0)