rye icon indicating copy to clipboard operation
rye copied to clipboard

`rye build` ouput empty wheel

Open gunungpw opened this issue 1 year ago • 4 comments

Thank you, for making rye "one-stop place" for Python packaging and project manager .

I have a problem with rye build The step to reproduce is like the one below:

Steps to Reproduce

  • git clone https://github.com/gunungpw/namecolors.git
  • cd namecolors
  • rye build
  • check wheel file is empty

pyroject.toml

[project]
name = "namecolors"
version = "0.1.2"
description = "Get your colors name"
authors = [{ name = "gunungpw", email = "[email protected]" }]
dependencies = ["urllib3>=2.2.1"]
readme = "README.md"
requires-python = ">= 3.8"
classifiers = [
    "Programming Language :: Python :: 3",
    "Programming Language :: Python :: 3.8",
    "Programming Language :: Python :: 3.9",
    "Programming Language :: Python :: 3.10",
    "Programming Language :: Python :: 3.11",
    "Programming Language :: Python :: 3.12",
]

[build-system]
requires = ["hatchling"]
build-backend = "hatchling.build"

[tool.rye]
managed = true
dev-dependencies = []

[tool.hatch.metadata]
allow-direct-references = true

[tool.hatch.build.targets.wheel]
packages = ["src/namecolors"]
exclude = ["src/namecolors/data/*.json"]

[tool.hatch.build.targets.sdist]
packages = ["src/namecolors"]
exclude = ["src/namecolors/data/*.json"]

Project Structure

.
├── dist
│  ├── namecolors-0.1.2-py3-none-any.whl
│  └── namecolors-0.1.2.tar.gz
├── docs
│  ├── index.md
│  └── reference.md
├── src
│  └── namecolors
│     ├── data
│     │  ├── basic.json
│     │  ├── bestOf.json
│     │  ├── chineseTraditional.json
│     │  ├── default.json
│     │  ├── french.json
│     │  ├── german.json
│     │  ├── get_data.py
│     │  ├── html.json
│     │  ├── japaneseTraditional.json
│     │  ├── leCorbusier.json
│     │  ├── nbsIscc.json
│     │  ├── ntc.json
│     │  ├── osxcrayons.json
│     │  ├── ral.json
│     │  ├── ridgway.json
│     │  ├── risograph.json
│     │  ├── sanzoWadaI.json
│     │  ├── spanish.json
│     │  ├── thesaurus.json
│     │  ├── werner.json
│     │  ├── wikipedia.json
│     │  ├── windows.json
│     │  ├── x11.json
│     │  └── xkcd.json
│     ├── colors.py
│     └── name.py
├── tests
├── LICENSE.txt
├── README.md
├── mkdocs.yml
├── pyproject.toml
├── requirements-dev.lock
├── requirements.lock
└── testing.py

Expected Result

wheel file not empty

from experiment when use: rye build --wheel -c the wheel file is normal and include the source code

but when use only: rye build the wheel file is empty

Actual Result

sdist output

namecolors\dist\namecolors-0.1.2 on  master via  v3.12.1 (namecolors) 
❯ eza -T -s type
.
└── namecolors-0.1.2
   ├── namecolors
   │  ├── data
   │  │  └── get_data.py
   │  ├── colors.py
   │  └── name.py
   ├── LICENSE.txt
   ├── PKG-INFO
   ├── README.md
   └── pyproject.toml

wheel output

namecolors\dist\namecolors-0.1.2-py3-none-any.whl on  master via  v3.12.1 (namecolors) 
❯ eza -T -s type
.
└── namecolors-0.1.2.dist-info
   ├── licenses
   │  └── LICENSE.txt
   ├── METADATA
   ├── RECORD
   └── WHEEL

Version Info

rye 0.25.0
commit: 0.25.0 (d8e00cea1 2024-02-19)
platform: windows (x86_64)
self-python: [email protected]
symlink support: true
uv enabled: true

Stacktrace

No response

Hope you have a good day, Thank you.

best regards, gunungpw

gunungpw avatar Feb 21 '24 13:02 gunungpw

Is there anything I miss in pyproject.toml, but why the rye build and rye build --wheel -c give different output additional info:

  • windows 11
  • uv is enable

gunungpw avatar Feb 21 '24 13:02 gunungpw

I wonder if this is an issue with rye or how hatch is set up. Does the problem also appear if you use build manually on that project?

mitsuhiko avatar Feb 21 '24 20:02 mitsuhiko

for now, my solution is to use separately:

  • rye build --wheel
  • rye build --sdist

So the wheel is not empty,

gunungpw avatar Feb 25 '24 04:02 gunungpw

I just encountered the same problem. I think this is due to the fact that the wheel is built from the sdist archive. Since you defined

[tool.hatch.build.targets.sdist]
packages = ["src/namecolors"]
exclude = ["src/namecolors/data/*.json"]

The namecolors package gets mapped at the root of the archive. Then the wheel is build from this archive, looking for a package in src/namecolors as specified in pyproject.toml:

[tool.hatch.build.targets.wheel]
packages = ["src/namecolors"]
exclude = ["src/namecolors/data/*.json"]

But this package does not exist since it got mapped to namecolors/ in the sdist, not src/namecolors...

The solution is to remove the packages field from the sdist configuration, keeping only the exclude. Then the sdist will contain the whole source tree and the wheel will get correctly built!

sdiebolt avatar Jul 21 '24 11:07 sdiebolt