-
-
Notifications
You must be signed in to change notification settings - Fork 12
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
Use hatch, hatch-vcs; drop setuptools, versioneer. #145
Use hatch, hatch-vcs; drop setuptools, versioneer. #145
Conversation
Both warnings are coming from
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Both warnings are coming from setuptools_scm which should not be involved at all here.
hatch-vcs
uses it! Of course that doesn’t explain what the warning is about or how to fix it…
I’m new to It looks like the warnings are coming from the second build, and seems strange (without knowing any better) for that second build to even be happening. I noticed that if I just run |
Well, this seems to happen for me on a more-or-less blank repo (e.g. what you have if you follow the PyPA tutorial), so I think it may be an intrinsic issue with the current combination of build, hatchling, and setuptools-scm. I’m definitely not familiar enough with the details to diagnose the problem well, but based on skimming the source:
It seems like the above is how setuptools-scm has behaved since v7. Pinning Alternatively, maybe build or hatchling is intending to work against an actual git archive instead of the working directory, but is somehow winding up on the actual working directory, or a copy of it instead? |
I’m also noticing |
Also, they put one that does get included in Anyway, I’m done for the day. Hopefully some of the above will be useful for you. |
Yes. From
This possibility occurred to me. Maybe this is fine.... |
aeb9844
to
a150311
Compare
CI failures are related to cache key:
and version not being set:
Locally, the version is being set as expected:
|
I updated the cache key and build script in
I think we didn’t have that error before because we excluded test files with: [tool.setuptools.packages.find]
where = ["."]
exclude = ["docs", "tests"] So this either needs the equivalent config for Hatchling or config for I think it’s probably better to continue not including test files, but I don’t have especially strong feelings about it. Either approach is probably OK if you have strong feelings the other way. |
Yeah, I had read that, and was reacting to the text:
While the log output made it look like it was building once from the sdist and then again from source:
But I just started digging into the warning on a simplified repo using setuptools instead of hatchling, and setuptools does a lot more logging — I can see now that the |
That also makes it clearer what’s causing the warning, and why we only see it when doing
Anyway, this makes sense now, although it is kind of a crappy situation. Do you know if there’s a way to have build (or hatchling?) run the right git machinery to get the right values substituted into |
Or alternatively: maybe the right way to do this is to build with: # From the root of the repo:
git archive --output ../build_dir/source_archive.tar <tag-to-build>
cd ../build_dir
tar -xf source_archive.tar
rm source_archive.tar
python -m build . That way you are building the sdist with a properly archived/archive-ready file tree. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, so to summarize:
-
It’s clear to me now why we are getting the warning. I think it’s pointing us to a legit problem, although not a critical one: our builds/distributions have placeholder/template files in them that they probably should not. There are a bunch of solutions here, but I think either of these two make the most sense:
- Write a build script that builds from an archive (see above) so the
.git_archival.txt
file is correctly populated in our builds. (Should be a script and not just commands in the CircleCI config file so we can use it in CI and whenever someone is building a release [someday I’d like to script the whole release process in CI, but I think that’s out of scope here].) - Exclude the file from builds so it’s not present or visible to hatch-vcs/setuptools-scm.
- Write a build script that builds from an archive (see above) so the
-
We also need to fix the build error by excluding test files (preferable) or by not checking those files when validating the built wheel with
check-wheel-contents
.
Re: “exclude the file from builds,” I tripped over this [tool.hatch.build.targets.sdist]
exclude = [".git_archival.txt"] (The same article also suggests removing test files from wheels but not sdists, which I hadn’t thought of before. Interesting.) |
Let me a little digging around some other projects and the behavior of their builds. I wonder if (i) is better, though I agree you have found the right implementation of (ii) if we go that way.
Happy to tackle this next. I usually include the tests. The “web deployment” side of Python, interested in small containers and fast CD, pushes to keep the tests out, while the “science” side of Python, where end users also sometimes dip into light development, almost always bundles them. The sdist/wheel breakdown is a reasonable compromise. I am on international travel for work; I left a note to resume this Monday when I am back at my keyboard. |
That all makes sense to me!
Sounds good. I’m hoping to include this in a v0.5.0 release before the end of the year, but otherwise there’s no rush. (Besides this I want to do some final rate limiting cleanup for #137 and to finally get thread safety by dropping requests, but we’ll see; I may be being to hopeful there.)
👍 |
Reading a bit, I agree that excluding Googling the current error in CircleCI, I found a post from one @Mr0grog: https://discuss.circleci.com/t/upgrading-to-the-convenience-image-breaks-everything/42746 Do we need to further adjust our cache key here? |
🤣 Yep, I think that’s probably all you need to do. |
Last issue:
|
Indeed these files have the same contents, but I think we should not assume that they always will forever, so the right thing here to make an exemption in the check:
|
Huh, I would have thought that would be solved by 7be22d4. Is that only addressing Python files, or does it need to be |
Oh, no, I think it needs to be the wheel target:
|
Ah, indeed. Pushed. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Woohoo, successful builds! 🎉 Is more-or-less ready to merge into #144?
Also one question: Does MANIFEST.in
still get used (I think that is really a setuptools thing)? If no, we should probably also delete it here.
And a couple quick notes inline.
Oh, I also wanted to ask: what pushed you towards excluding
|
Your argument made sense, I just look around a bit at some projects and confirmed that I could not find any examples that could convince me otherwise. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sweet, this looks good! I uploaded to test.pypi.org and then installed the uploaded package both from the wheel and from the source and everything seemed to work. 🎉
I also did a quick test of removing MANIFEST.in
, and it makes no different to the content of the sdist or wheel, so I will drop that over in #144 after merging this into it.
30e4243
into
edgi-govdata-archiving:can-we-drop-setuppy-lets-find-out
@danielballan would a good quick followup here be moving |
This is part of the way there. Some warnings needs to be resolved. I haven't seen these before.