#hatch
1 messages ยท Page 4 of 1
plumbum is basically a collection of tools to help you write command line scripts. It predates good packaging, so it bundled stuff that really should have been seperate packages
The reason I'm thinking about it now is I want see if I can get Python 3.14's color --help output into a mkdocs project. ๐
colorlib has the ability to read and write ansi and write html. So I think I could convert with it. (I'm trying Rich first, but it adds a lot of stuff around the html)
I forget the name but for color have you tried that package Hugo maintains? it's been around for a while but I think ownership was semi-recently transferred so it's in a better shape now
termcolor, it seems, and doesn't seem to support html.
FWIW, I would love to have the opportunity to install Plumbum without those sub-packages. I'm a fan of modularity for its own sake. (And, well, you can imagine how I feel about Numpy as a result ;) )
re import time, my understanding having them namespaced would imply importing plumbum.__init__ before the sub-packages if it exists; if you can design the sub-packages to not depend on the main package, then the cost of the namespacing should be trivial (just chasing the path further and creating an extra empty module object and setting its attribute)
that sort of thing is much faster than running top-level code in a module (which I can confirm can take single-digit milliseconds per module; worse of course if there are transitive imports)
(for me, time python -c 'import plumbum' is about 80ms more than time python -c 'pass')
Those packages are just a bit of pure Python without side effects (I think I delayed the color protection atexit). I need to check with -X importtime, but I think they don't add too much if anything. This idea wouldn't allow that, but maybe more parts could be pulled out. I really dislike plumbum.path since it's pre-pathlib, but it's remote version makes it both unreplacable and tangled with the local and remote submodules. And plumbum has a lot of top-level objects.
I was wondering if hatching can do it, and if there might be a problem doing it. Pretty sure the first answer is yes, but not sure how involved it might be.
You must love SciPy. ๐
oh I was wondering why you were asking in this channel, my bad I should have interpreted it as a question about packaging lol
yeah that's totally possible with Hatchling
not sure it would work out-of-the-box without config, let me check
@errant timber probably not https://github.com/pypa/hatch/blob/hatchling-v1.27.0/backend/src/hatchling/builders/wheel.py#L226
so you would have to do manually for each package:
[tool.hatch.build.targets.wheel]
packages = ["src/plumbum"]
Okay, I think I have an idea of how to do it. Will research uv's workspace feature to try to keep them in one repo.
I'm fine with (and expect) config for somethign like this ๐
oh it's about building multiple wheels from the same source tree, I get it. Yeah, if all else fails you can script "re-edit pyproject.toml and call the build frontend again"
(and NumPy's weight is fine when you need the full SciPy experience and that's part of it. When you have a couple hundred LOC to fill a bytes and just want to interpret it as a 3d array and slice it, maybe not so much. I don't even know how to evaluate whether my code will actually touch the blas/lapack libraries, actually.)
oh thanks for the clarification. changing the name dynamically is not allowed so yes you would need multiple pyproject.toml files
(maybe I misunderstood? and sorry about the off-topic part)
Yes, that's a big part of it; I'm thinking I'll make two subdirectories for the two namespace packages. I think uv's workspaces (IIRC Hatch doesn't have them yet?) might be able to manage them. Then I can set them up with the config above. (And for SciPy, I was referring to the fact it's basically a big collection of unrelated modules that were bundled together since packaging was bad at the time, and the small collection of Fotran makes it really hard to compile the whole thing)
correct no workspaces yet, I've been extremely demotivated
I've never been a fan of all-in-one tools of that sort, but my hat's off to anyone who makes a multi-project "workspace" concept for Python that catches on. I wouldn't know where to start with the design.
We do have it in uv!
It's pretty early days though, so I'd love to hear more about whether it works or not for you.
I don't know that I have the kind of project where it would help, but I suppose I should at least try to play around with it. (Actually, the tools I'm "currently working" on seem like the best candidates...)
I have not actually used it yet, but reading through the documentation I'm surprised that the child project has to specify that a particular dependency is in the workspace via tool.uv.sources. It seems like that would be the default if not specified -- but maybe I'm just used to the way that golang workspaces work
We don't support children pulling their dependency declarations from the workspace root yet, it's not "standards compliant" so we need to figure out a way to make that work.
Getting off topic, but I'm hoping to support uv workspaces in cibuildwheel when we add a native uv frontend (we have build[uv] currently). But that's pushed off till 3.1. I'm hoping doing it with hatchling in Plumbum will be a good way to learn about them (not binary ones, but hopefully close enough)
If hatch still doesn't support dependency-groups, I might try to contribute that in the future. ๐
BTW, I noticed Hatch is reporting hatch-test.py3.14 -> cannot locate Python: 3.14 though I've installed 3.14 in GHA.
show config/branch
macOS is fine. Linux and Windows are not able to find it. I'm using the free-threading Python, since GHA's regular Python is broken on Windows for bulding (and Hatch needs a build with cffi)
I wonder if it happens to work since macOS has both versions (even though I request/activate the free-threaded one), but the others don't. I bet that's it.
Is there a flag I can use to make a missed Python an error? Nox sets the flag for you if CI is defined, since it's an easy footgun on CI.
can you show the branch?
Sure, it's repo-review. https://github.com/scientific-python/repo-review
you need to set a conditional environment variable based on this https://github.com/scientific-python/repo-review/blob/main/.github/workflows/ci.yml#L58
I just happened to notice I wasn't actually testing what I thought I was testing, CI was passing but 3.14 was mostly skipped.
HATCH_PYTHON_VARIANT_GIL https://hatch.pypa.io/latest/plugins/environment/virtual/#cpython
I can't ask for 3.13t, etc? I was rather planning on trying python = ["3.14t", "3.13t", "3.13", "3.12", "3.11", "3.10"]
It's the syntax of setup-python, uv, pyenv, virtualenv, tox, and nox, at least.
I guess I have to support it then but it's a bummer because it's literally temporary until it becomes the default
like say you have 3.15 and freethreaded is the default, how would a user request the option to not have that, you know? I don't think that's something folks have figured out with that syntax which is why I consider that an option for an identifier rather than a new identifier
what works?
I bet there's going to be a 3.16g or something (I'd be pretty surprised if the default flips in 3.15, I think working on a thread-safe JIT will be the focus of 3.15)
But they are living together for at least a few more years, and testing on both at the same time is really nice.
I don't recall supporting that syntax, so I'm not sure how it's working
It might be picked up from virtualenv/uv? It even gets the session name right. Trying it now with everything.
oh I guess since virtualenv supports that syntax and Hatch passes the name for resolution then it would work as a byproduct, however if it wasn't already installed Hatch would not be able to download it
Works on macOS, and I realized I can install hatch with 3.13 and test on 3.14, so both Windows works too. It looks like yaml won't import on 3.14t on ubuntu (only) due to a circular import (strange), so hatch-test.py3.14t fails there.
But as long as they are pre-installed, it works well ๐
Hio, would be great to get some context for hatch shellโs parameters: https://github.com/pypa/hatch/issues/1972
Theyโre undocumented, and I donโt know if their behavior is expected or not (like, is name only for display or is it supposed to select a shell by name but that part doesnโt work?)
@umbral bridge whats the recommended way to run hatch tests against master of pluggy - im reworkin downstream testing in pluggy and took note that the hatch run dev command is no longer working, probably never was (as its not editable isntalling the pluggy)
@umbral bridge ping on that question - i want to run hatch tests against pluggy main
does this help? https://hatch.pypa.io/latest/how-to/plugins/testing-builds/
Not exactly i want to run the complete testsuite of hatch/hatching against pluggy mainline
Going to do my best to word this and it not be confusing, what is the recommended way in Hatch if I need to ensure a plugin is installed by all users before any other installs can happen? I need to make sure my users are using a plugin that will give them a multi-package virtual environment and setup to point to a proxy rather than public pypi. What I mean by multi-package is not multiple packages in the same git repo but rather multiple git repos under the same parent directory.
... is there a reason the plugin can't just be declared as a dependency?
I believe the idea is the plugin affects dependency resolution during build time? If so that would require either declaring it in the buildsystem requires or disable build isolation I think
https://hatch.pypa.io/1.10/plugins/environment/reference/#installation
indicates theres a settings key for that
This is for environments, but I think the ask is for during package generation? Unclear
the doc clearly stated any env type not builtin muxt be preinstalled or listed there, so my interpretation is - list it there
that mapping is different form the env mappings
The requirement is pre-install of any environment this plugin is installed. But I think Ronny got me what I was looking for as I think I can use EnvironmentInterface here to get what I need to do. And yes this is a very weird thing but unfortunately how things work at Amazon where the primary structure of work is polyrepo based.
well, finally migrating a package to use hatchling, two years later.
for build hooks, is there something similar to force_include? In particular, if you add to force_include then the package will be automatically recognized without the user needing to explicitly specify tool.hatch.build.targets.wheel.packages -- but when a user does an editable install, the files are added to the wheel and copied to site-packages. The .pth file points at the original source so it works as expected -- but it's really weird that the files were copied to site-packages.
I tried just adding to artifacts, but that didn't resolve the issue.
That might be because the correct way to access files shipped with a package is importlib.resources, which might try to load things from site-packages. But Iโm not sure.
I use artifacts so files are included in the wheel that are .gitignored. I think itโs only for that and doesnโt influence anything other than โdonโt ignore this fileโ
force_include_editable? https://hatch.pypa.io/latest/plugins/builder/wheel/#build-data
Nope, I actually want the inverse of force_include_editable -- only include things when it isn't building an editable install
hi everyone ๐ I'm dropping in here as I noticed that the Hatch repository in PyPA hadn't had much activity in the past 5 months. We have tutorials and have been teaching using Hatch. I wondered what is going on with the project. @umbral bridge i also DM'd you in slack. I'm just a bit concerned and wondered if the project has plans to move forward / be maintained. It's such a great community project and we want to support community projects. Thank you all for any insight!
For posterity: we discussed that I am looking for a co-maintainer, the project is not abandoned, and almost all functionality requested in issues is supported by plugins
Thank you so so much @umbral bridge ! it was also great to catch up a bit today ๐
I saw that pylock.toml has been accepted, and I know that hatch was waiting for a standard to implement lockfiles, is there an eta or pr in the works for pylock.toml lockfiles?
no, but luckily I think I might have found a co-maintainer two days ago so when I find out more details about their/their team's level of commitment I will be able to offer more insight into the roadmap ๐ค
oh neat! thank you ofek!
๐ I thought I would give a proper introduction as my name starts to pop up more. I am Cary, I am a Python Ecologist at Amazon, I help maintain the Python ecosystem internally for Amazon. Some of you who have attended PyCon might know my coworker Jeff Edwards. My previous open source contributions have been primarily in Airflow and poetry_plugin_pypi_proxy. I am going to be trying to spend more time contributing back to hatch starting with workspace support which had an absolutely amazing foundation from Ofek already started. Once I get through some of that work I can certainly chat with Ofek about implementing lockfile support once that happens.
I want to get opinions on workspace support, Right now what I have put in will allow defining the names of the workspace packages under "tool.hatch.workspace" in pyproject.toml as an array of names. I think that part is the right approach, how much of workspace support should include CLI commands such as workspace remove, workspace add, workspace update? I want to make sure that what comes out meets the communities needs. ๐
I'd say that we introduce the baseline support first and then in a subsequent PR we can add those commands and potentially ones to manage dependencies as well (or that can wait until lock file stuff is added).
We've gotten pretty far without workspace-specific commands in uv
Oh, I didn't realize there weren't any. @hoary wraith Let's not do that for now then ๐
Oh good to know, I did not realize there were not any either. Then I think we can definitely hold off and focus on the lockfile piece. I should have time this weekend to be much closer to a PR for workspaces.
uv add <path> just adds it as a workspace member if it's in the current project
and uv init <path> in a workspace does the same
@umbral bridge aware of any hatch plugin that uses hookspecs ?
im coming up with a complete removal of the pluggy dependency thats still backward compatible (putting my 3 month free claude max gift in use)
Can you explain what that means? I think that's every plugin, no?
@umbral bridge hookimpls are used by all of them - i have compat forthat directly in place - but basically as all the hooks you have only ever return types and never take contextual args, its safe to jsut call them - so i can invoke all the pluggy hooks without pluggy - its just that legacy plugiosn would get warnings
@tropic void is pluggy a deprecated package?
@low gyro nope, but hatch uses it in a way thats ludicrus - all its doing with it is looking up classes without ever doing anything fun (like pytest does)
as all thats done is look up classes, its not sensible
ok, makes sense. thanks for clarification
I see, yes thanks, I don't think any plugins use specs
@umbral bridge im going cazy with your custom massive explictit ruff config that breaks in different places and envs
what breaks?
different rules are missing on co, local, and after update that changed -
i'll undo all changes to the ruff rules file and then figure how the local one is supposed to run
interestingly it nworks now without a hickup - i suspect i might have had a poisoned cache for the fmt env
ah, still a behaviour difference
this is precisely why i use pre-commit - drift is so tricky
i can understand the dislike - its very specific design choices for stability dont match the expectaions of some folks - of some parts im also not a fan - but its rock-solid and good enoug
@umbral bridge https://github.com/pypa/hatch/pull/2076 is done with the first iteration - i'd apprecaite a quick skim - some refinement is missing
That looks pretty good! I plan to land workspaces first (effectively frozen until @hoary wraith is finished) and then merge yours afterward.
Iโm curious - what is the zstd decompression in hatch for? Are there private wheel indices with zstd-compressed wheels or something?
python from python-build-standalone is compressed with zstd
IIRC Hatch supports installing those Python distributions
Working diligently to get this out. Ran into a few snags over the past couple days when setting up for dogfooding where I discovered a few things missing for workspaces to work correctly.
I have marked the PR for workspace support ready for review, I am still working on what the changes need to be to dogfood it within CI but the primary code is ready. https://github.com/pypa/hatch/pull/2073
Python 3.14 is released. Can we get https://github.com/pypa/hatch/pull/2080 in and make a release?
@umbral bridge hatch is still hiding errors in version sources by cutting off traceebacks to be missing it all
I have what I think are the final changes needed for workspace support pushed. Ofek and I just need to discuss them and review them which is what is blocking other PRs right now. Workspace support was a big enough change that it was going to warrant a code freeze for a bit until it was ready to go.
are there any issues filed on this? I can take a look at them or if you have a good reproducible example.
just use the code version source and trigger a import error in the body of the code file
i dont recall if we filed one when i ran into this last time
User reports: can't import my package
Just removing all Hatch config fixed it: https://github.com/fmorton/Birdbrain-Python-Library-2/pull/1
The dist-info folder was being created
/usr/local/python/3.12.1/lib/python3.12/site-packages/birdbrain_python_library_2-0.9.28.dist-info
But the folder with the actual code was not
/usr/local/python/3.12.1/lib/python3.12/site-packages/birdbrain_python_library_2
I've seen this before, but last time the build config just excluded all code from the wheel, so the wheel was just empty
Here, I still see all the code in the wheel on Inspector, so I'm not sure why it's not getting installed
https://inspector.pypi.io/project/birdbrain-python-library-2/0.9.26/
The packages config should never be used with the sdist build target.
(why not?)
I don't have the bandwidth to explain but here are the docs https://hatch.pypa.io/latest/config/build/#packages
๐ ,all good, take care of yourself, I'm just curious
basically as the docs say it corrupts the path of the source distribution such that when you build the wheel from the unpacked source distribution the directory structure doesn't match the repository
Ahhhh
I came here because I was having problems of my own migrating but that clears it up
If you have a hatch plugin that utilizes the EnvironmentInterface, can you please test out changes from https://github.com/pypa/hatch/pull/2073 Ofek and I would like to make sure that these changes do not have a large negative impact on existing plugins, there have been some pretty significant changes to the EnvironmentInterface to make way for workspaces.
@umbral bridge I know you're busy, but I did want to flag this to you: https://github.com/pypa/pip/issues/13627#issuecomment-3430816365
We can and should debug it further on pip's end, but if there is a potential issue on hatchling's side, I thought you'd want to know.
commented
Hi
https://hatch.pypa.io/1.13/cli/about/ only gives general information about using Hatch's CLI. On the main page, it's linked as "CLI reference"; so I expected to see a list of all the subcommands that can be typed after hatch on the command line.
It links to the primary page where you can then get to the reference page that shows the CLI commands. We can reword the home page link to not say CLI Reference to avoid confusion. There is likely some improvements that can be made here to reorganize the CLI docs a bit better.
ah, that's the link labeled "root options"?
also, the "config file" referred to in documentation for hatch config... is that pyproject.toml or just what
ah no, I guess that's what hatch project is for.
https://hatch.pypa.io/1.13/cli/reference/ is all of the hatch commands reference.
Iโm stoked for dependency group support! Whatโs the plan for the next release?
The next release is happening next week and will include dependency group support, workspace support, adding 3.14 and dropping 3.9, and support for writing sboms to wheels.
That is awesome
I expect the release to happen tomorrow or Wednesday. I will share this here because it is going out in the blog post associated with the release. For anyone that did not know, I am taking on the responsibility of co-maintainer along with Ofek. I am here to hopefully reduce the burden on Ofek as much as I can. After this release, we will be working on something in the form of a roadmap for additional features to come including a typing command similar to hatch fmt and certainly implementing any additional PEP standards that might be missing from hatch and hatchling. I also want to thank everyone for their patience as I held up some changes due to the nature of the workspace changes and how big they were.
Iโve got it on my list to work on free-threaded CI for hatch this week now that the zstandard dependency PR is merged
For anyone that did not know, I am taking on the responsibility of co-maintainer along with Ofek.
I didn't know explicitly, but somehow, I sort of guessed... ๐
Fantastic to hear! Fewer single points of failure, hopefully less stress and burnout risk, etc. All the good things! ๐
thank you!
it's by no means urgent (although I usually close year-old PRs and its first birthday is tomorrow ๐), but I'd like to suggest my PR that adds a user agent header:
Let me try to get this rebased and reviewed today to try to include it.
Really glad to hear this @hoary wraith , and of course major kudos to @umbral bridge for all the work on Hatch so far. It's difficult being a sole maintainer, especially of such a popular project. I'm really looking forward to the new release, a roadmap, and a bright future for such a great tool. Thank you both.
This made it into the release as well. Release will be happening tomorrow morning sometime Pacific Time.
Hatch 1.16 and Hatchling 1.28 have been released! Thank you to @ofek for all the help on the release and reviewing all the code I put out. Thank you also to the other contributors that have helped add features and changes!
I posted on the forums https://discuss.python.org/t/hatch-v1-16-0-workspaces-dependency-groups-and-sboms/105099
Heads up that starting this evening I'll be off the computer for several days on a trip and will return Sunday evening.
Enjoy the time away!
Thanks Cary! It's difficult to express how appreciative I am of you unblocking development for us. Nobody knows this really but the state of the project has imposed a certain cognitive overhead that I feel at every moment of every day. It's like when you know you have to respond to emails, but so much worse lol. Now I feel better and am super excited to continue development ๐
Bug fixes are out for Hatch with the release of 1.16.1 to address regressions that occurred around context variable usage in dependencies, special character paths and adding support for dependency-groups to option overrides.
Fastest fix in the west โค๏ธ
And itโs on conda-forge now. 1.14.1 -> 1.16.1. ๐ณ Now finally using a ratter-build recipe, too.
see https://github.com/pypa/hatch/pull/2125 - I'd appreciate it if a maintainer could run the CI for that PR.
Done!
Quick bug report: it seems hatch 1.16 is not installing local extras, both in classic and dependency-group from. In repo-review, I had an environment that was self-depending on "repo-review[cli]", but hatch 1.16 stopped including the cli extra. Moving to dependency-groups didn't change anything. Adding the dependency what is part of that extra manually to the dependency-group does fix hatch's environment.
This commit, https://github.com/scientific-python/repo-review/pull/296/commits/5ab2ec5684d246f351b537118ea81606e922dd87, should not be required, but it fixes hatch 1.16 (uv is fine).
Which version of Hatchling?
Last working build was last week (with 1.15.1), so I'd guess 1.26.3 vs. 1.28, though I think this would be in Hatch?
[tool.hatch.envs.docs]
# duplicated since hatch doesn't support groups yet
dependencies = [
"repo-review[cli]",
"sphinx >=4.0",
...
]
Basically stopped installing the cli extras when building docs.
Part of the changes that were pending on master for over a year include migrating some utilities from Hatchling so that it isn't required at runtime (not there yet) and I'm not sure if this would be related to config parsing over there or now Hatch
Does this happen in 1.16.1 and 1.16.0? Just want to confirm which version as I have a potential idea of the issue but it would likely only exist in 1.16.1 if it is what I am thinking it might be.
I think I have this isolated to a change that was made for workspace environments that might be incorrectly filtering out these extras for the local extras case.
There is an official issue now https://github.com/pypa/hatch/issues/2126
PR to fix https://github.com/pypa/hatch/pull/2127
Is this released? Seems severe
doing this now, sorry!
Thank you so much!
I'd like to set up downstream testing for hatch and/or hatchling in packaging. I need to be able to run pytest directly in a nox environment. It would be nice if hatch had dependency-groups, so I could just do -e. --group=test for it. And I'm not sure what plugins are actually required for hatch, since some of them are not listed expliclity in extra-dependencies. And a lot of failures are popping up. How should I go about that?
elif project == "hatch":
session.install("-e.", "pytest", "filelock", "flit-core", "trustme", "editables")
session.run("pytest")
Build requirement is a bit old here, by the way, we are on 1.4 now: https://github.com/pypa/hatch/blob/e33e232b60aaafb9d11d342206e849d4f8b967e0/hatch.toml#L92
We can certainly move to dependency-groups now that they are supported within hatch itself. The extra things that get installed when running hatch test can be found here https://github.com/pypa/hatch/blob/master/src/hatch/env/internal/test.py
Uhoh, hatch noticed ._version has been removed.
Changing the internal _version tuple then reassigning it is very much not supported! Version objects are not mutable. That's part of why ._version used to exist.
I think the other failures are issues with the setup, but this one very much is something that will break with packaging 26.0
Is there an issue you found?
I'm not sure how bad the breakage is, but it breaks some of the tests in hatch.
I've got a backwards compatibility patch, not sure if I should introduce warnings now or in the next release, though (in packaging)
I've played around with this, this breaks the hatch version CLI, that is used to bump versions of a project
Look like the new __replace__ method would be a great fit for the code here
I don't see any reason to wait on adding a warning, only delay situations we don't know about from finding out it's going to be removed
I can run the tests directly from hatch (not sure what I need to do to get it working in our downstream version), with the patch, I think the rest of the failing tests are due to the space with @
I was assuming something in hatchling would break, since it's in the hatchling source, that's good if it's only a CLI breakage
Yes, this is basically an implementation of __replace__
Fixes for hatch: https://github.com/pypa/hatch/pull/2159
@elder lotus Do you know why the license file helper needed whitespace changes? I think I noticed that but didn't look into why.
The spdx vendoring changed the newlines in the license I believe
Hatch 1.16.3 is now released! This fixes issues with dependency-groups and the builder=true workaround. This also adds a feature that deletes environments when an exception happens during the creation of the environment. https://github.com/pypa/hatch/releases/tag/hatch-v1.16.3
Awesome! I think thereโs a slight mistake in the 1.16.3 release notes, as this change was already in 1.16.2:
Fix issue with self-referential dependencies not being recognized (https://github.com/pypa/hatch/pull/2127)
The dependency groups fix in 1.16.3 was
Allow dependency groups in builder and non-dev envs (https://github.com/pypa/hatch/pull/2155)
Packaging 26's spacing change broke the tests, so https://github.com/conda-forge/hatch-feedstock/pull/44 fails
I think I can just limit packaging for the tests to get this in, but it would be really nice if the tests could pass with packaging 26 ๐
I am going to take a look at the spacing changes that broke tests sometime this weekend.
My PR fixes them btw: https://github.com/pypa/hatch/pull/2159
If you want me to split out the warning fixes and test fixes into separate PRs, happy to do so
Just merged your PR ๐ Thanks for being proactive on helping us fix that!
hi! we've recently put up PEP 817 "wheel variants", which extends the wheel standard to support things such as GPU detection (pip install torch that picks the right CUDA version) and CPU extensions. i wanted to ask you as hatch maintainers if you have feedback on the proposal: https://discuss.python.org/t/pep-817-wheel-variants-beyond-platform-tags/105860
it would be valuable for us to have more voices on the proposal than just uv and pip
I am going to gather my thoughts on the PEP this weekend from the hatch perspective. I think Jonathan and others know my primary stance already as Henry, myself and some Nvidia folks at Scipy 2025 had discussions around security concerns at the time of arbitrary code execution and that does still seem to be present in some ways.
highly appreciated! based on that feedback in the first round, we've redone the security model in this iteration: the tl;dr is that untrusted code must never run without opt-in, while tools vendor trusted providers (say having GPU detection for a pypa-org library, something to hash out after the technical proposal) so that opt-in is not necessary for let's a <tool> install torch (avoiding security fatigue). there seems to be some confusion about what this means for tools, so we appreciate feedback on what we need to explain better (or what you'd rather do different).
There is a lot to digest with that PEP so these are just initial thoughts while I work on a more coherent reply to go into DPO after Ofek and I align.
I think my concerns around provenance being potentially broken by encouraging that tools vendor plugin providers have mostly been already surfaced by others in DPO. I think I am most ammenable to VariantLib providing the list of trusted providers through it as declared dependencies. Vendoring these things breaks provenance. This is less of a hatch issue here and more of me putting on my security hat as the person that is responsible for ensuring a healthy Python ecosystem at Amazon. Vendoring risks provenance for me in one key area and that is tainted code and hidden changes. If code is copied into the vendor directory without clear documentation of its origin (e.g., version number, commit hash, original repository), it becomes hard to verify if the code has been altered or contains malicious additions.( I am happy to have Seth tell me I am wrong here if I am) And I do not see the PEP taking a clear stance to say if a tool chooses to vendor that they must maintain provenance. Perhaps the PEP is not the right place for taking that stance but that just sticks out to me as where I see some concerns.
From the build backend perspective I do not see anything that sticks out as problematic. From the hatchling perspective we are likely going to push
They SHOULD also query providers to determine whether variant properties requested by the user are valid, though they MAY permit skipping this verification and therefore emitting variant wheels with potentially unknown properties.
as being build hook plugins that a user can choose to use. There are too many variables for this for hatchling to provide good defaults out of the box. This would also remove hatchling from the middle of the trust relationship here. Providers here should be who the users trust on checking for valid properties.
I do agree that there needs to be a balance to avoid security fatigue occurring when it comes to the opt-in mechanism of provider plugins.
A lot of what is in this PEP are things that we generally defer to package managers already on the install side for hatch. So I would defer to you and the other uv folks as well as Paul and others on the pip side to have more meaningful input on that side of the PEP.
One thing of note, and this was provided as feedback on https://github.com/pypa/hatch/pull/2037 and my hope here is that the intention is that these are going to live in VariantLib. Otherwise I have a lot of concerns here about drift between tools.
thanks, i've shared the feedback with the other PEP authors
Thanks! Hopefully it all makes sense, I know the DPO has sort of gone in a bunch of different directions and some people are really digging in on certain aspects. That is not my intention with my feedback just where I see some potential concerns. I do think the security aspect might be getting blown a little out of proportion in DPO because the reality is that there really should only be a small number of trusted publisher plugins in terms of namespaces as those should be based on hardware vendors. Which is why I think having them as dependencies of VariantLib is an appropriate move and then for any untrusted plugins those can be opt-in by users that need them. It is a model that works well with us for hatch.
would love to get feedback directionally on this from others https://github.com/pypa/hatch/pull/2174
Happy to! I think in the future, the main way to do lockfiles shoule be declaratively, using a per-env locked = true setting or so. This makes it possible to keep the PR almost as it is, but Iโd probably rename the -o/--output option to --export and make it mandatory for now so itโs clear that hatch doesnโt use that lockfile yet when creating or syncing environments. More details in my comment on the PR.
Thanks! That was the other direction I was leaning was being declarative per environment because i do think that is more flexible so i think with that feedback that is the right way to go now. And that also allows this to happen during different commands, while working on this draft PR the thing that kept coming to mind is having a sync command for environments.
The missing sync command was weird, I always did hatch run <envname>:true or so
Hatch 1.16.4 and hatchling 1.29.0 have been released. https://github.com/pypa/hatch/releases
yay! thank you!
FYI: the lockfile PR got closed by you deleting your personal fork: https://github.com/pypa/hatch/pull/2174#event-23009745689
I know, my fork got into a weird state so I had to do that to get the release out. I still have all that code locally and can get it onto the new fork pretty easily. I should have a new PR for that out this week as I would like to get lockfile support ready to go.
hey
the PR for the fix with virtual env has failed on what looks like an unrelated issue
@dull rapids
yeah, I think we need @hoary wraith or @umbral bridge to restart them or fix them on main.
what timezone are they in?
idk, but @umbral bridge is online rn
I am in Pacific Time and just getting my morning started. I have restarted the tests and will be reviewing the PR shortly. I have been working on a fix for those tests already but put them on hold while we were making changes to the release process and releasing the latest release.
Hey, let me know how I can help
looks like it just merged. Thanks a lot!
PR is merged. I have. a few meetings this morning and then I can get to a release
Release is happening now. Sorry for the delays but now the issue with the publish tests failing intermittently is fixed ๐
I'm seeing some odd behavior when making a copy of a repo (in a test): building an SDist in that repo copy doesn't respect the .gitignore anymore, uv.lock is being included in the SDist. Git is working correctly and does not show uv.lock. I don't see any difference between the two directory trees other than some extended attributes didn't get copied.
(I'm trying to fix the test suite for check-sdist to work in parallel)
It has something to do with being in the pytest temporary directory
Found it with GPT-5.3-Codex. It reads the .gitignore, then starts processing the ignores, and comes across var/ pattern caused hatchling to think the entire project dir is being ignored. Then it throws out the rest of the ignores after that, since now it thinks everything is being ignored, and goes back to the default ignores.
I don't think it should be checking absolute paths, but only relative paths to the repo. Git itself works fine if you ignore var/ but have a var in the path to the repo itself.
The same thing could be triggered by putting the repo in a build directory, since build/ is also a common ignore.
Unrelated: hatchling seems to be normalizing version everywhere, when it should only be normalized for wheel/sdist names. The metadata should contain the exact version the user inputted, like 2026.03.03, so PyPI displays the correct version, just like the way names work now (normalized name for SDist/wheel, unormalized name for metadata and PyPI display). We might be adding a property to packaging.version.Version to make it a little easier, but when I was looking around for this bug, it seems like strings are passed around most places, so it should be easy to fix, I think.
(People have been complaining about git tags not matching PyPI versions for CalVer, and I'm pretty sure this would be enough to fix that)
(I can open issues but I haven't worked that latter one out fully to know if it does get displayed correctly if the metadata is fixed)
The first problem could be a security issue when making SDists, actually. It means I can change what files are included in the SDist simply by moving the repo into a path with a specific name, removing the ability of the author to control what files get excluded in the SDist.
@errant timber I will try to take a look at these this week. Feel free to open issues even if the latter one is not fully worked out. I will have enough context here to at least know the shape of the problem to dig into it.
As mentioned in #general, I have a beta release ready for the Hatch Code extension: https://github.com/flying-sheep/hatch-code/releases/tag/v0.1.1
Please try it out!
psa: i beleive im finally finished with the iteration on setuptools-scm 10 and vcs-versioning 1 - my next step on that front would be to add more api in vcs-versioning to make hatch-vcs work nice and idrectly with it (no more setuptools)
looks neat, i presume it also works on vscode derivates?
Iโd hope so, but if it doesnโt, pleae tell me which one it fails on!
i sheduled trying it on cursor for next week (i use cursor at work)
Awesome. Of course the packager had a bug and I needed to push a new release, so make sure to try 0.1.1!
Does hatch not work if there's not a python command? I've only got python3 on this mac, just tried brew and uv tool installs for hatch, both crash with FileNotFoundError on python. I'm trying to do hatch run docs:serve, and my command is just sphinx-autodocs (it's failing setting up the dependency-groups). Maybe I'm doing something wrong, though.
hatch run --help's formatting is wrong for one of the toml blocks, too.
Opened an issue and PR for the latter
uv run hatch run types:check is fine. Thinking it might be a cache issue
hatch clean
/Users/henryfs/Library/Application Support/hatch/env/virtual/repo-review/bd7TtdJB/hatch-build/lib/python3.14/site-packages/vcs_versioning/overrides.py:609: UserWarning: No GlobalOverrides context is active. Auto-creating one with SETUPTOOLS_SCM prefix for backwards compatibility. Consider using 'with GlobalOverrides.from_env("YOUR_TOOL"):' explicitly.
return get_active_overrides().subprocess_timeout
(That's from the hatch-vcs plugin and setuptools-scm's newst release, I think)
This is the command it's trying to run:
['python', '-W', 'ignore', '-'] {'capture_output': True, 'input': b"import os\nimport platform\nimport sys\n\nif hasattr(sys, 'implementation'):\n info = sys.implementation.version\n iver =
'{0.major}.{0.minor}.{0.micro}'.format(info)\n kind = info.releaselevel\n if kind != 'final':\n iver += kind[0] + str(info.serial)\n implementation_name = sys.implementation.name\nelse:\n iver
= '0'\n implementation_name = ''\n\nenvironment = {\n 'implementation_name': implementation_name,\n 'implementation_version': iver,\n 'os_name': os.name,\n 'platform_machine': platform.machine(),\n
'platform_python_implementation': platform.python_implementation(),\n 'platform_release': platform.release(),\n 'platform_system': platform.system(),\n 'platform_version': platform.version(),\n
'python_full_version': platform.python_version(),\n 'python_version': '.'.join(platform.python_version_tuple()[:2]),\n 'sys_platform': sys.platform,\n}\nsys_path = [path for path in sys.path if
path]\n\nprint({'environment': environment, 'sys_path': sys_path})\n"}
I think this is from src/hatch/utils/env.py:23. It's hardcoded to "python". Works better if I change the default to "python3" or sys.executable. Works if I change that.
PR for the help portion is merged. I will take a look at a fix for the python command issue.
the warnign will get a resolution soon
I have just merged lockfile support in hatch per environment, I would love for others to test it out and provide feedback for it before it is released!
I've noticed hatchling does not ignore the .git file (note: not directory) that git worktree's use, it adds it to the SDist. https://github.com/scikit-build/scikit-build-core/pull/1280
Post PyCon the next release will have this fixed.
One limitation I should have added to the readme: the Ruff and ty extensions donโt support the new API yet, making things really clanky until this is released: https://github.com/astral-sh/ty-vscode/pull/406
I wanted to make it easy to find me and chat at PyCon my schedule is
Arrive Tuesday afternoon and am free until Thursday for anyone who is early that wants to chat.
Thursday - Typing Summit and opening reception
Friday - Morning at AWS booth, afternoon Packaging Summit
Saturday - Morning at AWS booth, afternoon Maintainers Summit
Sunday- attending talks and open to discussions
Monday - dev sprint for Hatch
oO did i miss the dev sprint for hatch
There was; though I didn't actually do anything while I was there other than build goodwill with Cary. ๐
I didn't realize you were at PyCon -- another missed opportunity (for me at least). Such things happen.
Same! It was nice to see @humble smelt and @hoary wraith at the sprints. I didn't get as far as I'd hoped with workspaces on my project, but that's okay. My TL;DR was that it makes no sense to have a pyproject.toml at the top level, so I'm working on converting that to a hatch.toml. Definitely something to think about on the journey for standardizing workspaces.
I always imagined that we'd have pyproject.toml at the root, FWIW, but with no [project] table. (I'm not sure if that's where we'll really end up.)
So after chatting with Zanie, that is what they do actually in uv is that you just do not have a [project] table for the top level pyproject.toml I think that is probably the best way to go Barry. I would be curious if when you do that, does the hatch build --all work for you.
I indeed did host a sprint on Monday and we got some first time contributors. It was great to hang out and chat with @humble smelt @orchid birch and others. I am very excited for the rest of this year in the packaging space with hatch.
We expect a new release in the next week! What is in the release? We will be delivering pylock.toml support per environment, fixing a few bugs, and the one I am most excited about is we are reconfiguring our commands. We are introducing hatch check as a command and will in the future retire hatch fmt. The check command will have sub commands for type checks with pyrefly, and splitting out the linting and formatting commands with ruff. This will allow us to be more resilent with adding future sub commands. For those that want mypy or ty that is still possible with creating your own type checking environment but we believe that pyrefly offers a good experience without requiring us to maintain a list of configurations to apply. Minimally we only need to tell Pyrefly the search paths.
I think it did not, but that's also fine with me. We already have concensus on pyproject.toml so one without a [project] table makes sense. I'll continue down that path and see how far I can get.
Let me know! I am going to pull your projects down and test on my end as well and see what is missing to make them build with the changes I have in that PR or fix that PR to ensure that your projects can build.
There are use cases for having the workspace root be an actual project too ๐คทโโ๏ธ it varies.
(uv supports either way)
We support the workspace root being an actual project right now but we do not support the other way right now of not having the workspace root as a project.
I will be getting back to fixing that maybe tomorrow. I already have a lot of other irons in the fire tonight with refactoring to the hatch check command group.
I can see it either way. In the use case I've been playing with, the workspace root is not a project; both projects live in sub-packages. I may not get back to this until next week but it sounds like with the upcoming hatch release for check that'll be fine.
I pushed changes Barry that should fix the issue, I have added several tests to make sure that it should work the way you have things setup. It should now support both with and without the top level pyproject.tom; having a [project] table defined. ๐
This is literally the Hatch repository; Hatchling is both a dependency and workspace member.
That's how I've constructed nab, I didn't spend a lot of time thinking about it though, just seemed a natural fit
1.0.0 is released https://news.ycombinator.com/item?id=31190027
woo!
One question: How does hatchling detect packages? if you have your package as src/project_name, itโll just workโข, but what if the PyPI name and module name diverge? What if one doesnโt use the src layout but just has the package next to pyproject.toml?
One thing I find could be improved is the separation between hatch and hatchling in the documentation ๐ค
For people who want to use hatchling but prefer e.g. tox for environment set-up and management
I should add a tutorials tab, ty I'll work on this
wrote a bit more here https://discuss.python.org/t/hatch-1-0-0-is-available/15359
Congrats on the release.
@umbral bridge awesome, wish I was further along with setuptools_scm, it may take me mid May before I can mix the vcs plugin up
@umbral bridge do you plan to propose hatch for adoption to pypa, considering the existence of this chat ๐
I'd +1 it, especially the hatchling part of it ๐ช
Approved Ofek Lev to pypa-committers
thanks!
Technically shouldn't we only do that past the vote to pass? ๐ค
PEP-609 says at least so
Can always remove
oop I pressed subscribe, didn't realize it was a special list
If hatch does not pass โฆ
I voted for it, so I'm not against it, just noted that the bylaws were not followed ๐
as Paul requested: https://discuss.python.org/t/hatch-1-0-0-is-available/15359/2
@umbral bridge aware of anything to ease migrating a setuptools using project to hatch?
@umbral bridge could this be integrated into hatch init --new
(i have about 70 repos i want to migrate from setuptools+setuptools_scm to hatch
it's not perfect (cannot be) so I'm hesitant to
what im looking for is not perfect, but safe 10-15 minutes transcoding setup.cfg to pyprject.toml then fix the rest (im happy with a command name that indicates its only trying, practically most metadata should transfer relatively safely
plus its fair game if it prints a red "warnining, best effort, validation necessary" ^^
ok, I will
๐
mind a separate entry point? hatch-migrate <PATH>
thats fine as well
nice, ty
@umbral bridge oh, and for something completely else - would it be thinkable/possible to have a editable install of the current package for builds, im trying to figure self-bootstrap of setuptools_scm
[build-system]
backend-path = ['src'] # or ['.']
?
@umbral bridge but if hatch + hatch-vcs was in use - wouldnt it pull in the transtive setuptools_scm dependency of hatch-vcs as well
(btw, im still in the middle of full git archive support there - i introduced a regression there that im fixing now)
Looks like it's time to move this channel up a category. ๐
Indeed ๐
Did that work? I tried dragging it up
yes
@umbral bridge you'll need to liason with @dusty obsidian, @elfin crater or @sick jolt AFAIK to make the transfer
Yeah I donโt haz those powers unfortunately
Dustin, Donald and Paul Moore are the only ones then
transferred!
Cool
yay CI secrets persisted
https://hatch.pypa.io/latest/ is all set up thanks to @elfin crater
That was fun trying to remember how all this stuff was setup ๐
... is any of it documented? I presume the answer is no :p
Update project links and remove monetization https://github.com/pypa/hatch/pull/223
Ee and Donald are the only folks who can do that.
Is there more than a DNS update + a RTD admin update?
well there used to be a Fastly thing
that is still setup
but not receiving traffic
so that waylaid me ๐
Hehe
Maybe bullet point out the process and we store it somewhere โฆ
- invite owner of repo to
pypaso they can transfer (if no longer wishes to maintain transfer to member ofpypa) - transfer to
pypa(might take a few minutes) - make teams:
@<PROJECT>-team-> Triage
@<PROJECT>-committers-> Write
@<PROJECT>-maintainers-> Maintain
@<PROJECT>-administrators-> Admin - for projects that were using GitHub Pages, on
https://github.com/pypa/<REPO>/settings/pagesset custom domain to<REPO>.pypa.io(for RTD no idea)
@mint bramble I'm implementing substitutions similar to tox like {env:KEY:DEFAULT} today... it's not very fun lol
Nesting/recursion can be fun to handle
I was originally trying out hacky REs but now I'm using https://docs.python.org/3/library/string.html#custom-string-formatting
tox uses regexes
Not sure if this string formatting supports nesting ๐คทโโ๏ธ
I'd be surprised if it does
someone should update the channel topic lol
@karmic glacier what would you suggest?
pypa/hatch :P
it is, no?
likely
can you send a screenshot of it, I can report this as a bug
@tropic void did you happen to start writing that plugin?
context?
still pretty much delayed - stil lhavent ifinished the git archive full support pr and the upcoming changes
@mint bramble here's what I ended up with (will be in 1.1.0) https://hatch.pypa.io/dev/config/environment/#context-formatting
๐ looks alright, even though I only use hatchling for now ๐
https://github.com/pypa/hatch/releases/tag/hatch-v1.1.0
Add ability for the
--initflag of thenewcommand to automatically migratesetuptoolsconfiguration
Yeeha, going to try right now
@umbral bridge first error is Could not automatically migrate from setuptools: [Errno 18] Invalid cross-device link: '/tmp/tmpxvbrbdlv/repo/pyproject.toml' -> '/home/ronny/Projects/${redacted}/pyproject.toml'
๐ฆ
I'll fix os.replace after lunch...
I guess:
def replace_file(src, dst):
try:
os.replace(src, dst)
# Happens when on different filesystems like /tmp or caused by layering in containers
except OSError:
shutil.copy2(src, dst)
os.remove(src)
yikes, that one is a really painful
why not use move?
shutil.move implements what you wrote
@umbral bridge actually, why not use use copyfile from shutil, the temporary directory will go away anyway
oh, yes to both. ty
@umbral bridge what type of system do you run that this didnt break the world? (for all my systems, tmpfs for tmp would break normal operations, but a pytest tmppath caveat exists
Windows
@umbral bridge works, i'll add some extra setuptools_scm detection next week, ๐
@tropic void it does that a bit already ๐
its missing raw tool.setuptools_scm sections as far as i can tell
(i just tried it in apipkg)
@umbral bridge would it be possible toset hatch up, so that it could generate signed tags which include verifiable signatures for the expected wheels
the idea being that when a tag for a release is added by a user, it could be added in a way that includes the signatures of reproducible artifacts that will publish,, and then a publish would fail if the signature wont match
like ship in wheel?
extra-metadata https://hatch.pypa.io/latest/plugins/builder/#options
@umbral bridge no- more like when i tell it to tag a release, build a wheel for that release - and then use git tag --sign -m "pypkg-version.whl gpg-signature", so that on the ci, hatch build can fail if the signature on the tag doest match
Hatch/Hatchling doesn't do any tagging
ok, then i suppose a plugin that fails to build of the crypto hash of a artifact is not noted on the build
fyi Jupyter is switching their build tooling to Hatchling ๐ https://github.com/jupyter/jupyter-packaging/issues/145
oh they've already begun lol scroll to the last half of https://github.com/pypa/pip/issues/11110
hmm, would it be too evil to make zerg memes around hatch?
congrats on v1 :)
Ah, itโs very nice! Compared to flit, the only things I have to mind are
- Specify
tool.hatch.build.targets.wheel.packages = ['src/mypackage']to avoid having accidental inclusions in the wheel (liketests/*,docs/conf.py) - I have to manually set
description, which means the same sentence now needs to go intopyproject.toml,__init__.py,README.rstand the GitHub repo description (one place more than before)
It would be great if the first one would be visible prominently in every tutorial (@umbral bridge @errant timber), Iโd like to avoid seeing PyPI packages shipping their tests folder and my PyCharm jumping into some random packageโs tests folder when I start debugging instead of my tests.
This is especially important because pip still doesnโt even warn when it clobbers files: https://github.com/pypa/pip/issues/4625
Tests and docs should not show up in wheels, but they should show up in SDists. It's a really easy and really bad mistake to make, so some default filtering is almost always applied. The very least (no non-package paths in the wheel) is okay, though tests often have an __init__.py.
It's important for me to make sure all tutorials do the right thing by default without configuration so that one tutorial (scikit-hep.org/developer, packaging.python.org) will work for all backends. Also so that scikit-hep/cookie will work with all 11 backends with minimal per-backend fiddling. Also for user experience.
Setuptools used to have issues with including the tests folder, I think it is manually ignored nowadays
That sounds right, @dull rapids are you sure docs and tests are getting added to wheels?
The docs, and other stuff, because this is hit:
- Otherwise, every Python package and file that does not start with the word test will be included
because the package name doesnโt match the distribution name.
But of course that lessens my concerns a lot since for most packages, names should be the same. Sorry for being alarmist ๐
with a src layout its reasonably safe i would say
docs doesn't usually have an __init__.py, tests is the one that might have one
And yes, matching package & distribution name should be the default for most
new docs: https://hatch.pypa.io/latest/config/context/
new features:
- https://hatch.pypa.io/latest/config/environment/#context-formatting
- relative path support due to ^ https://hatch.pypa.io/latest/config/dependency/#local
argskey https://hatch.pypa.io/latest/config/hatch/#shell
@umbral bridge it might be nice to error out with unknown setup.py sections (like flake8 or isort) i missed the drop of one of those much to the complaints of the ci system ;P - its probably something i can work on later this week
what dropped?
the setup.cfg had a flake8 section which configured flake8, hatch migrate killed that
@tropic void setup.cfg doesn't get written to
hmm, then i suppose its human error on me all the way ๐คฆ
Complete laziness question, but is there a migration guide somewhere
I.e. a page that says "here's how you migrate a project to hatch"
Ah amazing, thank you!
Is there a setuptools-scm equivalent for hatch
The version page (https://hatch.pypa.io/latest/version/) looks like it only covers regex pattern matching
Modern, extensible Python project management
Thanks!
Hooray, pretty painless I think. https://github.com/python-jsonschema/jsonschema/pull/957. Now to wait for CI.
(Even including that I hadn't been using PEP 621)
Do I still want to use build or should I use hatch to build in CI.. I guess the former still, I want to make sure folks can build with whatever thing.
@umbral bridge whats the recommended way to run more than one commands of a script section of a environment?
example?
i have a env that has a mypy and a pytest script - i want to run both of them in a single command
@umbral bridge it would help the docs to have that example, i went into my shell way of trying to use a ; in the string ^^
hmm, ok, this indicates that my brain juice for today is utterly depleted - i was searching for that there for a while and completely missed it,, calling it a night
np ๐
thanks, and great work, im slowly replacing all my personal tox usages with much nicer hatch usage
aww thanks! I'm actually quite proud of what I came up with for environments so that means a lot
Why / how?
I was just considering the same thing (so legitimate question)
(+1 on hatch being really nice though, just pushed the first release of jsonschema which uses it so T-X seconds till I get the first user complaining they can't find a setup.py file)
But yeah how are you replacing tox?
@golden merlin hatch envs as linked above are basicall tox environments on steroids (it can do pretty much all the things tox couldnt do nice because of ini files and matrix expansion > factors
OK, I haven't read enough I suppose, I didn't know it can do the latter
(matrix)
Ah. I see it now.
OK my tox.ini's are typically... elaborate so will give it a shot, I want to see which is faster probably.
@golden merlin one big difference is that whereas in tox envs are "executable", in Hatch you aren't limited to a given command set. so:
tox -e style
tox -e fmt
vs 1 env:
hatch run lint:style
hatch run lint:fmt
aha, ok, nice
and there's I think I see a way that corresponds to running tox bare?
I.e. "run all of a set of environments"
not an OOTB way no, the paradigm is just different
i.e. in CI I want steps broken into logical units
not 1 "do-all-the-things" step
hm, but then how does one do "run all the things that I want to pass to know this thing works"
if you have an env or matrix for testing called test:
hatch run test:all
[envs.test.scripts]
foo = "pytest"
bar = [
"foo",
"baz",
]
all = [
"bar",
"...",
]
ok cool yeah that's what I meant by "I think I see something matching tox bare" it was yeah "put all that in one environment" ๐ -- good, will give it a shot, thanks
I want to see which is faster probably
Hatch is, but haven't tested tox4
@golden merlin a cool test might be:
hatch run test:python -c "import sys;print(sys.executable)"
[envs.test.overrides]
env.HERMETIC_TESTS.type = [
{ value = "container", if = ["true"] },
"virtual",
]
[[envs.test.matrix]]
python = ["37", "38", "39", "310", "311"]
then run again to see the speed
then pip install hatch-container & set env var HERMETIC_TESTS=true and run again
nice, ok will give that a shot tomorrow then, thanks for the tips!
@umbral bridge any idea how to make pycharm aware o f hatch envs?
or from https://hatch.pypa.io/latest/plugins/environment/#virtual, could try HATCH_ENV_TYPE_VIRTUAL_PATH env var for exact path (maybe to share)
Likely they'd be equal, though true env sharing hatch might be a bit faster due to less stuff to install.
the dep sync check is faster in Hatch but dunno why
That shouldn't be the case in tox 4
why? ๐
Also in tox 4 you can switch to install the wheel over sdist Speeding up even more
What do you define exactly as dep sync?
list of pep 508 strings is met + sync if not
tox 3 doesn't do that at all ๐ so guess it's faster
tox 4 does it though and uses prepare metadata for wheel to be fast-ish ๐
? it does [testenv.deps]
Well guess does it sometimes, but not for project install and extras
Only for deps
And if there's a diff recreates from scratch in tox 3
tox 4 installs only the diff if the dependencies are append only, if there's a remove needs to recreate as there's no good way how to know what to uninstall (e.g. transitive dependencies are not handled)
To be fair even additions only are not necessarily save to just install afterwards, as adding a new dependency might in theory invalidate the previously resolved dependencies in the pip solver
But as it's likely good enough 95% of time it allows it
pip solver does not consider the current installed packages when installing new packages
How does hatch handles package building, as far as communication with the backend and build environment?
just shells out to pip for env installs
I've invested a significant amount of time to make sure package building is fast as possible ๐ so wondering how hatch handles it
Guess then that's an area where tox 4 might be faster as tox reuses build environments and uses a persistent process to minimise process start-up time especially hard hitting on Windows
for builds i.e. hatch build Hatch does pickle-based RPC with Hatchling for colored text so Rich not needed
hatch can still gain advantage overall though due allowing env sharing, which tox doesn't do yet
90% of pip install time for the project will be pip recreating the isolated build environment and installing your build dependencies
true but only happens once, afterward just the defined deps are checked
After every code change you need to rebuild the artifact unless you're installing in editable mode, no?
no, user in charge of that
dev mode/editable is default
if disabled they chose that path
So for non editable mode, which is the true test env, you still need to rebuild/reinstall the project before every run, no?
yes if they want to, Hatch doesn't manage that
IMHO editable mode differs to much from normal mode to be default to be a reliable validation env, I view it more a unit test, where normal mode is the true integration test
After all your lib users will do normal installs not editable ๐คทโโ๏ธ guess there's a difference of philosophy between projects here ๐
Have a talk about all the times it's not ๐ https://twitter.com/gjbernat/status/1529136305988374532?t=QJIPhjQWs5hvpGfUvZcbhQ
esp. since the main old issue was setuptools config was just easy to mess up
Still it's probably still 90% of time probably close enough ๐
As long as you require hatchling as backend for hatch, and there's no fancy import hook logic active for the project
@umbral bridge i think the issue is that pycharm would need a plugin to know hatch envs like tox envs or normal venvs
hmm
oh, lovely, hatch is in recent fedora
I gave up on tox's installation process a few (many?) years ago -- I'm sure it improved since then but yeah I always turn it off. Let's see if I get similarly frustrated if hatch does the same.
(the behavior I always want is "locally should always reinstall from scratch fully, CI should always reinstall from scratch but I want to restore a wheel cache each time")
locally should always reinstall from scratch
for every change?
yes, think so, but will see what my workflow becomes for hatch
if I don't want that, I run my test runner
(if I'm running tox, or hatch, it's because I want to run everything, and not rely on some state)
@umbral bridge any plans for parallel running of environments ?
Ability to parallelize command execution in multiple environments, I want it to be pretty and have an interactive option to expand to full size output based on keypresses so you can check on the progress of any at will
ah, lovely, i suppose this will need textual and subprocess protocols + ptys ? (and pain)
yes, much pain
@umbral bridge perhpas its a valid strategy to convince textual into providing tabs and sub terminals" then the parallel mode can open up a main tab, and hide the rest away in other tabs one can click on,
tox 4 also wants/needs to deal with that much pain
hi! i just found out about hatch (out of left field!) and it got me salivating. it's like everything i want from poetry plus tox and vcs integration on top ๐ฎ also cibuildwheel integration, woah. i tried to init it on https://github.com/fonttools/fonttools/ and it crashes though because it can't find fontTools/__init__.py for version determination. can't figure this one out... to repro, clone the repo and do hatch new --init && hatch env create
if you want to use the setuptools_scm integration via the hatch_vcs hook, then it also wont need the file for finding the version anymore
also please create a draft pr with the changes so its directly visible
i want that eventually, but for now i'm just playing around. the project currently uses the bump2version approach to versioning so i wanted to keep it until i'm more familiar with hatch. ok, will do after i have set something up ๐
@umbral bridge i have a feature request - can we create something that provides the expected content hashes of artifacts for a release - i want to tag releases with a signed annotated tag that includes the expected output hashes of the reproducible artifacts
sure, what would that workflow look like exactly?
@umbral bridge bascially i would locally ask hatch to build the pacakges of a future release and then obtain content hashes/signatures
afterwards the target tag would be created as a signed/annotated tag containing the expected signatures/content hashes of the artifacts
then when pushing it to the ci/cd platform, the release process could gate on the signatures + do actual signed uploads
as far as im aware, apipkg will be the first package in pytest-dev to be turned hatch
ok, i have a test branch of the fonttools project up at https://github.com/daltonmaag/fonttools/tree/test-hatch, and the pr fails at the same point as locally: https://github.com/fonttools/fonttools/runs/6759103303?check_suite_focus=true#step:5:35 -- does anyone know what i'm doing wrong? pyproject file at https://github.com/daltonmaag/fonttools/blob/test-hatch/pyproject.toml
Did you try with Lib/fontTools/__init__.py on line 100 of pyproject.toml?
yep, no dice ๐ฆ
@rancid mesa are you sure you tried?
[tool.hatch.version]
path = "Lib/fontTools/__init__.py"
I think I found the issue. hatch doesn't like that the line starts version = __version__ = (i.e. sets both variables). The regex expects __version__ to be at the start of the line.
The regex is here: https://github.com/pypa/hatch/blob/05f17ca0fdc1e7bd899401d3d4261a3db135695b/backend/src/hatchling/version/source/regex.py#L6
i tried setting the regex before but same error
changing the line to read just __version__ = "4.33.4.dev0" still results in the same error
git clean -xdf && hatch env prune && hatch run test:test still gives the same error
also, funny: after the regex version thing fails, running hatch run test:test again results in "'test' is not recognized as an internal or external command, operable program or batch file.". i have to prune envs and try again
there is no test script
ah ๐ i haven't understood the tox/env stuff yet
this does work
__version__ = "4.33.4.dev0"
version = __version__
ah! it's the combination of Lib/fontTools/__init__.py plus your modification. thanks ๐ very misleading error though
& ty @spare vortex for finding out what the error was!
oh duh. i now realize that i was suffering from traceback blindness and didn't realize that i got a different error after changing the path. duh. sorry for the noise ๐ฌ
@umbral bridge is hatch using some sort of pretty traceback presentation (eg: rich's?)
pip's not using rich's tracebacks (except when you pass --debug which is mainly for debugging crashes). It's using rich-renderable error objects, which I should really factor out into a separate package at some point.
pip's PR was tedious because I needed to figure out how to plumb the rich exception presentation through logging without disrupting regular logging use. It was fine, otherwise. :)
Rich wasn't the hard part. :)
Is there something other than PEP 508 which specifies extras should be normalized?
I ask here because I have https://github.com/python-jsonschema/jsonschema/issues/962 from the hatch change, but indeed I'm specifying that as I was before: https://github.com/python-jsonschema/jsonschema/blob/b1c1d0082c4ebe1cce3631383c63e24233b8c311/pyproject.toml#L55 which pip won't install
Python Enhancement Proposals (PEPs)
Aha, thank you! /me reads
OK, so this is waiting on https://github.com/pypa/packaging/issues/526 essentially?
https://peps.python.org/pep-0685/ Normalize extra comparisons Update requirements.Requirement.extras to raise a warning when names clash Update docs for packaging.utils.canonical_name() #495 #383 M...
And there's not really anything I can do in the meantime it'd seem, given I'm already specifying it with the form it was specified in before, hatch is just following the guidance from 685 before pip is ready for it?
Er sorry probably it's build doing that in this case
whatever's happening I doubt build is involved
if the extra names are being normalised, then that's hatch doing that
yes I've implemented that pep
Ah bleh sorry it's confusing keeping it in my head
build builds my distributions
But it does that by calling out to hatch
So yeah thanks
(for unconfusing me)
@umbral bridge I ask not as a leading question but purely to inquire -- should hatch not do that until pip actually supports the PEP?
https://peps.python.org/pep-0685/#transition-plan I guess that describes this case
maybe I should've gated it on core metadata v2.3
but PyPI still doesn't accept v2.2 even
yeah that section to me says it's recommending pip should win right?
pip implementation should be prioritized yes
(filing an issue just for visiblity, hope that works?)
sure
@umbral bridge another feature detail came up - a good way to run commands of a environment in the current python to help replicate the test commands for packaging in say fedora which for example use tox --current-env to run the test commands against a installed package
context is apipkg restoring tox-ini to support the fedora packaging scripts in https://github.com/pytest-dev/apipkg/pull/41
I'll add a way
hi again! I'm struggling with excluding a certain feature for just pypy3 in a matrix. i have this snippet:
[tool.hatch.envs.test]
dependencies = [
"pytest",
# ...
]
features = [
"interpolatable",
"lxml",
# ...
]
[tool.hatch.envs.test.scripts]
cov = "pytest --cov-config=.coveragerc --cov"
no-cov = "pytest"
[[tool.hatch.envs.test.matrix]]
python = ["37", "38", "39", "310", "pypy3"]
i want to exclude the lxml feature when running under pypy3 because it just slows things down. i'm not sure what to do from reading https://hatch.pypa.io/latest/config/environment/#option-overrides... :/ or do i have to make a separate env?
Modern, extensible Python project management
@umbral bridge how would negative conditions apply as far as i understand the ask here is for something like
features = [
{ value= "lxml", platform = [{ not = "pypy"}]}
]
my dictionary programming language sense is mismatching braces
(i don't want to put the platform anti-specifier into the feature itself because maybe someone really wants to use the lxml feature on pypy for some reason, i just don't want to run the tests with it)
are there any examples building cython modules from hatch and having them tested in envs?
no support, but you can continue using setuptools with Hatch envs
ok, thanks ๐
how would negative conditions apply
@tropic void no support, yet
excluding a certain feature for just pypy3 in a matrix
@rancid mesa for now use https://hatch.pypa.io/1.2/config/environment/#overwriting:
[[tool.hatch.envs.test.matrix]]
python = [..., "pypy3"]
[tool.hatch.envs.test.overrides]
matrix.python.set-features = [
{ value = [ ... ], if = ["pypy3"] },
]
that works, thanks
what's the best way to use pinned deps for testing? i understand that a lockfile format is being fought over and the faq-listed pip PR is not merged yet. i'm primarily interested in tests not randomly breaking with updates when i haven't touched a project for a while (i also understand that this won't save me from having to move with my deps)
I'm not sure yet ๐ฆ
I've never been more happy I wrote a test https://github.com/pypa/hatch/runs/6869657871?check_suite_focus=true
wow os.stat is literally broken on Python 2 on Windows
fix for <1.0.0 line https://github.com/pypa/hatch/releases/tag/hatchling-v0.25.1
@umbral bridge im thinking of surrounding hatch/setuptools_scm with a set of github actions + plugins to facilitate
- proposed releases with something like towncrier/changelog integration + output of reproducible artifact hashes (intended use on pytest)
- triggering release proposals on milestone completion and/or bugfix merges/branches (also intended use on pytest)
- proposing commands that will ensure the target release tags are signed and include artifact signatures (i want to go all in on supply chain security, going to use this for hopefully > 100 internal and external projects)
i'd appreciate any input before i get to it starting mid week hopefully (first setuptools_scm regressions)
sounds cool, lmk if I can help at all
@umbral bridge before starting i'd like to get some input on possible issues you see, and how to best work with repeatable builds to suggest artifact hashes in pipeline + also what place to best check them
(the diea being that to do a pypi release a maintainer pushes a signed tag, which also includes artifact signatures, for the wheels, possibly even the signature that would go into the record
all of that seems possible with plugins and scripts
@umbral bridge ok, then im starting hopwfully this month ^^
@umbral bridge is there a way for hatch to build both mypyc wheels and non-mypyc wheels that i missed in the docs? (except for running twice with the different env vars
except for running twice with the different env vars
no
i have 2 use-cases here - a speed compare a mypyc lib versus a non-mypyc lib and publishing both types of wheel for broader consumption , im fine with a little script tho
@umbral bridge can environments be configured so different build settings are used ?
builds use separate env
i see, so matrix is probably not possibly easily and sanely,, so script it shal be
@umbral bridge could build variants be used as input to the option?
pep517 config_settings? no, env vars yes
@umbral bridge i meant https://hatch.pypa.io/latest/config/build/#versions
Modern, extensible Python project management
sorry, example?
@umbral bridge i was wondering if those could be used as way to enable/disable specific build hooks, also bbl, toddler needs me
@umbral bridge basically - its not clear to me how the versions thing of build targets works and i do wonder if i could use them as part of a if expression to enable/disable mypy building
@umbral bridge i see, with that part it makes much more sense - the example versions in the versions docs dont exactly help to make this clear, maybe a link to this or a example may help
will do
@tropic void https://github.com/pypa/hatch/pull/314/files
lovely, thanks
@umbral bridge i'll try to get pytest in there once the fedora packaging tooling is hatch compatible
with the caveat that i may be out of commission for 2 months for having a daughter starting in the second half of august ^^
congrats!
congrats! enjoy the sleep while you can get it :)
hmm, my sleep schedule dearly wishes i would heed your words
oh the responsibility!
^.^
I want to rename the default publishing plugin name/ID pypi to something more generic. thoughts? cc @elfin crater
index? standard? keep as-is?
If you come up with a good name let me know, because I hate calling something the PEP 503 API, since its' really the PEP 503+592+691+othernumbersiforget
simple-repository?
too long to type
smpl-rpstry
haha perfect
@umbral bridge are there any plans for project local plugins for hatch/hatchling (to enable stuff like setuptools_scm self bootstrapping)
every Custom on the left https://hatch.pypa.io/latest/plugins/about/
@umbral bridge thanks, after taking a closer look, it seems oblivious, it may be a good idea to link to some practical examples in a non reference section of the docs
will do ๐
GitHub Actions' setup-python has native support for caching via pip, pipenv and poetry
Does anyone know if there's a way I can use this with hatch?
https://github.com/actions/setup-python/#caching-packages-dependencies is the relevant section, which basically is just calling actions/cache for you
Where does hatch store concrete lockfiles, I guess I should be able to answer that myself in the docs
hatch aint dealing with that - just use the normal pip cache
oh wait, i misunderstood the tool
so currently hatch is not supported, but enabling caching of pip caches may speed up things
I think (but haven't tried yet) that it won't do much unless I manage pinning versions, for the same reason mentioned there, that pip will still go look for latest versions
I'm aware hatch doesn't fully manage this, just trying to see how to complete the workflow
like, I think I need to use something like hatch dev show requirements, but then pip-tools comes back in the picture
hatch will eventually support pep based lock files, currently it doesnt, and it may help to use pip-tools for the meantime
ok
I think pip-tools itself doesn't support hatch at the minute
so I guess I get to pipe into it
my ๐ are on https://github.com/pypa/pip/pull/10771
Following the conversation in #10748 and @cosmicexplorer 's request that I describe more precisely what I had in mind I created this proof-of-concept.
The output is conceptually very similar to...
we'll be switching away from tox soon, PR number 1 of like 150 lol https://github.com/DataDog/integrations-core/pull/12519
Motivation
Part of our tooling revamp
๐ฎ๐ญ
@umbral bridge k pip install --dry-run --report is merged and will be in pip 22.2. Eager to see what you are going to do with it.
awesome ๐
oO - isnt that basically going to make pip-tools be able to disengage fromthe apis?
It's addressing these kind of use cases, yes, together with pip inspect that I also hope to land in pip 22.2. https://github.com/pypa/pip/pull/11245
@hybrid thorn -- I've just filed https://github.com/jazzband/pip-tools/issues/1654
Do we have to icurr a subprocess call penalty here?
https://github.com/jazzband/pip-tools/issues/1654#issuecomment-1188409384 it's a dup. Vendor pip-tools in pip please ;(
Is there a good way / best practice for pulling out part of a README for the description? In converting some packages, I run into things looking for markers and just pulling out parts for PyPI in the setup.py.
interesting, does hatch have a feature which replaces tox?
Modern, extensible Python project management
actually just presented my RFC to switch at work today
we should be done migrating by the end of Q3
we just migrated to nox from nothing and now i want to explore migrating to hatch 
lmk if I can help
tbh I should probably explore other options first
as we currently use setuptools, that is the main thing to shift away from
Its also a library, so I'm not terribly concerned about not having lockfiles; I don't think that libraries should use them
the build tools I know of are flit, hatch, poetry, and setuptools
is there a comparison floating around somewhere that you might know of?
of tox/hatch/nox or setuptools/hatchling/flit?
both would be cool but mainly interested in the latter, as we'll probably stick with nox for a period of time even if we switched to hatch
let me check when we switched to nox
we added usage of nox on june 3rd
thanks, i'll take a look!
np! I think I found your nox file ๐ https://github.com/DisnakeDev/disnake/blob/master/noxfile.py
you did, haha
I'm not too familiar with nox but the size/verbosity alone scares me lol
I wonder if hatch supports everything we're doing with nox
this is the list of our current sessions:
- docs -> Build and generate the documentation.
- lint -> Check all files for linting errors
- slotscheck -> Run slotscheck.
- pyright -> Run pyright.
- test-3.8(extras=[]) -> Run tests.
- test-3.9(extras=[]) -> Run tests.
- test-3.10(extras=[]) -> Run tests.
- coverage -> Display coverage information from the tests.
- setup -> Set up the external environment.
the important things which I would be interested if hatch supports are the things below:
the first session, docs, invokes a different dependency based on if we're running in CI or an interactive session, plus different arguments
the test sessions call the coverage session once they are done running
the setup session installs all of the dependencies to the local environment, checking that the developer has a venv activated before doing so (this one is almost certainly implemented when using hatch for dependency management)
different dependency based on if we're running in CI or an interactive session
CI/env vars yes, interactive session I think no atm. you mean like detecting TTY?
i actually don't know how nox does it ๐ but I think it detects the TTY or a forced environment variable
btw for Hatchling migration just do https://github.com/scikit-hep/vector/pull/219#discussion_r912151460
er, what is hatchling?
oh, the build backend
does hatch new --init not send anything to stdout/stderr intentionally?
yes
what is the reason?
I figure if no files are created then no need for showing a tree
ah, but i found it odd to wait for ~20 seconds with no indication of what was occuring
just read through the pyproject.toml file, quite impressive
oh good point, mock running python setup.py could take a bit, I'll add text
ty ๐
does hatch ever write to the pyproject.toml file other than hatch new --init?
because when it did, it changed some formatting and removed any existing comments
no only time
there's a lib tomlkit that tries to preserve formatting but it's buggy
I haven't noticed bugs with tomlkit, but I have noticed it is somewhat slow
and one issue where it sometimes deletes or adds a newline in one specific place, which may be poetry's doing
(I use poetry for my applications)
hm... the publish command is a bit scary
tested with a private index, and it would be heavily appreciated if confirmation was per-file, or a list of files to be uploaded would be shown.
Because of how the rest of hatch works, I partially expected hatch to only upload files that match the current version
Ah, I did just find hatch clean but I feel like I would forget to clean it right before making a release
upload files that match the current version
no b/c often you'll publish artifacts in a separate step that doesn't even have the project
wdym?
usual steps:
- build artifacts, upload to cache
- download artifacts from cache without cloning repo, upload to pypi
huh, where is the step to test the wheel/sdist?
I haven't made an automated release workflow yet but I've intended to
my main point is that the final upload step often won't see the project
ah okay