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

Only tar.gz format is made with flit build when there is .git? #685

Open
samuelwhiskeyjohnson opened this issue Jul 5, 2024 · 5 comments

Comments

@samuelwhiskeyjohnson
Copy link

flit build normally produces both tar.gz and .whl format

but when I use git init to have .git in the project, only tar.gz is made.

@takluyver
Copy link
Member

That's weird, what do the messages say? Most of my projects have a .git folder and Flit generally builds wheels as well.

@samuelwhiskeyjohnson
Copy link
Author

samuelwhiskeyjohnson commented Jul 5, 2024

The message is a bit different.

Structure

  • pytest_skip_slow_DIY (directory)
    • .git (directory)
    • dist (directory)
    • examples (directory)
    • LICENSE (file)
    • pyproject.toml (file)
    • pytest_skip_slow_module.py (file)

But here this is with .git folder

(venv) PS C:\Users\SJ\Desktop\Programs\Python\PyTest\code\ch15\pytest_skip_slow_DIY> git init
Initialized empty Git repository in C:/Users/SJ/Desktop/Programs/Python/PyTest/code/ch15/pytest_skip_slow_DIY/.git/
(venv) PS C:\Users\SJ\Desktop\Programs\Python\PyTest\code\ch15\pytest_skip_slow_DIY> flit build
Untracked or deleted files in the source directory. Commit, undo or ignore these files in your VCS.
(venv) PS C:\Users\SJ\Desktop\Programs\Python\PyTest\code\ch15\pytest_skip_slow_DIY> 
(venv) PS C:\Users\SJ\Desktop\Programs\Python\PyTest\code\ch15\pytest_skip_slow_DIY> ls dist


    Directory: C:\Users\SJ\Desktop\Programs\Python\PyTest\code\ch15\pytest_skip_slow_DIY\dist


Mode                 LastWriteTime         Length Name
----                 -------------         ------ ----
-a----          7/6/2024   2:32 AM             79 pytest_skip_slow_module-0.0.5.tar.gz


(venv) PS C:\Users\SJ\Desktop\Programs\Python\PyTest\code\ch15\pytest_skip_slow_DIY>


This is when I don't have the git folder

(venv) PS C:\Users\SJ\Desktop\Programs\Python\PyTest\code\ch15\pytest_skip_slow_DIY> flit build
Built sdist: dist\pytest_skip_slow_module-0.0.5.tar.gz  I-flit_core.sdist
Copying package file(s) from C:\Users\SJ\AppData\Local\Temp\tmp_9wzr_4r\pytest_skip_slow_module-0.0.5\pytest_skip_slow_module.py  I-flit_core.wheel
Writing metadata files                               I-flit_core.wheel
Writing the record of files                          I-flit_core.wheel
Built wheel: dist\pytest_skip_slow_module-0.0.5-py2.py3-none-any.whl  I-flit_core.wheel
(venv) PS C:\Users\SJ\Desktop\Programs\Python\PyTest\code\ch15\pytest_skip_slow_DIY> ls dist


    Directory: C:\Users\SJ\Desktop\Programs\Python\PyTest\code\ch15\pytest_skip_slow_DIY\dist


Mode                 LastWriteTime         Length Name
----                 -------------         ------ ----
-a----          7/6/2024   2:35 AM           5271 pytest_skip_slow_module-0.0.5-py2.py3-none-any.whl
-a----          7/6/2024   2:35 AM           4316 pytest_skip_slow_module-0.0.5.tar.gz


(venv) PS C:\Users\SJ\Desktop\Programs\Python\PyTest\code\ch15\pytest_skip_slow_DIY> 



@takluyver
Copy link
Member

Aha, OK. So it's by design that it's stopping early, as the message indicates:

Untracked or deleted files in the source directory. Commit, undo or ignore these files in your VCS.

It uses git to decide which files to include in the sdist, but if they're neither checked in nor ignored, it doesn't know what to do, so it refuses until you decide on those files. (This is what it does for now, anyway - we're actually moving away from this).

You can override this with the --no-use-vcs option.

There is a bug, however, in that it's creating the .tar.gz file before doing that check. It's actually giving you an empty archive, that's why the length is only 79 bytes. It shouldn't do this if it's refusing to build.

@samuelwhiskeyjohnson
Copy link
Author

1
ok so flit build --no-use-vcs does work. It creates tar.gz and the .whl. 🙂

2

It (Flit) uses git to decide which files to include in the sdist, but if they're neither checked in nor ignored, it doesn't know what to do, so it refuses (to build) until you decide on those files.

I'm not very knowledgeable at Flit. So I'm assuming "it" means "Flit" and "it refuses" mean "it refuses to build" is what you meant for clarity.
Anyways, so shouldn't adding .gitignore also fix this problem?
Even I add .gitignore so that ignore whatever the files inside the dist folder and do flit build I suffer from the same problem generating only the tar.gz format and not the .whl.

.gitignore

dist
__pycache__

@takluyver
Copy link
Member

All the files in your project directory (where pyproject.toml is) need to be either ignored or added (git add blah.txt) to git. If git status shows you any 'Untracked files', Flit will give you this error.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants