-
-
Notifications
You must be signed in to change notification settings - Fork 258
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
Update package metadata #1640
Update package metadata #1640
Conversation
727dfac
to
0e680c3
Compare
I appreciate you talking the time to do this. I will be evaluating this. I apologize though if it takes a bit of time. Switching the build backend is no a small decision as I'll have to be familiar enough to maintain it, and whatever is chosen will most likely be chosen to use across all my packages. I see you are the author of hatch, I at least know where to go to ask questions 🙂. I may have some mildly more complicated questions as the project that has the most complicated setup is https://github.com/facelessuser/Rummage. If I can't migrate that one, then migrating this one may wait. I'll be taking some time to run through this and let you know my final decision. |
path = "pymdownx/__meta__.py" | ||
|
||
[tool.hatch.build.targets.sdist] | ||
include = [ |
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.
NOTE TO SELF: not sure if the includes are all correct. Will need to double-check that we are including what we expect in the sdist and not what we don't.
Okay, so quick question. Assuming I want to run an arbitrary pre-processor step. Like I need to generate some files before the build begins. For example, I have a package Backrefs that needs to generate a compatible Unicodedata table that corresponds with the current Python version. It'll generate the necessary source code, then I will build the package. I assume I need to use the initialize build hook: https://ofek.dev/hatch/latest/plugins/build-hook/#hatchling.builders.hooks.plugin.interface.BuildHookInterface.initialize? |
Yup exactly! from hatchling.builders.hooks.plugin.interface import BuildHookInterface
class CustomBuildHook(BuildHookInterface):
def initialize(self, version, build_data):
... |
I think the only other thing I am uncertain of is whether I may take a stab at |
Those deps would go in either [build-system]
requires = [
"babel",
"hatchling>=0.21.0",
]
build-backend = "hatchling.build" or defined as a dependency of your hook: [tool.hatch.build.hooks.custom]
dependencies = [
"babel",
] The latter is preferred so disabling the hook will not install its dependencies in the build environment. |
Cool, makes sense. That leaves me with figuring out how to actually call babel. Hopefully, integration is straight forward. You've been a lot of help. I'll let you know if I get stuck. I may be able to carve out some time today to dig in today. This is looking promising. |
Hmm, looks like
I'm assuming something like: import os
from hatchling.builders.hooks.plugin.interface import BuildHookInterface
class CustomBuildHook(BuildHookInterface):
def initialize(self, version, build_data):
if self.target_name != 'wheel':
return
# Lazily import in case hook is disabled but file is still loaded
from babel.messages.frontend import compile_catalog
compiled_catalog = compile_catalog()
compiled_catalog.directory = os.path.join(self.root, 'rummage', 'lib', 'gui', 'localization', 'locale')
compiled_catalog.finalize_options()
compiled_catalog.run() Note that the [tool.hatch.build.targets.wheel.hooks.custom]
dependencies = [
"babel",
] |
Another unclear point. |
That's a legacy
All file extensions are included by default, not just |
I read the comment (python/mypy#8802 (comment)), what I am unclear of is what this means. Does this mean that packages are not zipped by default anymore? |
Looks like babel is going to be a pain to get working... |
never mind, think I got it |
I think it's about the old |
I think the metadata plugin isn't running. I'm doing the same thing in Rummage, and the PKG-INFO has no |
I think this change needs to define |
Whoops, fixed! |
I think Hatch can do everything I need it to do. I was able to convert the most cumbersome project, so if I can manage that, I think I understand things well enough to adopt in all of the easier projects. |
09aa6b4
to
2a72771
Compare
Closing this in favor of #1644 which builds upon this PR and cleans up some stuff |
Background
Hello there! The Python packaging ecosystem has standardized on the interface for build backends (PEP 517/PEP 660) and the format for metadata declaration (PEP 621/PEP 631). As a result, the use of
setup.py
files is now heavily discouraged.So, I'm spending my free time updating important projects so that they are modernized and set an example for others 😄
Summary of changes
This implements PEP 621, obviating the need for
setup.py
,setup.cfg
, andMANIFEST.in
. Support has not landed insetuptools
, so builds will now usehatchling
. It is quite stable and actively maintained, the only reason the version is 0.x is because 1.0.0 will drop support for Python 2. It's also on the major distribution channels such as conda-forge, Debian, Fedora, etc.I've done this for such projects as pipx, all Datadog Agent integrations, etc.
Notes
hatch_build.py
can be removed if you want things to be more static