Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: hatch requires extra config if __init__.py is not present #249

Merged
merged 1 commit into from
Aug 15, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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