astral-sh / rye

a Hassle-Free Python Experience
https://rye.astral.sh
MIT License
13.6k stars 466 forks source link

`rye build --sdist` makes a `.tar.gz` that contains `.github` and `.gitignore` #1264

Closed jamesbraza closed 2 months ago

jamesbraza commented 2 months ago

Steps to Reproduce

Here is my project's rough structure:

 .
├──  .github
│  └──  workflows
│     ├──  publish.yaml
│     └──  tests.yml
├──  src
│  └──  proiect
│     ├──  __init__.py
│     ├──  foo.py
│     ├──  py.typed
│     └──  version.py
├──  tests
│  └──  test_foo.py
├──  .gitignore
├──  pyproject.toml
├──  README.md
├──  requirements-dev.lock
└──  requirements.lock

Now, when I run rye build --sdist and view the resultant .tar.gz, I see it contains all the files, including the .github and .gitignore.

Expected Result

I expected the resultant .tar.gz to not include hidden files like .gitignore or hidden folders like .github.

Actual Result

The made .tar.gz includes hidden files like .gitignore or hidden folders like .github.

Version Info

rye 0.37.0 commit: 0.37.0 (2024-07-20) platform: macos (aarch64) self-python: cpython@3.12.3 symlink support: true uv enabled: true

Stacktrace

No response

charliermarsh commented 2 months ago

I think Rye is just calling python -m build here. If you want to configure the build, you should probably be configuring the tool.hatch metadata in your pyproject.toml?

jamesbraza commented 2 months ago

Ah I see, so it's essentially python -m build --sdist behind the scenes. Yes it's a pyproject.toml configuration issue, which is then outside the scope of Rye. Thank you!

To resolve this issue (unassociated with Rye), one can employ a MANIFEST.in in the repo root:

# Ignore .gitignore and requirements files
exclude [.r]*
# Ignore .github and tests directories
recursive-exclude [.t]* *