this post was submitted on 25 Oct 2023
5 points (100.0% liked)

Python

6413 readers
4 users here now

Welcome to the Python community on the programming.dev Lemmy instance!

πŸ“… Events

PastNovember 2023

October 2023

July 2023

August 2023

September 2023

🐍 Python project:
πŸ’“ Python Community:
✨ Python Ecosystem:
🌌 Fediverse
Communities
Projects
Feeds

founded 1 year ago
MODERATORS
 

I want to build a python package using setuptools. The folder structure of the project is the following (some non-essential parts have been deleted):

energy-monitor
β”œβ”€β”€ config
β”‚ β”œβ”€β”€ config.yml
β”‚ └── secrets.yml
β”œβ”€β”€ data
β”‚ └── cpu_tdp.json
β”œβ”€β”€ energy_monitor
β”‚ β”œβ”€β”€ core
β”‚ β”‚ β”œβ”€β”€ gui.py
β”‚ β”‚ β”œβ”€β”€ __init__.py
β”‚ β”œβ”€β”€ data
β”‚ β”‚ └── tableExport.json
β”‚ β”œβ”€β”€ __init__.py
β”‚ β”œβ”€β”€ main.py
β”‚ └── utils
β”‚     β”œβ”€β”€ api_calls.py
β”‚     └── __init__.py
β”œβ”€β”€ energy-monitor.py
β”œβ”€β”€ LICENSE
β”œβ”€β”€ MANIFEST.in
β”œβ”€β”€ pyproject.toml
β”œβ”€β”€ README.md
└── requirements.txt

The content of the pyproject.toml file is the following (some non-essential parts have been deleted):

[build-system]
requires = ["setuptools>=68.0"]
build-backend = "setuptools.build_meta"

[project]
name = "energy_monitor"
version = "0.0.1"
description = "Energy monitor"
readme = "README.md"
requires-python = ">=3.11"
license = {text = "GPLv3"}
classifiers = [
  "Programming Language :: Python :: 3",
  "Operating System :: OS Independent",
]
dynamic = ["dependencies"]

[tool.setuptools.dynamic]
dependencies = {file = ["requirements.txt"]}

[tool.setuptools]
packages = [
  "energy_monitor", 
  "energy_monitor.core", 
  "energy_monitor.utils"
]
include-package-data = true

[project.scripts]
energy-monitor = "energy_monitor.main:main"

Finally, the content of the MANIFEST.in file is the following:

include README.md
include LICENSE
graft config

I generate the package with python -m build and install the .tar.gz archive with pipx. According to setuptools documentation, I expect to find my config folder, together with README and LICENSE in the interpreter directory (site-packages) after the installation. However, this doesn't happen and I cannot run the app becase it complains that it doesn't find the config. What am I missing?

you are viewing a single comment's thread
view the rest of the comments
[–] NostraDavid 3 points 1 year ago* (last edited 1 year ago)

Doesn't MANIFEST.in specify which other-than-the-known-package files and folders to include?

I bet you need to add them to the MANIFEST.in.

I use poetry, so I don't need the MANIFEST.in, but I used it use a setup.py a few years ago, which is why I somewhat know of it.

https://packaging.python.org/en/latest/guides/using-manifest-in/