Skip to content

Commit

Permalink
fix: hatch requires extra config if __init__.py is not present
Browse files Browse the repository at this point in the history
  • Loading branch information
Saransh-cpp committed Aug 15, 2024
1 parent 63cc37c commit 981e53c
Showing 1 changed file with 17 additions and 14 deletions.
31 changes: 17 additions & 14 deletions ch04packaging/03Packaging.ipynb.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
# and complex packaging. Some of the recommended ones are listed below -
# - [Python Packaging User Guide](https://packaging.python.org/en/latest/)
# - [pyOpenSci Python Package Guide](https://www.pyopensci.org/python-package-guide/)
# - [Scientific Python Packaging Guide]https://learn.scientific-python.org/development/tutorials/packaging/
# - [Scientific Python Packaging Guide](https://learn.scientific-python.org/development/tutorials/packaging/)
#
# Besides the guides, there are numerous "cookie" templates available for developers. These templates
# allow developers to generate an empty Python package following good practices and guidelines with a
Expand Down Expand Up @@ -97,7 +97,7 @@
# |-- LICENSE.md
# |-- CITATION.md
# |-- README.md
# `-- setup.py
# `-- pyproject.toml
# ```
#
#
Expand Down Expand Up @@ -147,7 +147,8 @@
# 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)
# for the actual build-backend `hatchling`. `hatchling` is installed with hatch and can be specified as the `build-backend` in `pyproject.toml`.
#
# 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.
# 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.
# We could have skipped adding the directory manually if our package had a `__init__.py` file (more on this below).
# The best way to look at all the options of a build-backend is by going through its documentation.

# %%
Expand All @@ -161,9 +162,9 @@
name = "Greetings"
version = "0.1.0"

[tool.hatch.build.targets.sdist]
include = [
"src*",
[tool.hatch.build.targets.wheel]
packages = [
"src/greetings",
]

# %% [markdown]
Expand Down Expand Up @@ -343,9 +344,9 @@ def process():
[project.scripts]
greet = "greetings.command:process"

[tool.hatch.build.targets.sdist]
include = [
"greetings/",
[tool.hatch.build.targets.wheel]
packages = [
"src/greetings",
]

# %% language="bash"
Expand Down Expand Up @@ -422,9 +423,9 @@ def process():
[project.scripts]
greet = "greetings.command:process"

[tool.hatch.build.targets.sdist]
include = [
"src/",
[tool.hatch.build.targets.wheel]
packages = [
"src/greetings",
]


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

[tool.hatch.build.targets.sdist]
include = ["src*"]
[tool.hatch.build.targets.wheel]
packages = [
"src/greetings",
]


# %% [markdown]
Expand Down

0 comments on commit 981e53c

Please sign in to comment.