#hatch
1 messages · Page 3 of 1
why?
Uhh I want a bunch of tag names for testing resolution, there are no real platform requirements
that isn't correct because you also have to change the WHEEL file inside
Hm true. I wonder when that file is inspected.
on wheel installation
Well the tags are in the name of the file, why parse them from there too?
from what I have noticed, neither pip nor installer actually read the tag from WHEEL file, so you can get away with just changing the file name
maybe true but I wouldn't recommend not conforming to spec
for example, IIRC the *.dist-info/RECORD also isn't used but I think it would be bad to not have that be correct
installer verifies hashes based on RECORD file
I remember because we had some issues with that when we introduced installer-based installer
oh, that's awesome. I think pip does not
the next release will have a command that is the recommended way to submit bug reports https://hatch.pypa.io/dev/how-to/meta/report-issues/
Is Hatch getting PEP 723 support at some point? I seem to remember you mentioning that somewhere.
yes it will be in the next minor release
@blazing orbit I was about to open a feature request in VS Code Python about Hatch env discovery,
as people from the PyOpenSci community start to embrace Hatch and found this to be a pain point.
I then found “Reach out to Hatch about environment discovery proposal; @brettcannon” in VS Code Python’s “Iteration Plan for June 2022”.
Did anything come out of this? Is there a PEP planned for Python venv discovery? Would supporting Hatch specifically in VS Code be welcome until then (IIRC, Poetry has special support)
Poetry has special support in VS code? Interesting
yes so does pipenv
if I was good at TypeScript I would have contributed the feature a while ago
Hm, maybe it’s quick to do. I played around a little: https://github.com/microsoft/vscode-python/pull/22779
The plan/hope is to come up with a workflow API this year and then move out all special support for anyone not pip and venv to separate extensions (and we will ask projects if they want to own those extensions before we publish them). And the "environment discovery proposal" Ofek knows of (and likes 😉) as it's the idea I have in the Python Launcher for Unix's discussions section on that topic
As you mentioned it, any chance to make your python launcher for unix an official thing? Like py on Windows?
As in ship w/ Python? Or have VS Code use it for discovery?
yeah, ship with Python
Not at the moment. I'm enjoying the fact I can still iterate on it. I would rather get relocatable binaries built and made available on python.org so that py can download and install them. When that's possible then it might make sense to make it the thing to download from python.org
makes sense
is this working?
Not yet. I’m busy with work, but I’ll try to finish it up at the end of the week or next week
Actually I just checked and it does work! It’ll find Hatch envs that are already created.
In the future, we could maybe enhance the extension so it lists all defined environments, and creates one that is being switched to but that doesn’t exist yet. For that, maybe Hatch might want to grow a “create environment, but don’t sync dependencies yet” command.
That PR is now ready for review, so hopefully it can be merged soon!
that's so awesome, thank you!
🥚
I have a data directory with some static data that I want installed into the package as resources when it's installed (the reason it doesn't live inside the package in the source layout is because it's shared with other things which do not get installed) -- force-include with data = "mypackage/data" seems to do "the right thing" there -- is that the intended option to use for this use case?
I guess I need to check that does the right thing for editable installs too first, hopefully so, /me checks
yes that is correct usage but editable I think would not work
you would need a custom build hook and use the option at the bottom here https://hatch.pypa.io/latest/plugins/builder/wheel/#build-data
I guess I could promote that to actual option rather than requiring a hook but I didn't know how useful it would be
the existing build data option was a feature request
I think this kind of thing might not be unheard of, basically it's a backend and a frontend that need to share some data, but I also wouldn't think it's super high priority to work on if there are some ways to do it
some day I'll understand importlib.resources
the force-include way is doing weird things even for non-editable installs
but I think because of importlib.resources, not hatch
specifically it's finding paths in cwd rather than the installed virtualenv, what...
I can see the file is in the right spot, it's in venv/.../site-packages/bowtie/data, so hatch did its job, yeah.
ok I'll shut up and fight with importlib and stop vomiting on the channel 🙂 will come back with build hook questions if I get stuck, thanks as usual
oh geez that will be because of dumb sys.path-automatically-prepending-. issues presumably, ok now I'll stop
I thought I was clever and just fixed editable packages by relying on having the source checkout available (and not using importlib.resources in that case, just opening the file directly), but somehow force-include breaks twine building the package via the sdist
not sure what's up there (nor did I diagnose yet, so I'm being quite lazy even mentioning it until I do 🙂
would the target path be different depending on wheel vs source distribution?
Whoops, didn't see your response sorry -- but I fixed it just by moving the force-include down
(to tool.hatch.build.wheel.force-include rather than the global one)
Having the data layout for sdists match the repo layout is fine / probably intended anyhow, so think all works well!
Whee, always more complicated, now RTD is broken -- https://readthedocs.org/projects/bowtie-json-schema/builds/23443821/
Now to see how the heck to reproduce that.
And now green there too via https://github.com/bowtie-json-schema/bowtie/commit/0d89985860e5188aa8adaaa279b4dec2e2cd7a9b . Phew I'm tired :D.
I'm encountering some very weird behavior with hatchling
In two checkouts of a repository, one builds a wheel without the src/<pkg> bundled and the other doesn't
# Checkout "a"
❯ git clean -fdx
❯ which hatchling
/Users/mz/eng/src/astral-sh/uv/.venv/bin/hatchling
❯ git rev-parse HEAD
68c75bd0cb1b4346f2d8b3ed44e2e680384357bb
❯ hatchling build
[sdist]
dist/uv_private_pypackage-0.1.0.tar.gz
[wheel]
dist/uv_private_pypackage-0.1.0-py3-none-any.whl
❯ tar -xvf dist/uv_private_pypackage-0.1.0.tar.gz
x uv_private_pypackage-0.1.0/src/uv_private_pypackage/__init__.py
x uv_private_pypackage-0.1.0/.gitignore
x uv_private_pypackage-0.1.0/pyproject.toml
x uv_private_pypackage-0.1.0/PKG-INFO
# Checkout "b"
❯ git clean -fdx
❯ which hatchling
/Users/mz/eng/src/astral-sh/uv/.venv/bin/hatchling
❯ git rev-parse HEAD
68c75bd0cb1b4346f2d8b3ed44e2e680384357bb
❯ hatchling build
[sdist]
dist/uv_private_pypackage-0.1.0.tar.gz
[wheel]
dist/uv_private_pypackage-0.1.0-py3-none-any.whl
❯ tar -xvf dist/uv_private_pypackage-0.1.0-py3-none-any.whl
x uv_private_pypackage-0.1.0.dist-info/METADATA
x uv_private_pypackage-0.1.0.dist-info/WHEEL
x uv_private_pypackage-0.1.0.dist-info/RECORD
The project is identical to https://github.com/astral-test/uv-public-pypackage but with private instead of public
A public test Python package. Contribute to astral-test/uv-public-pypackage development by creating an account on GitHub.
If I unpack the build sdist it looks like a gitignore is getting generated for me?
❯ cat uv_private_pypackage-0.1.0/.gitignore
.vscode
.venv
.python-version
.envrc
.direnv
❯ cat .gitignore
cat: .gitignore: No such file or directory
and in the bad build, the gitignore is * for some wild reason
❯ cat uv_private_pypackage-0.1.0/.gitignore
*%
To be clear, it's the same as the git repo, but with all instances of "public" replaced with "private"?
Could it be that you didn't update the package path under the package key in pyproject.toml?
Yeah. It builds fine in one of the clones of it, the path is correct.
It must have something to do with the way it's cloned? A fresh clone with git builds fine but building from libgit2's clone ends up injecting this bad gitignore
I'm not sure what's generating this gitignore file
Weird!
I wonder if it's pulling my global personal gitignore in
In the one that works, it's in a subdir of my home directory so it finds it
In the other, it's in a temporary directory and defaults to some horrible "*" ignore
@umbral bridge are any details of the proposed lockfile standard public?
I know nothing of Brett's idea other than that there will be top-level keys in the file per target
Hatchling traverses up the directory tree to find an ignore file which is useful for monorepos, you can disable that behavior with https://hatch.pypa.io/latest/config/build/#vcs
Isn't that a big problem for sdist builds in other environments?
the ignore file gets shipped in source distributions (if the aforementioned option is not disabled)
If building a source distribution from a git repo (e.g. via pip install git+...) this will use the users ignore file which can break the package
I think you should stop at git boundaries so you don't traverse up out of the repository when searching for an ignorefile
https://github.com/pypa/hatch/issues/1273
Let me know if you need more!
fixed and will be released today
@dull rapids fantastic work on this! much appreciated https://github.com/microsoft/vscode-python/pull/22779#pullrequestreview-1940542535
Oh nice, didn't expect that to be merged without doing more busywork. It's very refreshing to see that they're pragmatic and don't love their new testing standards so much that they let them delay the PR.
(I said I don't have much time and therefore can't pursue a higher testing standard than older integrations)
Ah, I misunderstood them! They just wanted manual testing instructions, not me to do many more unit tests. Easy!
So yeah, it's merged and it works.
working on the test command now, it's going to be really nice
test command?
yeah a hatch test like I mentioned would be coming in that blog post
I have a question about overriding dependencies, in the context of a monorepo. I have a namespace package that doesn't have any code, just metadata. It has a project.dependency array with a pinned dependency on one of its subpackages. I need to bump that pinned dependency in a PR that prepares things for release, but that pinned dependency version isn't released yet, so normally that would break because hatch couldn't find this yet-to-be-released child package on PyPI.
I have the same problem when I build the namespace package, but there I have a tool.hatch.metadata.hooks.custom which rewrites the dependencies to use file URIs and remove the version pin. This works fine for most cases.
However, it breaks when it wants to install the project in development mode. Apparently my metadata hook does not get called when the environment first gets created (i.e. from a cold start clean clone). I see Installing project in development mode and then I get the failing error because it can't find the pinned dependency.
What's odd though is that if I run the same command again, it all works. I see Checking dependencies and Syncing dependencies and my hook debug prints prove the hook is getting called. My hook implements MetadataHookInterface.update().
So the question is: how can I hook into this Installing project in development mode step to rewrite the dependencies to use file URIs in the same way? I don't know if such a hook exists, or if there is a better way to handle this dev mode problem.
Worse comes to worse, I think I can hack my CI to ignore the error the first time, and run the command again. Not ideal, but it might work.
TIA
I think the root problem is that I have to be able to modify the project's dependencies (i.e. to remove the pin and point to the file URIs) when the project is installed in development mode. Is there a hook that allows me to do that?
Looks like for now I can add skip-install = true but that's not a long term solution.
@umbral bridge i mised the post, can you link it?
sorry I missed this message, blog post for 1.8 https://hatch.pypa.io/latest/blog/2023/12/11/hatch-v180/#future
I'm so close now, the command is completely finished and tested, only documentation remains
@umbral bridge I'm not sure you saw my above question: #hatch message
It's the one thing that's hanging me up with monorepo. I mention this because your blog post above references monorepo. Could you confirm that I'm missing something that already exists, or that it's a gap that needs a bug report, which I'm happy to do. Thanks.
@umbral bridge BTW, I finally completed the conversion of some of my personal projects (not monorepo) to hatch and ruff. Gotta say, I really appreciate all the work you've done on hatch, and I think you've really found the right UX and functionality. I was able to drop pdm and tox and a bunch of hacks I had on top of all that to make things work. Everything is simpler now, easier to understand, better organized. Just want to give you major kudos!
@ofek I'm not sure you saw my above
ah 🙂 thank you for your kind words! I'm very happy to hear that and I plan to add more cool stuff regularly, work has been busy recently
it took a lot more time to get it polished than I thought but the test command is merged!
I can't wait to start using it in all my projects
FYI making two breaking changes in the next minor that are fixes:
- the run and shell commands will no longer switch to the project root if already somewhere inside
- the shell command arguments are being replaced by flags and the only argument will be the name of the environment to enter. everyone was surprised by the previous behavior, including myself lol
(just merged both of those changes today)
https://code.visualstudio.com/updates/v1_88#_hatch-environment-discovery
thanks again @dull rapids, great job
Happy to help!
PEP 723 support coming later today!
that script is this example: https://peps.python.org/pep-0723/#example
how to do run hatch shell on a specific environment ? like if I normally do hatch shell it'll spin up default env. how can I spin other envs which are already creadted ?
hatch -e <ENV> shell but in the next release you will be able to specify the environment as an argument to that command instead, sorry about the poor original UX
awesome thanks 👍
UV support coming sometime in the next week and then I will release the next minor version!
How to make hatch publish use my pypi API token?
You mean hatch run pip will actually run uv pip? That sounds confusing, no?
I would understand hatch using uv if it had a dependency management capabilities, but this sounds more confusing than like a good feature
I agree. Hatch should use uv for dependency resolution, but hatch run pip should still run pip.
The algorithm for selecting a command should stay simple: “if a Hatch script is defined in pyproject.toml or hatch.toml, use that, otherwise use a binary in the env’s PATH”
this is all behind a configuration option, not the default behavior. when UV is enabled pip will expand to uv pip to prevent mistakes when users run pip and there happens to be an executable outside of the virtual environment. in virtual environments created with UV there is no pip
that script override can be disabled with another option
this also makes it easier for users to keep using the same scripts e.g. if one of their post-install-commands runs some pip command but some environment in their matrix they override to not use UV (maybe a dependency doesn't resolve properly) then the command wouldn't have to change
at the same time, if 3 people say to not do that then I probably shouldn't...
okay I'll just put a tip in the documentation that adding such a script might be useful
I mean, I think we all didn’t know that it’s opt-in, in which case it’s a conscious decision to enable it
In general, I think it is unfortunate that a lot of Python distributions come without an EXTERNALLY-MANAGED file (which when present causes pip to refuse to operate when there is no virtualenv to operate on)
Maybe Hatch should come with a pip (and pip3) shim that just displays an error message when there is no pip inside of the virtualenv? That would both be helpful while also not replacing one tool with another.
Then we could also by default not install pip and setuptools into the venv (like rye does: virtualenv --no-seed)
So basically, when doing hatch run, PATH would be
<venv>/bin(might containpipor not)<hatch>/shims(contains apipshim that warns people that they’re not operating on the venv)- default stuff
next minor release coming soon, with UV support https://hatch.pypa.io/dev/how-to/environment/select-installer/
Beautiful! Love the examples, those really show how to become a power user!
FYI I'm very sick and won't be on the computer much the next few days so will have to wait a little bit for the next minor release. just started antibiotics, steroids and decongestant
Oh no! I hope you feel better soon @umbral bridge
@umbral bridge How are you feeling?
about 80% better thanks!
I'm hoping to release tomorrow
and then prepare the presentation for PyCon
this is a major theme at astral this week haha
Great to hear you're feeling better @umbral bridge . Looking forward to meeting you in Pittsburgh!
trying to find a package to showcase the test command
Rich might be a good candidate, just a bummer about the test suite causing that warning
You're welcome to use one of mine. They're small and not amazingly popular 😄 but they're already hatchified. I actually started to switch over to the test command but then realized it wasn't yet released (and then got distracted).
uv and the test command work together really well! I switched some of my stuff and it makes things really convenient!
@errant timber at work folks are seemingly most excited about your build plugin, or at least I've gotten a few messages only about that lol good job!
Test, uv, and PEP 723 are great. I've switched to Hatch 1.10 for https://github.com/henryiii/validate-pyproject-schema-store (actualy, I switched a couple of weeks ago and just requied a git checkout of hatch!)
Congratulations @umbral bridge - now I'm just waiting for the new version to show up in homebrew (I know, I know, pipx :D)
thanks! actually Henry is working on that literally as we speak
@orchid birch I just thought of something, do you want to see something cool? If so, what platform & arch are you on?
I love cool things! macOS and have both Intel and Apple Silicon
you mentioned homebrew and then pipx, which makes me think you might not have tried the binaries. UV has made the first time installation a lot faster
curl -LO https://github.com/pypa/hatch/releases/download/hatch-v1.10.0/hatch-1.10.0-aarch64-apple-darwin.tar.gz
tar xzf hatch-1.10.0-aarch64-apple-darwin.tar.gz
mv hatch-1.10.0-aarch64-apple-darwin hatch
./hatch
That is pretty cool. Do you have any sense of relative popularity of the various distribution channels? I'm guessing you're not collecting any telemetry on that, but I thought I'd ask.
Do you have technical details about how this works?
no I don't but the binaries are built with this https://github.com/ofek/pyapp
Homebrew is out, finished a bit ago. Doing conda-forge now
there is also a PKG for macOS (which just ships the binary) but I thought for testing didn't want to modify your system
Yeah 😄
for the next minor release I'm planning on signing the Windows release artifacts but I don't yet know who to talk to, Ee helped me set up the PSF certificate for the macOS stuff
https://hugovk.github.io/top-pypi-packages/ has PyPI stats
A monthly dump of the 8,000 most-downloaded packages from PyPI
I think he meant PyPI vs binary vs installer
Yep, I guess also conda.
I'd start with @last cobalt
Yes, don't know how to get stats for the other ones. Except brew: https://formulae.brew.sh/analytics/
(And of course conda: https://anaconda.org/conda-forge/hatch)
Someone called?
hey there! yes, I'm trying to find out who has access to PSF certificates for signing Windows software
Ee assisted with the macOS certificates but from my recollection they only had purview over Apple stuff
Are you using the same certificate we use for CPython? Or did Ee get you your own?
a new one was created on that account
Ah, because with Apple you pay for one developer account and can create multiple certs
Windows is different - you pay for certs from third parties such as DigiSign. Ee ought to be able to arrange one for you, but it probably requires the PSF to approve it
okay I'll ask thank you. then my next question is, how? lol I've never done Windows signing before actually
You'll either use signtool.exe, which should be installed if the compilers are there (see https://github.com/python/cpython/blob/main/PCbuild/pyproject.props#L209 for our old commands). This can either sign directly from a .pfx file (private key) or an installed certificate. (Full tool docs https://learn.microsoft.com/en-us/dotnet/framework/tools/signtool-exe)
For our actual releases, we're using AzureSignTool, which lets us keep the certificate locked up in a Key Vault and never actually bring it onto the machine. Our code https://github.com/python/release-tools/blob/master/windows-release/sign-files.yml
Actually, the readme from that repo has better info than the code: https://github.com/python/release-tools/blob/master/windows-release/README.md#findingupdating-certificates
that sounds way easier, and I've heard about that before, I might have even saved that in my notes! would you recommend this approach for Hatch then?
If you've got an Azure subscription you can use, absolutely. Wouldn't surprise me if there are tools that work with AWS/GCP equivalents, but I doubt there are many that support those and support Windows binaries 😅
cool, and is only one certificate required? for Apple it was really weird, you had to have one type to sign binaries and another to sign the distribution artifact
Yeah, one cert for everything on Windows. Works on .exe/.dll/.pyd/.msi directly, and a few other file types with the right additional tools (I even have an addon to sign .py with them, but that's not public 😉 )
when I talk to Ee, does this mean the subscription would prevent having to pay for another certificate?
No, they're two unrelated things. The Azure subscription is just secure storage, but the cert comes from another company and is unique to you (I've tried for years to get a Let's Encrypt type feature for Azure Pipelines/GitHub Actions, but we can't make it work... maybe with OIDC someone else can do it?)
It might be possible to let you use the one I have in storage for CPython, but the risk is that if it gets out, we have to revoke the cert and all existing installs of Python will start raising red flags.
let's not do that
Last I looked the cost is less than $100 for a 3 year cert
It's just that anything greater than zero is more complicated than zero
Oh, it looks like DigiCert is charging more, but they also offer secure hosting and remote signing.
Pretty good looking walkthrough: https://docs.digicert.com/en/digicert-keylocker/ci-cd-integrations/plugins/github-custom-action-for-keypair-signing.html
Would Trusted Signing (https://azure.microsoft.com/en-us/products/trusted-signing) work?
AFAIK it is currently free but will be $10/mo at some point
I have a feeling that service wouldn't use root trust certificates for normal machines, it was meant for enterprises that could generate their own root certificate and install it on all their machines
Though it does say "public trust" as an option
oh interesting the link I saved in my notes is https://github.com/Azure/azure-code-signing-action which apparently is now deprecated in favor of what you just mentioned, trusted signing https://github.com/azure/trusted-signing-action
Yeah, I heard about this from someone who uses certs for signing an OSS application
That repo is barely two months old, so that's why I haven't seen it before 😄
so... how can I verify that trusted signing does what we require for binary distribution?
Looks like it's invite-only right now, and they're keeping to trusted companies. But the root CA has been rolled out and will be trusted everywhere
I think it will go GA in June from what I read
So yeah, this would be a viable option when it's accessible. I can try to get the PSF onboarded, but I suspect they are keeping it tight before someone figures out nasty hacks
this sounds awesome and I don't think I would have tried tinkering with signing before June anyway so I'll just wait until it's GA
that would be fantastic if PSF was onboarded sometime this summer!
I'll drop the team a message and see what they think
great, thank you for answering all my questions, I have a much better idea of what Windows signing entails and thanks @dusty parcel for that tip
Sure thing! Saw the discussion and remembered what my friend mentioned, glad it will be useful
@umbral bridge if you have some time, I'm just starting to play around with hatch test and have a few questions
sure
Here's what was doing previously: https://gitlab.com/warsaw/public/-/blob/main/pyproject.toml#L64
Translated now to:
# Default hatch-test matrix is currently 3.8-3.12
[tool.hatch.envs.hatch-test]
default-args = ['tests', 'docs']
extra-args = [
'--cov=public',
'--cov-report=term',
'--cov-report=xml',
'-p', 'no:doctest',
]
extra-dependencies = [
'diff-cover',
'pytest-cov',
'sybil',
]
So first thing is that with those extra-args I think it breaks hatch test --cover because the coverage files are already collected.
that final argument is two arguments
Ah, good catch
you can do your own coverage wrangling but I would recommend getting rid of that plugin and using coverage directly with or without the test command flag
I was a big proponent of the plugin for years until I realized how everything worked and now it's just a hindrance (and mostly unmaintained)
Was thinking the same thing, though is it possible to make --cover (and for that matter --all) the defaults for hatch test?
no those flags must be passed
because they are not so much configuration as modifying test execution
I can see that. At least for this package the tests run very quickly, so I always run everything and I always like seeing the console coverage report.
also you can modify the scripts https://hatch.pypa.io/latest/config/internal/testing/#scripts
if you're doing crazy stuff like using a different test framework or something
Yep, saw that. Haven't tried it yet.
Other questions is about diff-cov. I'm not quite sure where to plumb that in, maybe in the cov-report script override?
Funny thing is you have to use - diff-cov because you can't run this if you're not in a branch other than main.
my assumption:
[tool.hatch.envs.hatch-test.extra-scripts]
run = [
"pytest{env:HATCH_TEST_ARGS:} {args}",
"- diff-cov",
]
That's what I thought; thought I tried it but let me confirm
Oh, now here's an interesting observation. hatch test --cover --all gives me the coverage report after all the python matrix tests run, so I get one console report. In my previous incarnation, each python matrix run gets its own console coverage report.
Why this could matter: if your tests are Python version dependent, then you might have different coverages for different runs. I've definitely seen that in some projects.
My guess is that to get the behavior I want, I'd have to change the default scripts
The cov-combine script runs after all tests complete when measuring code coverage, as well as the cov-report script
Are you sure about the [tool.hatch.envs.hatch-test.extra-scripts] there? Seems like it has to be [tool.hatch.envs.hatch-test.scripts] - and you have to define all 4 default scripts. I don't think extra-scripts overrides just a single script (e.g. run)
[tool.hatch.envs.hatch-test.scripts]
run = 'pytest{env:HATCH_TEST_ARGS:} {args}'
run-cov = 'coverage run -m pytest{env:HATCH_TEST_ARGS:} {args}'
cov-combine = 'coverage combine'
cov-report = [
'coverage report',
'coverage xml',
'- diff-cover coverage.xml',
]
^^ solves the diff-cover question, but note the hatch test --cover --all question.
no it was just a thought, good to know thanks
Alhtough it would be cool if I could just override a single one of those scripts 😄
I guess you could simply go back to the previous way and change the run command to do more stuff
I'm just not sure how to connect the matrix that --all invokes with the run command.
the run command happens once for every environment when using that flag
so you would want each run to test and then run some command afterward right?
Ah yes, I think I see.
Seems to do the trick:
[tool.hatch.envs.hatch-test.scripts]
run = [
'coverage run -m pytest{env:HATCH_TEST_ARGS:} {args}',
'coverage combine',
'coverage report',
'coverage xml',
'- diff-cover coverage.xml',
]
run-cov = 'hatch test'
cov-combine = ''
cov-report = ''
Why this could matter: if your tests are Python version dependent, then you might have different coverages for different runs. I've definitely seen that in some projects.
I'm a bit confused here, isn't that the whole point of combining coverage at the end? I don't quite understand the benefit of this approach
What if you had a line that got covered under 3.11 but not 3.10, and maybe that was unexpected (i.e. you expected every line to be covered under every Python version). Combining at the end would hide that issue.
I see, I understand now but I would say for differing functionality the tests themselves should fail rather than relying on what is essentially metadata
i.e. if someone proposed that on my team I probably would require them rewriting as a test assertion
also possible that I don't actually understand and this complexity is necessary 🙂
Could also be that the test passes and the missing coverage silently gets ignored. It would be pretty difficult to spot. I know I've seen this in the past, but admit I can't come up with an example atm.
It could also be my paranoia 😄
Anyway, I appreciate the ear. Maybe worth some time to let it simmer (for both of us)
happy to help! let me know if some kind of new feature is in order
Thanks! Next up hatch fmt conversion.
@umbral bridge Found and reported one problem w/ hatch fmt: https://github.com/pypa/hatch/issues/1459
@umbral bridge @dusty parcel FYI, I was pointed to the actual docs for Trusted Signing, though they're kinda thin. https://learn.microsoft.com/en-us/azure/trusted-signing/overview Sounds like getting the PSF and/or individuals into the preview is possible, just a matter of identity verification. I'll chat with the team next week and get more details
That's great to hear!
I went on the same path as you. Then I was told that vanilla coverage.py doesn’t handle pytest-xdist well: https://github.com/nedbat/coveragepy/issues/1341#issuecomment-1302863172
Is there something you do that makes that work?
A clear disadvantage is that coverage.py doesn’t support removing the working directory from PYTHONPATH. I can’t get the PR through that fixes it since I don’t have windows: https://github.com/nedbat/coveragepy/pull/1700/
yes there is custom logic to make that work, I worked with Ned on the feature
That’s awesome! Would be great to have that independently as well …
@umbral bridge with all the test command and format details - hatch is closer to what tox set out to be than tox is ^
Remind me what tox is again? 😆
@orchid birch it's a venv manager and command runner initially created by the creator of pytest to facilitate local first ci/CD fooling
"fooling" [sic] 😄
@umbral bridge is there an option to get hatch to log or output every command it's calling? HATCH_VERBOSE=3 doesn't seem to give me any additional output for e.g. hatch fmt --check
not yet
Nox does this on almost every command, and it's one reason I like it 🙂
Ok. I was thinking about debugging the "why is it moving that import" and I wanted to see how hatch is actually invoking ruff.
oh actually that might be just an artifact of that command, increased verbosity should actually show the commands
see
I can fix that, good catch
my thoughts exactly. hatch envs are "tox in pyproject.toml done right"
Anyone have any examples of nice docs (sphinx) builds in hatch? I've got a pretty nice nox one set up and wondering if anyone has a hatch equivelent to start from when converting. (https://github.com/scientific-python/repo-review/blob/def816817556d32f205d255e829fb8c0f6d1c8fa/noxfile.py#L81-L138 for example)
@errant timber Like this? https://gitlab.com/warsaw/public/-/blob/main/pyproject.toml#L107
yes, though I was hoping to see a way to serve with autobuild and regenerate the API docs. I can start there though
One task can't depend on another like in pixi, right?
Also the ability to target multiple backends, not just html. linkcheck and man specifically are important. But maybe those can each be scripts.
I never really spent much brainpower on it because I mostly rely on RTD, so I can't wait to see what you come up with.
I don't know about task dependencies, but I think not. What I do sometimes is build higher level scripts/envs that collect a bunch of operations: https://gitlab.com/warsaw/public/-/blob/main/pyproject.toml#L60
Ah, a script can call other scripts, intersting!
Yes! There can be some oddities though. I don't remember the details, but at $work, there was a case where I had to unset HATCH_ENV_ACTIVE env before calling the sub-script from a script. The outer script was calling hatch build so that might be where the conflict came from.
You can set both features and dependencies, right? Having a missing command issue I'm debugging
Ahh, my fault, nevermind
No, I take it back, it's not installing the item I have in dependencies when I have features
yes you can set both, what is the issue?
I have:
[tool.hatch.envs.docs]
features = ["docs"]
dependenices = ["sphinx-autobuild"]
scripts.serve = "sphinx-autobuild -n -T -b=html docs docs/_build/html {args}"
Then when I run it with -v after a purge, there's no sphinx-autobuild in the install and it's not available as a command
dependenices typo
post-install-commands = ["$HATCH_UV pip install -e tests/test_utilities"]
Is this the best way to do this?
I did try dependencies = ["-e tests/test_utilities"] but that wasn't supported
yes it's not like tox/nox where it's literally just arguments to pip but rather they must be actual dependency definitions
I'm not sure workspaces would solve it, I do want both the main package and the example plugin
It doesn't rerun the post install if I edit (or add) it, have to env prune every time I fiddle with it
yes and that's not great but workspaces will solve that
essentially, anytime you want to do -e on another directory, that is what workspaces is for
Great 🙂
What's the best/fastest way to install hatch on CI?
- name: Setup uv
uses: yezz123/setup-uv@v4
- name: Install hatch
run: uv pip install --system hatch
?
The default test matrix doesn't respect reqiures-python. That would have been nice
You can see what I did here: https://github.com/scientific-python/repo-review/pull/212
[tool.hatch.envs.docs]
features = ["docs"]
dependencies = ["sphinx-autobuild"]
scripts.linkcheck = "sphinx-build -b=linkcheck docs docs/_build/linkcheck {args}"
scripts.html = "sphinx-build --keep-going -n -T -b=html docs docs/_build/html {args}"
scripts.serve = "sphinx-autobuild -n -T -b=html docs docs/_build/html {args}"
scripts.man = "sphinx-build --keep-going -n -T -b=man docs docs/_build/man {args}"
[tool.hatch.envs.api-docs]
skip-install = true
dependencies = ["sphinx"]
scripts.build = "sphinx-apidoc -o docs/api/ --module-first --no-toc --force src/repo_review"
The nox one supported arbitrary builders, this doesn't (due to needing to include -b=<X> in the directory name), and it always installs sphinx-autobuild (could have inherited an env instead), but I think otherwise it's simliar to what I had.
I can do this as a feature but most people would not run into that because CI would have a job for each usually
How can we use hatch publish in github CI/CD to automate package publishing ?
@umbral bridge any consideration for having hatch also act as pre-commit hook , in particular wrt linting and formatting
Wouldn't you want those to be local hooks because each command is unique other than "hatch"? And their versioning would be tied to the pyproject.toml
Wouldn’t Hatch still run on pre-commit.ci? I’d break pre-commit’s env caching, but it would simply run create its own envs there.
i'd use thus on a few hundred repos in a gitlab instance, so that type of caching is not that much of a problem, also pre-commit.ci has to reject that feature on principle
I'm open to suggestions but I don't know much about that
generally speaking I very much dislike pre-commit
how come, its pretty handy (in combination with formatters/linters)
- Here's an example of someone switching to just Hatch with detailed reasoning: https://github.com/br3ndonland/inboard/pull/89
- Here's a summary of sentiments from a conversation from this server (above this comment they noticed that pre-commit was not even working correctly): https://github.com/jupyter-server/jupyter_server/pull/1114#issuecomment-1337855082
- Project Jupyter made pre-commit optional for all of their developers as a final decision because of this
I usually would have hatch call pre-commit
hmm, the inboard one pretty much lists stuf thats actually valid and ought to be handled in thedownstreams, disappointing
as for the sentiment, i consider your opinion on the topic "wrong" based on the documented design choices of the tool that is multi language not python only
sure, I'm not saying that Hatch is a valid replacement, I'm saying that the downsides and unexpected behavior with pre-commit does not justify its use for me personally
Pasted from a DM: By the way, a lot of those arguments about pre-commit are due the fact it's a general check runner, not a Python check runner. I don't mind it not using pyproject.toml because it's not python specific. I use it for Ruby, C++, LaTeX, and other languages too. It doesn't know how to pull Python deps or tool config for affected files because it's not specific. And it's not awful in pre-commit mode and doesn't slow things down too much. I don't use it in pre-commit mode all the time, but don't mind it that way. IMO quick feedback is a better experience than git commit being lightning fast.
there's this https://github.com/WaylonWalker/hatch-action
I haven't had time to create my own official GitHub Action for Hatch but it's on my list for summer actually!
I do the opposite. I have precommit calling hatch scripts.
after I did hatch version micro my terminal is fozen. I have closed vscode as well. is this a bug ?
i beleive there is a need for some extra flags if invoking vscode as "editor" according to the docs the "--wait" argument that waits until the file is closed
show config? I'm confused
@umbral bridge im wondering if it would be possible for a ci action, to make hatch use the current virtualenv/python env instead of creating own ones
path and its environment variable https://hatch.pypa.io/latest/plugins/environment/virtual/#options
oh, that looks lovely - im hoping to fix some bits up with that wrt test commands
let me know what you think about the new test command!
It looks nice at first glance
But I haven't yet given the integration a due diligence deep dive
I don't think I have setup an option for editor
@umbral bridge hey! am i reading this right that hatchling is using eval(...) to compute/normalize an SPDX license expression? https://discuss.python.org/t/pep-639-round-2-improving-license-clarity-with-better-package-metadata/12622/112
(not to do impromptu code review since nobody likes that, but IMO that might be worth changing -- i think this would allow someone to sneak arbitrary python expressions into the SPDX identifier as long as it eventually evaluates to something valid)
I'm definitely open to changing that! however I'll only use a library that is specifically (or mostly) for parsing functionality, last I checked every option is incredibly heavy
makes sense! i messed around with it a bit and i can't cause RCE thanks to your normalization, so it isn't a security issue in practice. i'll see if i can find a lightweight SPDX expr parser but i think i've run into the same problem before 🙂
yeah a security person at work also tried to induce bad behavior and was unsuccessful fortunately
Hmm, hatch fmt produces a bunch of:
tests/test_adler32.py:1:1: INP001 File `tests/test_adler32.py` is part of an implicit namespace package. Add an `__init__.py`.
Even though I've already configured ruff and don't have INP selected. (And this is a terrible suggestion, test folder's don't need __init__.py's 🙂 )
I've only set extend-include, so maybe it's setting a (different) base include?
It's a good practice for pytest collection that helps to avoid certain issues
test directories should have that file to make it an actual package
yeah as Ronny said that's actually catching a real issue
Btw, there's a plan to fix that which I hope to land in this years pytest sprint
there is an option in pytest to change the import mechanism but I don't recommend that
The importlib mode has a different share of problems
Historically that meant that some backends (setuptools at one point) would try to ship tests as a package. I've found you shouldn't import anything from tests, and use a test/utilities folder and pythonpath="test/utilities" in your pytest config if you really need to import.
good idea is using Hatchling then 🙂
Unless importlib mode is used, it's easy to end up with a import mismatch then
But that doesn't explain why this is appearing when I already have a ruff config. I was trying to help out someone and incrementally add things, not slam them with a bunch of issues, so I have a very minimal ruff config mimicing what they currently are using.
(I do also like adding importlib mode, I like avoiding pytest's weird custom importer)
Hatch has default settings that are used which the user must extend/override
if you don't want to use any defaults and rely entirely on your stuff you can disable them https://hatch.pypa.io/latest/config/internal/static-analysis/#no-config
I think https://docs.astral.sh/ruff/settings/#flake8-tidy-imports-ban-relative-imports was supposed to go to an anchor
thank you! I just fixed all 3 anchors and will publish in a few minutes
That's pretty rough for a default, I use relative packages all the time, it expecially useful if you support vendoring. But given it's recommended in PEP 8, guess it's acceptable as a default. :/
I've tried setting 120 char width before, and had others yell at me because they had tiled windows less than 120 wide. So I now mostly stick to the default 88 or so.
If I set config-path = "ruff_defaults.toml" does it write out to that path?
Or does it read from that path and I need to generate it somehow?
Ahh, found it (--sync)
I'm about to go to sleep but FYI everything can be overridden by your config, Hatch just provides defaults
config-path = "" doesn't work. Was a little bothered by setting it to "none" when that's an path input. --sync would write out none. But I guess no one would know to try --sync.
That's fine, I think I'll be setting it to none in this specific case. This seems like a reasonable system in leu of something fancier from Ruff (which hasn't happened yet)
(I'm also looking into updating scientific-python/cookie, and I think I also want none there so it integrates with the manual settings)
I can add an option to simply disable, at the time that just seemed easier
I would be very interested in hearing about how the defaults are for your repositories, it sometimes just requires a few options to get what you want (and often not even that)
Guido and I are the source of the 79 character admonition in PEP 8. Blame a couple of old school Emacs hackers 😆 . Although TBH, while I still use Emacs I've long given up on 80-ish characters and mostly use 120. That said, I still think it's a good idea not to regularly write lines that are too long. Left-to-right language native readers (e.g. English) don't parse wide-right lines easily.
... do right-to-left languages have longer lines?
If something needs to be written, would it make sense in packaging?
no it wouldn't make sense there, it would need to be a dedicated package for that particular purpose similar to trove-classifiers
Just found the 3.23 part, so it would have a copy of https://spdx.org/licenses/
spdx has been untouched (the repo) for 8 years and was archived 4 years ago when the last release was made (2.5.1), I wonder if we could request the PyPI name
https://github.com/JJMC89/spdx-license-list/tree/main looks pretty close, No parser, but is kept up to date automatically. Poetry project, with the usual issues (python < 4, etc)
yeah the parser is all the person was asking about, I also have a script (not automated) that updates the licenses in Hatchling
I assume a parser package would also have a copy of the licenses, though? That seems like the "hard" part, the parser's just a pretty generic one
I think you could swap out the eval for a syntax tree based approach really easily
yeah true I guess it would have both
although I view the parser as the "hard" part, continuously updating a Python file automatically from an external source seems more straightforward to me
I won't mind having this in packaging TBH.
(the list of licenses for spdx, with the need for regular updates)
I can prepare a PR if you'd like
I wrote my opinions over on d.p.o.
I don't like having standards related discussions on a platform that you can't read without an account/additional access. 🙈
Tack on the parser as well.
can I use the Hatchling parser for now or do you want a new implementation?
I don't know enough about either the hatching parser nor have a fully formed opinion yet on this topic. So, I can't really answer that beyond: do the hatching one, but we might iterate on that or go a different way if necessary?
The hatchling parser has an eval in it? I'm pretty sure we could get rid of the eval pretty easily, it's just a simple language with parens and and/or AFAICT?
I'll introduce the generation of the enumeration as a first PR
this is all I have time for today: https://github.com/pypa/packaging/pull/799
hatch doesn't support extension modules yet, right? - would adding a c compiler interface in the standard library help jumpstart it? (or alternatively, just forking the old distutils.ccompiler for hatch)
there is setuptools that support extension modules
not itself but via plugins most cases are supported https://hatch.pypa.io/latest/plugins/build-hook/reference/#known-third-party
it would be cool if it did support it natively, something like hardcoding compiler commands into hatch-build-scripts wouldn't be platform independent
on that page I was mostly referring to scikit-build-core, hatch-cython, and hatch-mypyc
ive used hatch-mypyc before, it's nice, but none of those allow you to build raw c code
the first one does
uses CMake
it's the most powerful extension module builder that currently exists
oh, TIL
here's a bit about that https://hatch.pypa.io/latest/blog/2024/05/02/hatch-v1100/#cmake-build-plugin
in the future then, perhaps a much simpler native version could be added to hatch - bringing cmakelists into it can be a bit overkill for some projects
I agree with that, I actually do have a plan to add native support later this summer/fall but I don't want to talk too much about it in case it's not as awesome as I think but it will allow for cross compilation if all goes well
awesome - again, look into using the old distutils.ccompiler if you end up struggling to get cross compilation working
it's luckily more or less independent of distutils
I'll be using Zig which is actually shipped on PyPI
oh right, theres a zig cc command right?
yes exactly
that will be interesting to see, good luck!
You can also do it yourself in a local plugin pretty easily, though it needs some addition to infer-tags that I’ll be working on
oh crap I have to review that PR of yours, sorry been very busy, I'll do that today
zig is most curious
zig is C, but designed in 21st century
I kind of feel Zig is more like C designed for 2010. Still way better than C but already showing some age.
Zig's ability to cross-compile V/C++ is the really interesting bit, at least to me
hmm, extremely compact is a bit of a misnomer, but it certainly beats other toolchains by bounda and leaps
@umbral bridge I just stumbled upon rye workspaces and im wondering about the plans for hatch workspaces
that's literally the next feature
it'll be based on my experience and a hard requirement to satisfy Barry Warsaw and Apache Airflow maintainer who I can't remember at the moment
taking a cursory glance it looks like what Rye refers to as virtual packages is just an extremely limited form of Hatch environments
We're also in the middle of implementing this, I'd be curious to hear if we're going to differ! https://github.com/astral-sh/uv/issues/3404
I presume the Airflow maintainer you refer to is Jarek https://github.com/potiuk
yes sat next to him yesterday!
@tropic void I'm designing workspaces in my head currently and I thought of something. Say 1000 packages all use hatch-vcs in the same monorepo and are part of the same workspace, what are your thoughts on a caching mechanism so that the build environment for each doesn't have to make the same Git subprocess calls 1000 times?
when synchronizing dependencies I have to get the dependencies from the build environment and that requires hooks running every time
In case the describe behavior is the same, I believe the pretend version should be set, I need to roll this around in my head a little more
Hi, if we set the matrix platforms like this
[tool.hatch.envs.hatch-test.overrides]
matrix.feature.platforms = [
{ value = "linux", if = ["foo", "bar"] },
{ value = "windows", if = ["foo"] },
{ value = "macos", if = ["bar"] },
]
will the tests run on each of the platforms or just we're specifying that if the platform is Linux then do this and so on & depending on which platform we're running either manually or in the pipeline the test will run accordingly
that says run on Windows if a given environment has a variable feature set to foo, macOS if it's set to bar, and Linux in either case
that specific example has a table that you can see here https://hatch.pypa.io/latest/tutorials/testing/overview/#all-environments
the incompatible platforms will not run tests and will output a nice message at the end saying so
Initially I thought that hatch will emulate those OS environment to run the tests but this makes more sense. 
Hatch now has an Action that I'm about to document which significantly speeds up installation 🙂 https://github.com/platformdirs/platformdirs/pull/282#issuecomment-2125890143
doesn't this model make install script versioning harder?
what do you mean?
usually action have org/name@version scheme, which allows for action versioning. your setup makes it that you are pointing to a branch and prevent users from locking the versions
true, which I'm going to document in a few minutes, one must use the commit hash
I think the benefit of being in the same repository outweighs that minor inconvenience (although at large companies security folks usually enforce pinning to commit hashes anyway)
They do
But those are normally the hashes of release commits
Which is how Dependabot can update the comment next to it -- the comment is just the tag
Pinning to the commit hash in the main branch for the app itself is just going to cause tooling to trigger update PRs for every single commit that you ever make, regardless of whether it's actually updating the action or not
it's in a separate branch, created without Git history (orphan branch)
I'm getting NotADirectoryError: [Errno 20] Not a directory: '/usr/bin/ruby' while doing hatch shell
Thread
is there any awesome hatch repo ? I found this one https://github.com/ischaojie/awesome-hatch
nothing official but for discovery I would recommend going to each plugin type in the docs and on top there is a list that I try to maintain for each
how can we use uv as default installer for all of the envs ?
do that for the default environment and any other base environments if you happen to define a certain inheritance hierarchy
the reason it's not the default is because I'm planning on upstreaming stuff to pip which would make it comparably fast (or at least significantly closer) but that won't be for a long time
what are those patches?
cache as unpacked wheels mostly, and if it's warranted rewriting the resolver based on pubgrub (but I don't know how much that would help versus the current implementation)
for the former that would of course be coupled with new installation options like symbolic/hard linking
There are further optimizations in the planning/draft stage for the current resolver fwiw.
something that would definitely help but I don't know if it's merged yet is the parallel downloads PR
the networking stack is not fully thread safe (being so old as you're aware) AFAIU
hmm, what do you mean? doesn't it just use a vendored version of requests?
if you mean requests itself is not thread safe then yeah lol I can imagine because I've encountered issues with that in the past
It would definitely make reinstallation of already installed requirement files (like during a nox/tox run) much faster. There's actually a stale PR for parallelizing the initial index page fetch (for top-level packages IIRC) although it's dead essentially.
I'm trying to get rid of requests everywhere I can in favor of urllib3 or HTTPX
Yea, the problem lies with the dependencies.
my secret hope is that I don't have to do anything because by the time I get to it it will already be done by Nvidia's new dedicated pip/warehouse maintainer 🤞
hmm not sure if it's public sorry let me check
yes okay good it's public, Barry Warsaw 🙂
Ah okay. Neat!
I have 2 more envs along with default & test. I have added uv as installer to default env.
so will it get automatically enabled for the rest 2 along with test ?
or it has to be explicit ?
ah ok. Yes it's still in the early days & I have been using rye for a couple of months now. so far haven't faced any issues with uv yet
uv is already the default for the hatch-test environment.
Setting it as the installer for default means it will be used for all environments
Cool thanks
That is what I was asking 😁
I'm seeing that some times hatch shell doesn't actually start the virtualenv. Saw this issue with pdm as well as poetry in the past. maybe an python venv issue? using zsh
@dull rapids being the VSCode Hatch expert, do you know? https://github.com/pypa/hatch/discussions/1569 I never use the integrated shell
Hello! I am trying to migrate a setuptools project to hatch, and have a few questions... Perhaps I can start with this one - Can I make hatch only create / use a single virtual environment for everything (the default one)? By everything I mean linting, testing, etc?
Is this not the hatch channel?
I should probably expand that the reason for my question is that Im struggling to find how/why I should work with multiple environments to start with, and what is the reason for their existence for simple projects like mine. It seems to me that a single virtual environment kind of setup might provide for a straightforward way to get some people (like me) to switch over easily...? Happy to be enlightened otherwise, but although Ive been browsing the documentation for the past day, I have not yet stumbled on the reasoning behind this scheme... 🙏
you can set the path option in the internal environments and the default environment https://hatch.pypa.io/latest/plugins/environment/virtual/#location
the main reason is to reduce chances of dependency conflicts, you really don't want everything in the same environment
Oh! so I could set path for hatch-test, hatch-static-analysis, and default to be the same and it would all use the same virtual environment as a consequence? great!
This may be what I am not clear on. The default environment is where I develop, and I want to run tests and the static checker in that environment...? Im not sure what the 2 extra environments buy me here
No clue why that would be. If you execute a process that opens a shell, executing exit in that one should of course only take you up one level.
If that person is talking about VS Code’s Python extension activating your configured environment: that happens in the spawned shell directly, not a subshell, so you can only get out by deactivating, not exiting.
Hello! Can I make hatch either use the platform name to name virtual environments or use a different parent dirs.env.virtual based on the platform? 🙏
no but that is an open feature request
Hi I'm getting Error importing plugin "pydantic.mypy": No module named 'pydantic' error while running pre-commit hooks. I tired runnig from different env as well. what am I missing ?
show your pre-commit spec
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0
hooks:
- id: trailing-whitespace
- id: check-added-large-files
- id: check-merge-conflict
- id: check-shebang-scripts-are-executable
- id: check-docstring-first
- id: debug-statements
- id: check-ast
- id: check-json
- id: check-toml
- id: check-xml
- id: check-yaml
args: ['--unsafe'] # needed for !! tags in mkdocs.yml
- id: end-of-file-fixer
- id: mixed-line-ending
args: ['--fix=auto'] # replace 'auto' with 'lf' to enforce Linux/Mac line endings or 'crlf' for Windows
# Ruff replaces black, flake8, autoflake, isort and more
- repo: https://github.com/charliermarsh/ruff-pre-commit
rev: 'v0.3.4' # make sure this is always consistent with hatch configs
hooks:
- id: ruff
- id: ruff-format
args: [--check, --config, ./pyproject.toml]
- repo: https://github.com/pre-commit/mirrors-mypy
rev: 'v1.9.0' # make sure this is always consistent with hatch configs
hooks:
- id: mypy
args: ["--install-types", "--non-interactive"]
additional_dependencies: [types-tabulate, types-cachetools]
you need to add pydantic to additional_dependencies in mirrors-mypy
cause pre-commit installs all those in separate env
Ahh I see thanks for the help 😃
Is there a way to specify which tests should be run depending on the platform. Ex. Say Run all tests(unit + integration) if running in linux & only run unit if running from windows ?
apart from specifying it in the [tool.hatch.envs.test.scripts] section
that is possible in pytest but I would look at their docs or ask elsewhere
is there an example repo for scikit-build-core with hatch
I’m a bit stumped: shouldn’t this work?
[project]
name = "scanpy-tutorials"
version = "0.1"
requires-python = ">=3.9"
dependencies = ["sphinx"]
[tool.hatch.build.targets.wheel]
bypass-selection = true # This is not a package
[tool.hatch.envs.default]
python = "3.12"
installer = "uv"
[tool.hatch.envs.default.scripts]
build = "sphinx-build -M html . ./_build {args}"
$ hatch run build
/bin/sh: line 1: build: command not found
I’m pretty sure this worked before. Why doesn’t hatch run run the script and instead tries to find some executable?
QUESTION: Using Hatch scripts / envts to replace pre-commit
hey everyone - i'm working on an example package using hatch and wondered if anyone has migrated away from pre-commit here --> hatch (and could provide me an example of what that might look like with tools beyond ruff, etc. If i am asking this in the wrong channel please direct me to the right place! many thanks 👐
also never use --install-typesin pre-commit - it breaks the assumption of pre-commit
is there any recommended hatch plugin for building c extensions with hpy ?
I don't know of any currently but later this year Hatchling will add built-in functionality for defining extension modules
I'm still working on workspaces, that's all I'm doing in my limited free time
kk, i'll defer trying to figure how to make pluggy support hpy speedups for now then
@umbral bridge i jsut realized i need to use \\instead of just \to split a hatch script comand into multiple lines - that one is quite a bit puzzleing (as i couldnt find it in the docs)
scripts.generate = """
datamodel-codegen \\
--input=openapi/openapi.yaml \\
--input-file-type=openapi \\
--output=model_codegen.py \\
--output-model-type=pydantic_v2.BaseModel
"""
works
single quotes
andi think i asked this before - but whats the correct way to reffer to a command thats the same name as the script
i dont follow, is there a rule in toml im missing?
single quotes denote raw strings
ah, you meant literal strings 🤦♂️
just don't have it as the first argument e.g. maybe bash -c test if you have a test script
Can we get a built-in !cmd command to aim for those?
I'm currently using env
But that's not portable
can you please open a feature request? also if you could please tell me why naming the script something else is insufficient for your use case
Hello everyone!
I am currently trying to setup hatch in my repository.
The thing is, the name of the repository, and of my main module inside my code is eve
But the metadata name of my project if sdl-eve.
When I try to perform hatch env create, here is my error:
❯ hatch env create
error: Failed to download and build: `sdl-eve @ file:///home/me/ws/sdlrep/eve`
Caused by: Package metadata name `eve` does not match given name `sdl-eve`
Here is my build configuration:
[build-system]
requires = ["hatchling"]
build-backend = "hatchling.build"
[build]
exclude = [
"coverage",
".eve",
".walle",
"tests",
"scripts",
]
[build.targets.sdist]
only-include = ["eve"]
[build.targets.wheel]
only-include = ["eve"]
When I was using poetry, just doing this solved the issue:
[tool.poetry]
packages = [ { include = "eve" } ]
By chance, do you have any clues?
Thanks !!
update: workspaces is coming along nicely but I didn't realize that a prerequisite would be better built-in support for the standardized build hooks so that's why it's taking a bit longer than I thought (and lack of free time). after this is over build will no longer be a dependency
Hi @umbral bridge ! Hope you're fine.
I was looking at an alternative for our poetry.lock
I thought it would be great to exploit the UV_EXCLUDE_NEWER environment variable.
I was wondering if I could dynamically set this environment variable value for hatch with the latest commit date of the pyproject.toml or hatch.toml.
Do you know if it is possible to set dynamically this kind of setting ?
Maybe instead I should override the command used by hatch when calling UV in order to add this flag dynamically at each command ?
Thanks!!!
why not set that environment variable directly?
Maybe I should just not forget to edit the date each time I change a dependency yes indeed 🤔
And not bother with dynamic value computing
https://github.com/juftin/hatch-pip-compile/tree/main
@umbral bridge Maybe I could just use this plugin if I want a lockfile, while we wait for a python standard !
Seems to be working great! Wonderful
@umbral bridge aware of any trick to make pycharm auto-find the hatch environment?
whats the recommended way to ramble now 🙃
I'm not sure but maybe set the environment path to .venv and it might auto discover?
When using hatch version, can we do some dry-run of the command ?
In order to get the next version proposal ?
Don't think so 🙂
Can be a good first contribution for me 😄
👋 Hello all. Im working on porting a project from setuptools/setup.py to hatch/pyproject.toml and Im wondering if there is an equivalent to scripts from setuptools to copy arbitrary scripts to the bin dir of the installed (v)env?
Ex. our project bundles a couple of python scripts for handling parsing gprof output
...
scripts=['scripts/geordi', 'scripts/gprof2dot'],
...
)```
shared-scripts https://hatch.pypa.io/latest/plugins/builder/wheel/#options
Awesome! Thank you
Its still advisable to migrate to the scripts entry point eventually
yes definitely, the only valid use case now in my opinion is distributing binaries like Ruff
Im not sure I know what that means, got an example?
the general suggestion is not to use actual script scripts, but rather have the cli bits be python modules with a entrypoint function, then using project.scripts section to specify those (that allows for the binaries to be more nicely managed by the installer, which gets you better platform support for the odd ones out (like windows)
Ahh the downside being any shell scripts will need to be refactored/wrapped?
it's mostly for the aforementioned cross-platform compatibility issue
from personal horror experiences with shell and how it can get wrong i like to enthusiastically recommend porting them to python whenever feasible
Same! haha
@tropic void did you used to work with bitbucket btw? Your name looks familiar
Never worked there, but back before they broke mercurial we had pytest on it
I work on it now, but I must have come across your name in public tickets or something
Likely
But I consider them responsible for the end of mercurial and stay far away, I'm really salty about it even after All these years
I think that is a perfectly reasonable take and Im privy to all of the inside baseball
From a "business" perspective, there simply werent enough paying customers using it to warrant the required R&D to continue supporting both libraries. But those lovely business calculations never seem to account for uhhh destruction of goodwill in the community
And the people in charge at Atlassian now are sooooo far removed from what Bitbucket used to be that it doesn't even register to them
When bitbucket was started,the founder was in the mercurial irc channel and bitbucket was on top of updating things
But enough with that, this is the hatch channel
definitely the best part of open source 💜
@half spire
re: #pypi message
You're extracting your sdist, but you installed your wheel, which doesn't include your data files
You need to explicitly include them in your wheel
Docs are here: https://hatch.pypa.io/latest/config/build/
tried including then in the wheel like this
[tool.hatch.build.targets.wheel]
artifacts = [
"*.configs/*",
"*-torrc"
]
but still it's not visible
That doesn't look right
Why do you have an asterik on the left side?
The path starts with .config, doesn't it?
try the artifacts option and also the packages option together
# Build configs
[tool.hatch.build.targets.sdist]
# include = [
# "src/**/*.py",
# ".configs/*"
# ]
exclude = ["build/", "dist/", "docs/", "tests/*", ".github/", "assets/", ".cruft.json", ".editorconfig", "mkdocs.yml"]
[tool.hatch.build.targets.wheel]
artifacts = [
".configs/*",
"*-torrc"
]
did something like this but still the same
ok I was able to solve the issue by doing this
# Build configs
[tool.hatch.build.targets.sdist]
include = [
"src/**/*.py",
".configs/*"
]
[tool.hatch.build.targets.wheel]
packages = ["src", ".configs"]
thanks
What, no bzr love? 🤣
Java things in python is still having seizures over that one
okay, the massive build refactor has been merged, now workspaces is unlocked once again
Is there a way to stop redefining deps for each env ?
this is my default env
[tool.hatch.envs.default]
installer = "uv"
dependencies = [
"click",
"rich"
]
& I need these for all of my 3 other env & I need the deps from lint env into test as well.
Perfect thanks
Is it necessary to pass the --cli option when making cli tools using hatch ?
no
I'm getting this error
from ape_utils._cli import main
ModuleNotFoundError: No module named 'ape_utils'
# Cli tool name & options
[project.scripts]
ape_call = "ape_utils._cli:main"
.
├── CONTRIBUTING.md
├── LICENSE
├── Notes.md
├── pyproject.toml
├── README.md
├── src
│ └── ape_utils
│ ├── __about__.py
│ ├── _cli.py
│ ├── __init__.py
│ ├── __pycache__
│ │ ├── _cli.cpython-311.pyc
│ │ └── __init__.cpython-311.pyc
│ ├── py.typed
│ └── utils.py
└── tests
└── __init__.py
what command are you running?
ape_call
the name I specified for the tool
https://github.com/Aviksaikat/ape-utils
here is the repo
tried hatch run ape_call as well same error
you shouldn't ever set build paths for wheels unless there is an error, the default behavior is correct
then hatch env prune and try again
ah ok thank you very much
how can i tell hatch to install an optional dependency inside an environment?
e.g. i want this to install myproject[full] and not myproject
[envs.test.scripts]
no-cov = "pytest --memray --native"
cov = "coverage run pytest --memray --native"
you have to speficy the deps inside the that env
take this example
[tool.hatch.envs.default]
installer = "uv"
dependencies = [
"myproject[full]",
]
[tool.hatch.envs.lint]
extra-dependencies = [
"mypy",
"ruff",
"myproject"
]
so for the lint env hatch will install the default deps as well as the extra ones defined in lint
If I define the deps inside the default env when I'm going to install the package using pip the default ones will be project deps right ? to get the lint deps we have to do pip install package[lint] right @umbral bridge(sorry for the ping) ?
well, that’s a bit inconvenient
i already have the dependencies specified in project.optional-dependencies, it’s a bit silly to redefine all of them
it also adds for more maintenance, i.e. if i add another optional dependency i have to add it in two places not just one
@winged cargo @half spire https://hatch.pypa.io/latest/config/environment/overview/#features
how does hatch publish auth creds looke like?
hatch publish -u __TOKEN__ -a $TEST_PYPY_SECRET -r test
is giving me 403 Username/Password authentication is no longer supported. Migrate to API Tokens or Trusted Publishers instead
the default behavior assumes a token and should work if you remove the username option; it looks like you capitalized the word token when it needs to be lowercase
ahh making it lowercase did the job thanks
it's pretty hard to navigate through the docs IMO. I think publishing should be under a same location ?
that's why I disturb you the most 😵💫
what should be moved?
the link you send. I mean the section where the token & all if defined. would be nice if it's inside the https://hatch.pypa.io/latest/publish/ page?
what do you think ?
there is a further resources section at the end
the pages at the start of the docs are meant to be a brief showcase of working with Hatch
I find it confusing & difficult. maybe a short N.B. or a highlighted link to the broader reference?
which part should be highlighted?
the authentication part IMO.
maybe it can be mentioned here ?
or inside > ?
is there a way to include deps which has prereleased deps ?
"eth-ape>=0.8.9" module has this dep for which I can't add it to my projects. have to use older version. Don't know this is an issue with uv or not
there's probably an environment variable that can control the behavior
if not there definitely is an environment variable for pip so you have to switch installers https://hatch.pypa.io/latest/config/internal/testing/#installer
or whatever environment you have that configured in, disable UV, I just happened to link the testing environment docs
yup it's an issue with uvswitching to pip works just fine.
is there a way to pass args to uv ? need to pass --prerelease=allow I guess
not yet, passing arguments is a an open feature request
can you share link to issue?
can i force hatch to use the downloaded pythons rather than available pythons?
https://hatch.pypa.io/latest/plugins/environment/virtual/#python-resolution
you probably want to set the python-sources option
I can't find it please open one
[tool.hatch.envs.main]
dev-mode = false
skip-install = true
python-sources = "internal"
dependencies = ["rich"]
``` is what i have
done
Hello, can we define the publish index in a repository config file ?
@umbral bridge More generally, i want hatch to use a local repository config file without specifying it every time in the CLI.
Otherwise, I would want to configure publish.index.repos url directly in my pyproject.toml.
is it possible? thank you very much!
@umbral bridge Hello! Hope you're fine?
I think I found a bug:
When scripting my release mechanism, I call hatch version from a subprocess.run.
As you can see, the result contains some hatch ouput (it's inside the command of course):
CalledProcessError: Command '('git', 'log', '--pretty=format:%an|%s', '--no-merges', 'vSetting up build environment for missing dependencies\n0.15.1..HEAD', '--')' returned non-zero exit status 128.
Then of course, I can use hatch --quiet
But when I use it:
🛑 Command '(PosixPath('/home/jcarlens/ws/sdlrep/eve/.virtualenvs/hatch/bin/hatch'), '--no-color', '--data-dir=/home/jcarlens/ws/sdlrep/eve/.virtualenvs/hatch', '--config=/home/jcarlens/ws/sdlrep/eve/config.toml', 'version')' returned non-zero exit status 1.
Setting up build environment for missing dependencies
error: the argument '--quiet' cannot be used multiple times Usage: uv venv [OPTIONS] [NAME] For more information, try '--help'.
It seems there is some conflicts with UV flags.
I also tried to use the env var HATCH_QUIET, same issue
(The image at the end is not relevant, uploaded by mistake)
oh, maybe..
Sounds like a bug in hatch though
@umbral bridge I wanted to get your take on supporting Trusted Publishing natively in hatch. I might find some time to contribute something but I don't want to reinvent the wheel, duplicate existing work, or build something you wouldn't be interested in. I'm aware of the GH action on the PyPA org, but I want support for GitLab. Any thoughts?
that's something I desire as well but is so far away (based on my own time allocation) that it's not even in my personal todo list so I would definitely appreciate that!
Okay, thanks! GTK I won't be duplicating effort. No promises on my time availability, but we'll see! Do you think that should be a publisher plugin, or built into the existing publisher command?
for prototyping I would recommend a plugin first so you know it works and then we could incorporate into the main code
Awesome, thanks. If/when I get to this, I'll open an issue on GH.
something else to note is that although there is an option to pass arguments it's not that pretty and actually at work I'm prototyping something with a different tool that has plugins to allow a msgspec struct/class to transform into Click options and expose that dynamically in the help text
I'm confident I'll get it to work however so whenever we have success internally I'll incorporate into Hatch
unless Pydantic is able to drastically improve model build times it looks like Hatch will be using msgspec for configuration for everything
for the curious, here is the issue https://github.com/pydantic/pydantic/issues/9908
Gotcha. And yep, I haven't actually used msgspec but I've been hearing good buzz about it.
maybe you knew this: in addition to the GH action, GitLab is also supported with Trusted Publishing now (and Google Cloud and ActiveState) https://docs.pypi.org/trusted-publishers/using-a-publisher/#gitlab-cicd
Yep! And using that doc, I've switched some projects over to this: https://gitlab.com/warsaw/gitlab-ci/-/blob/trusted-publisher/common-gitlab-ci.yml?ref_type=heads#L122
Basically, I'm thinking (long term) about hatch publish doing that recipe natively.
i'm having some trouble with environments, it seems setting dev-mode to false prevents the project from being installed in scripts
i'm having some trouble with
@umbral bridge is there a way to make command templates - im hitting a case where i have to run a similar command for a mapping - and it seems like i need to start using a build tool instead of hatch
what do you mean by template?
@umbral bridge kind of like shell aliases or functions - i moved that to a python script now as its a bit too complex for hatch scripts
I see, can you please give an example?
like have a command like openapi-code-generator .... --input = something{name} --package-name=something{name}and then calling it with different values for name
use a matrix with variables?
actually in your particular example you can just do {args} at both spots
@tropic void does that suffice?
@umbral bridge not quite - im having more than one thing i need as a variable in the end
probably nothing more can be done unless you want to make your commands Python scripts e.g.:
foo = '''python -c "\
import stuff
use {args}
...
"
'''
i made an actual python script - hatch shouldnt invent a way to make "scripts" simple "functions"
that sounds like the better way
Hi @umbral bridge - could you PTAL at this PR? https://github.com/pypa/hatch/pull/1645
When downgrading with an explicit version number, normally hatch will raise an error. While validate-bump can be provided in the config file, it's useful to be able to override this check ...
I'm so sorry I dropped the ball on that! I will sometime this work week in the evening
Thank you!
Hello, currently what is the normal workflow when you update a dependency and you're working on your IDE ?
For example with poetry, a notification on VSCode remind you that you should run a poetry command to update the environment, for hatch, I am performing hatch shellcommand manually, and hatch --env=tests shell to also update other environments for example.
I was wondering if for now it was the normal flow of doing this ?
Don't think there is a command to update all environments right?
is there a non enviroment variable flag that tells hatch to install the latest pip onto a env?
@umbral bridge i picked up https://github.com/pytest-dev/pluggy/pull/445 again and derived a solution that works for pytest - a little bit more cleanup is needed, but then pluggy is a orders of magnitude faster import
note that https://github.com/pytest-dev/pluggy/pull/466 already shaved off half for importlib
how far away are we from getting editable installs for the scikit-build-core plugin?
how far away are we from getting
I'm sorry I've had minimal free time for the past few months but I swear workspaces is really close, the first test is passing
also, overall, development will be more rapid for two reasons:
- I introduced a new CLI at work where I did a significant amount of experimentation and a lot of it was successful so will be incorporated and cleanup some internal stuff I've been displeased with
- I'm no longer discouraged by the speed of UV development and have accepted that I cannot compete with a dedicated team and understand that there are many benefits to Hatch in comparison which I will talk about in one of the upcoming release blog posts
I really enjoyed your PyCon US talk, it was cool to see all the good UX stuff in Hatch
did they ever respond about giving the PSF access?
I made a release based off of the previous minor just to allow folks support for managing Python 3.13 (including freethreaded) https://github.com/pypa/hatch/releases/tag/hatch-v1.13.0
how do i specify the free threaded versions? 3.13t, 3.13 didn't work for me, it just went thru the normal 3.13 and seems like silently skipped 3.13t
i saw that, it's still not clear to me how it would go in the pyproject.toml
python = ["3.13", "3.13-freethreaded", "3.13freethreaded"?, "3.12", "3.11", "3.10", "3.9", "3.8"]
env vars
wouldn't that force free threaded only for 3.13?
can i set env vars in the pyproject?
[[tool.hatch.envs.hatch-test.matrix]]
python = ["3.13", "3.12", "3.11", "3.10", "3.9", "3.8"]
[[tool.hatch.envs.hatch-test.matrix]]
python = ["3.13"]
gil = ["freethreaded"]
[tool.hatch.envs.hatch-test.overrides]
matrix.gil.env-vars = [
{ key = "HATCH_PYTHON_VARIANT_GIL", value = "freethreaded", if = ["freethreaded"] },
]
ah, was about to ask again how to modify the one i had, which is
sorry, i struggle with your pyproject.toml it isn't intituitive to me
[[tool.hatch.envs.main.matrix]]
python = ["3.13", "freethreaded", "3.12", "3.11", "3.10", "3.9", "3.8"]
matrix.version.env-vars = [
{ key = "HATCH_PYTHON_VARIANT_GIL", value = "freethreaded", if = ["freethreaded"] },
]
so we have to duplicate tool.hatch.envs.hatch-test.matrix seems weird
it's not duplicating, it's adding another series
GitHub Actions has a similar matrix concept https://docs.github.com/en/actions/writing-workflows/choosing-what-your-workflow-does/running-variations-of-jobs-in-a-workflow#example-adding-configurations
Nonexistent matrix variable must set a default: python
i get this with that
Yes and the PSF now has access. I've been setting up the CPython releases to use it (been away for a few days so it's not quite finished yet, but this week). There'll likely be a discussion needed (with Ee, initially) about providing access to other projects, but technically it can now be done.
that's awesome, thanks! I'll reach out to Ee in a few weeks about that
yes that shows what is available
ah okay, i was confused because i was expecting hatch env prune to clear out any envs shown by hatch env show
I'm reading through the docs for build hooks as I'm interested in adding files to the list of includes or not based on libmagic data. But if I'm reading the docs correctly, that isn't possible if I want to use the wheel target?
force_include- https://hatch.pypa.io/latest/plugins/build-hook/reference/#build-dataforce_include_editable- https://hatch.pypa.io/latest/plugins/builder/wheel/#build-data
(afk for dinner)
So in my initialize function in the build hook, the function looks like
def initialize(self, version: str, build_data: dict[str, Any]) -> None:
build_data['force_include']['namespace/dir'] = 'namespace/dir'
But that doesn't actually make the directories in the wheel, the only contents are the dist-info directory.
(namespace/dir are directories, with dir having no contents)
(updated above s/update/initialize, it's a build hook not a metadata hook 🙂 )
Put up a demo repo: https://github.com/ethanhs/hatch-hook-demo
what command are you using to build?
oh, you're trying to ship directories without files?
that's not supported, although I'm interested in hearing why you think that should be supported
Ah, I think I just didn't realize it was failing only for directories
actually that's not supported by the spec as far as I can tell, you can't derive metadata to put inside the RECORD file
It might be good to raise an error in that instance then
that wouldn't make sense in this case because the directory does exist
an error already is thrown when a forced inclusion does not exist
But I don't currently see an error when I build the above
did you make a modification or are you saying you don't see an error how your reproduction repository currently exists?
I do not see an error with the state in the git repo
yes, that is correct behavior because the directory exists
add a foo to the key in the forced inclusion mapping and then try again
That does error. But shouldn't it be an error to try to force_include a directory that is empty?
no
Why? If it doesn't get included in the wheel I expect that would be surprising
it is included in the wheel, there just happens to be nothing in the directory
oh I think you misunderstand, the empty directory doesn't end up in the wheel
$ unzip -l dist/demo_hook-1.0-py2.py3-none-any.whl
Archive: dist/demo_hook-1.0-py2.py3-none-any.whl
Length Date Time Name
--------- ---------- ----- ----
370 2020-02-02 00:00 demo_hook-1.0.dist-info/METADATA
105 2020-02-02 00:00 demo_hook-1.0.dist-info/WHEEL
1095 2020-02-02 00:00 demo_hook-1.0.dist-info/licenses/LICENSE.txt
307 2020-02-02 00:00 demo_hook-1.0.dist-info/RECORD
--------- -------
1877 4 files
yes I do understand that is the correct behavior. you're defining configuration that says "the contents of this directory should be mapped to this path inside the wheel" the directory does exist and everything is working properly but it just so happens that the directory is empty
if the directory didn't exist that would be an error
Oh, I see, I didn't realize force-include when referring to directories included their children. That makes much more sense now. I thought it was merely specifying that path x should be placed at path y in the wheel
Thank you for the explanation!
ah I see, happy to help!
Is there a way to make hatch run/hatch test execute a build plugin every time? (Or better every time a file from a set of file changes)
I use some codegen in one of my projects and I’d like to make sure that my dev environment stays synced with changes.
Currently I need to remember to do hatch env prune/hatch env remove ... whenever the codegen changes.
you can change your scripts to always have an initial command that does what you want
I just got told that my “wonderful” hatch plugin doesn’t even work.
Trying to make it work results in infinite recursion, because I currently evaluate WheelBuilder(self.root).config.packages, which in turn calls the metadata hook again.
Any idea how to fix this more elegantly that inspecting the stack? https://github.com/flying-sheep/hatch-docstring-description/pull/73
interesting.. I would recommend using the raw_config dictionary to get the value you want
@umbral bridge, first off, I wanted to say nice to meet you. I've been a user of hatchling, hatch, and pyapp (which is my personal favorite) for some time now, and I enjoyed your session at this year's PyCon. PyApp really solves the packaged application distribution in an elegant way.
To stay up to date, I've been moving a few PDM based projects to uv, but hit some differences in the generated source and wheel files. These difference have left me wondering which is correct.
Here is the specific question I opened on the UV repo: https://github.com/astral-sh/uv/issues/8833
After re-reading the hatchling docs and re-testing with hatch. It seems like the behavior you've documented is correct. In summary, I can use this:
[tool.hatch.build]
dev-mode-dirs = ["."]
sources = ["."]
[tool.hatch.build.targets.wheel]
artifacts = ["**/public/*"]
packages = ["app"]
instead of this:
[tool.hatch.build]
dev-mode-dirs = ["."]
ignore-vcs = true
sources = ["."]
[tool.hatch.build.targets.wheel]
packages = ["app"]
Is my understanding of artifacts correct here?
hey, thanks!
the difference between tool behavior is due to your use of the global [tool.hatch.build] table which is used as the default for every target. in hindsight this was a big mistake for me to implement or at least document which is why the docs are updated to never do that
you should never use the global table. what is happening is that the table is configuring the build for source distributions and build and UV by default build a source distribution and then build the wheel from that but Hatch does not (and I'm assuming based on your description that neither does PDM)
OK, let me make sure I got it. I need to refactor my setup so that I no longer tool.hatch.build in my pyproject? Also, now that I revisit the docs, I don't see a reference for this there. I guess that's what you mean by "docs are updated"? 🙂
yes exactly configure the targets individually
basically with UV (and future Hatch default behavior) you have to think about what will be included in the source distribution and what you configure for the wheel will be based on its content e.g. if you exclude a file from the source distribution then it won't be present to include in the wheel
Got it. Thanks for the quick reply.
Is this also the right place to ask pyapp specific questions? I don't see a specific channel for it.
anytime! and yes you have to scroll to the bottom in the other projects section
I see it now 🙂
In case anyone is interested in a different way to use meson to create python packages, I've ported meson-python to hatchling: https://github.com/virtuald/hatch-meson
I'd think it would be good to cross-post that to #meson-python
I'd think it would be good to cross-post
Is it possible to define a version plugin via hatch_build.py alongside the rest?
I need to generate a dynamic version from git, but from a submodule not the current repository, so versioningit doesn't work OOTB. But when I try to define a version plugin in hatch_build.py and set its PLUGIN_NAME as tool.hatch.version.source, build tells me it's an unknown source.
vcs and versioningit define an entry_point, but I don't think that can work for the project trying to use the thing (and it certainly doesn't seem to work to define a project.entry-points.hatch whose value is set to "hatch_build"
i beleive you need to use the custom plugin for worktree based plugins - off hand i dont recal lwhere the detail docs are
custom builder?
its what makes the build hooks work for the hatch_build plugin - but i jsut took note that theres no variant for version sources as far as i can tell
that should be able to allow version modifications but you won't get interoperability with the hatch version command
ah, so the metadata hook provides version in that case?
I think metadata hook is what I tried first, but it didn't make hatch happy with dynamic = ["version"] which is what I'm trying to fix
you would have to link your code
Aha, thanks, I think when I tried metadata hooks the previous time it might have failed to work because I didn't get the registration stricture correct (I think I missed that I had to add a [tool.hatch.metadata.hooks.custom] in addition to the [tool.hatch.build.hooks.custom], the metadata hook does seem to work and correctly set the dynamic version field once it's actually correctly hooked in 🫡
Any idea why in this repo: https://github.com/eguiraud/hatch-bazel-and-pybind11/tree/include-problem-repro-bis the second nested folder is not included in the SDist (hatch_bazel_and_pybind11/cpp/submodule/submodule.h is missing). You can manually include it and it still doesn't show up, only with force-include/only-include
I haven't tried all the combinations Enrico has but I did verify that the folder is missing from SDists.
FYI, he opened https://github.com/pypa/hatch/issues/1817.
I've got a question re: the pre-built python that is installed by hatch.
I've found a few Xeon based machines where the python build does not work. I am assuming this is is because of the CPU variant configuration it was built with.
In PyApp, you can set PYAPP_DISTRIBUTION_VARIANT_CPU to get a specific compiled version. Is this possible with hatch python install?
Hatch doesn't support dependency groups yet, correct? It would be really nice for mixing a bit of uv and hatch.
correct not yet, what's your use case?
Hi, how can we install the deps from default env into another env like test without writing them again ?
I haven't set skip-install to false but default deps are missing idk why
test env deps
default env deps
[...]
# Default env dendencies
[tool.hatch.envs.default]
dependencies = [
"pydantic",
"google-cloud-kms",
"eth-account",
"eth-utils",
"eth-keys",
]
installer = "uv" # or "pip"
post-install-commands = ["pre-commit install"]
[project.optional-dependencies]
dev = [
"ipython",
"web3"
]
[...]
# Testing env dendencies
[tool.hatch.envs.test]
dependencies = [
"pytest",
"pytest-cov",
"eth-account"
]
[tool.pytest.ini_options]
addopts = [
"--verbose",
"--strict-markers",
"-ra",
"--cov=src/google_cloud_hsm/",
"--cov-report=term-missing",
"--cov-fail-under=80",
]
markers = [
"integration: marks tests as integration tests",
"performance: marks tests as performance tests",
]
testpaths = ["tests"]
python_files = ["test_*.py"]
python_classes = ["Test*"]
python_functions = ["test_*"]
what am I doing wrong ?
as per https://hatch.pypa.io/1.12/config/environment/overview/#dependencies use extra-dependencies instead of dependencies
thanks
Hi, everyone Merry Christmas. I was using pycharm and saw that it doesn't detect the vritual env created by hatch then I get to know about this workaround
[tool.hatch.envs.default]
type = "virtual"
path = ".venv"
So it got the thinking what's the reason behind this choice of design ? I can definitely see a upside is when we're out of storage we can easily clean all of the envs from one place without going to the individual projects much like conventional virtual envs.
mostly because I personally dislike it
I don't want my working trees cluttered and would prefer centrally managed data directories
additionally, beginners are prone to checking in data that is undesirable like virtual environments or log files
I like this design more TBH.
too bad pycharm is not supporting it yet
I was able to add the virtual env created by hatch
but noticed with this approach some of the deps are missing. So when I shelled into docs env only the extra-dependencies got installed and not the docs deps so I'm guessing doing this only won't shift the whole venv into the currect dir
only the default one as far as I understood. and docs and other deps will still be inside the default location
all options should respect inheritance I think, perhaps try re-creating?
@umbral bridge hatch test is incorrect by forcing the no args pytest arg to be tests - its quite a pain - default testpaths in pytest have a config var that pytest cannot use if one incorrectly passes a path by default
also the common pattern is to use testing as folder name as tests actually shadows stdlib package
your first point is correct and that is a bug fix I have to do, but the folder name is almost universally tests I've never seen the name testing in the wild ever
all pytest related pacakges use it and afair we also document it in the docs
fair, but I think even in a few decades everyone is still going to name the directory tests and I have no desire to change that default
just dont pass anything and let pytest decide
no Hatch just needs to learn how to read the arguments for pytest and if there are none default to the test directory
without a default the performance is suboptimal because pytest has to scan everything in the current directory
that's actually literally the only reason I made a point to have a default, for performance and accidental test recognition of user code
then at least prominently docment how to return pytest to its default behavior correctly as part of the test docs
bbl, family is back
@tropic void enjoy the holiday with your family! when you return I'm curious about an idea I just had, what if pytest added a new option that would only consider a single top level directory that appeared to be for tests e.g. named test, tests or testing? if there was such an option I would completely remove the default argument logic from Hatch
you mean the testpaths option which is a lsit of relative paths
no I mean to have a new flag which would make pytest be smart about which top-level directory to target based on the name
and depending on usage I would imagine that flag being enabled by default after a while because that is better as I mentioned above
for performance and accidental test recognition of user code
Pytest supporst tests in packages tests at the toplevel ans some more
That fla eill be a pain in the neck but most likely worth it
do you know of an open feature request to change the behavior/add the flag? if not I can open one for you
Theres none open for the case you made
Also just noticed mkdocs is using the cached response from the first build. even after doing a build with --clean and removing the sites dir completely it's returning the pages from the very first build. Only work around was to remove the venv complety by doing hatch env prune
added this line. and no change here
after env prune now it's there
Doing this created 1 problem now. When I'm installing the module which is setup like this the deps are not getting installed
[tool.hatch.envs.default]
# https://hatch.pypa.io/1.12/config/environment/overview/#dependencies
extra-dependencies = [
"pydantic",
"pydantic-settings",
"google-cloud-kms",
"eth-account",
"eth-utils",
"eth-keys",
"ecdsa[gmpy2]",
"cryptography",
# "rich", # typer will include it
"typer"
]
when the field was dependencies only I think it was fine. but changing it to extra-dependencies they are not getting installed along with module itself
My usecase. My project is using the above deps. And I want them to be installed in my other envs like docs & test and don't want to define them manually for all of the envs.
This config is working fine but when I'm trying to install the project the deps are not installed .
Extra dependencies need to be in the other envs not tge default
Dependencies for the package itself go to project dependencies instead of hatch related ones
is this a new update ?
bcz last time I used hatch defining deps in the dependencies section of the default env was enough to inherit other envs
or I'm horribly wrong ?
Please see the linked documentation
Extra dependencies are specifically to extend similar to ruff and other tools enabl expending on defaults
@umbral bridge any opinion on having hatch fmt default to invoking pre-commit in case its configured?
I wouldn't mind an option but that will never be the default
Gm everyone. I was wondering if we are going to see hatch add any time soon ?
is there any way to define the projects deps with latest versions without browsing through pip or github for the latest version number ?
use dependabot
afaik hatch takes the latest version but sometimes it takes the latest compatible version of the deps to avoid dep collitions right ?
by default the versions are not mentioned
please describe exactly what you're trying to do, I don't really understand what kind of workflow you're talking about
ex. here these are my project deps right. so when we use other tools like pdm, rye they add a minium version number like say
pydantic>=2.14 or whatever the latest but in hatch we don't have that. we have to manually add the deps into dependencies section. sometimes it becomes very hard to keep track of the version of say 10,20 deps. So I was wondering if threre is a better way
are you developing a library or application?
library
then you want the dependency range to be as wide as possible and only limit based on what you know to not work
the other tools that you mentioned, or anything related to "locking", are mostly geared toward applications
is there a way to pin versions other than manually ?
you can use automation like dependabot or write a script, what do the other tools do that you're trying to emulate? I'd like a concrete example of what command does what in some other tool
True but some modules have breaking changes like pydantic 2.0 so the module was built on top of that so want to force the users to use pydantic 2.0 otherwise they'll get unnecessary complications
so in that case you would limit the range, that sort of matches what I said about known issues right?
So the main library I'm working with is web3.py which is in the dev deps section of my module.
To extend it's functionality. But web3.py has some breaking changes from release 0.7. Many people are using 0.6 still. So people can use the module I'm building along with web3.py to build theirs. But the problem will be if they use version 0.6, pip will try to pin the version to 0.6 also for my module which will break it's functionality. If that makes sense
can you please give me an exact example of what another tool like Poetry does that you wish Hatch did?
[project]
...
dependencies = [
"web3>=0.7",
]
hatch can do this but we have to define the versions manually
rye add web3 will add something like this
dependencies = [
"web3>=7.6.1", # latest version as min.
]
poetry is shit it defines upper limits which sucks. Don't want hatch to go down that road. 🤖
I see. so even if Hatch gained such a command it would not do what you're asking because that wouldn't be good for libraries, I would add exactly what one types at the command line
Yah simple
hatch add web3
should add the latest version as bare minimun which will be
dependencies = [
"web3>=7.6.1", # latest version as min.
]
in this case
unless people specify the version like hatch add web3==0.6 or something else
that would be nice
sorry let me rephrase to be more precise: Hatch will never automatically set the minimum to the latest version because that is bad for libraries
say you add dependency foo which requires the latest version and now somebody uses your library, if they also use foo they are now restricted to the latest version
So there's no way not in future also to add deps versions automatically other than manual ?
I'd be totally fine with a flag to the add command but it would never happen by default
do you understand my reasoning regarding the applications vs libraries bit I mentioned?
👍
that would be a nice thing to have so we can add multiple deps at once with the add command
is there any way to get hatch to build a dependency via a (relative) path in an environment? i'd like to use hatch test for testing, but I have a specific extension module (using setuptools) that is needed for my test suite. it would be nice if I could do something like:
[envs.hatch-test]
extra-dependencies = [
"./tests/extension_module",
]
use the direct reference syntax https://hatch.pypa.io/latest/config/dependency/#local
does hatch support setting the version tuple here?
[tool.hatch.build.hooks.version]
path = "codeflash/version.py"
template = '''
__version__ = "{version}"
__version_tuple__ = (0, 0, 0)
'''
[tool.hatch.build.hooks.vcs]
version-file = "dir/version.py"
[tool.hatch.version]
source = "vcs"
tag-pattern = "release/(?P<version>[0-9]+\\.[0-9]+\\.[0-9]+)"
[build-system]
requires = ["hatchling", "hatch-vcs"]
build-backend = "hatchling.build"
i think i've got it 
man, the amount of logic that exists simply for handling versions magically... is nuts
it's cool, but I've lost track of all of the different ways to handle the version
Hatch currently uses @tropic void’s setuptools-scm for that, which he plans to split into multiple packages. Once that’s happened, it think it’s possible to integrate hatch-vcs’s documentation more cleanly with the new backend package, reducing confusion.
Well it all started as clone of the logic behind mercurial setup.py about 15 years ago
Then came feature requests
if i have a set enviroment called test;
how can i make another enviroment; say plus, inherit all the depencencies of the test enviroment?
i swear i went thru that before coming here, let me take another look
oh it's template isn't it
thanks!
not sure if i should be asking here or in the uv server
[tool.hatch.build.hooks.vcs]
version-file = "codeflash/version.py"
[tool.hatch.version]
source = "vcs"
tag-pattern = "(?:^|^v|^release/)(?P<version>[0-9]+\\.[0-9]+\\.[0-9]+)$"
[build-system]
requires = ["hatchling", "hatch-vcs"]
build-backend = "hatchling.build"
i'm using hatchling as the build backend, are there any utilities for bumping versions for release?
If the source is VCS?
I think we'll support this via a uv command which emits the bumped version, which you'd pass to your VCS
yup
yeah i'm trying to move us out of https://github.com/mtkennerly/poetry-dynamic-versioning into uv, and thought using the hatch backend + hatch-vsc would be easy enough
there's a few different ways. I'm using hatchling+hatch-vcs (for example) and then use Release Drafter to bump the version tags.
I add Keep a Changelog labels to PRs, and Release Drafter then knows which SemVer tag to use next: if there's a Fixed, it's patch. if there's an Added, it's minor. if Removed, it's major.
and it creates a draft release, I only need to publish the release, that does the tag and GH Release and uses Trusted Publishers to upload. so I can release from my phone from wherever
Does hatch(/hatchling) support building two distribution packages from the same source tree, with different files included?
I'm looking to convert a package (phonenumbers) to use pyproject.toml. From the same source tree, we need to generate the main package, and a 'lite' version that strips out ~2MB of data files. My first attempt was using a custom build script that swapped out pyproject.toml files, but I wondered if a more fully featured backend like hatch would support this.
The handful of resources I've found online seem tailored to a monorepo, where you would distribute different subfolders that contain full sub-packages, rather than excluding individual modules/datafiles
I think since the spec says the name of the project cannot be dynamic that Hatchling wouldn't allow you to override that dynamically using a hook
what about a different directory you build that just contains a pyproject.toml?
Sorry, yes, the idea is that we create a subdirectory to contain a pyproject.toml for the 'lite' package
I just haven't found a configuration that works!
show config?
[build-system]
requires = ["hatchling", "hatch-fancy-pypi-readme"]
build-backend = "hatchling.build"
[project]
name = "phonenumberslite"
dynamic = [
"readme",
"version",
]
[tool.hatch.build]
exclude = [
"phonenumbers/carrierdata/*",
"phonenumbers/geodata/*",
"phonenumbers/tzdata/*",
]
[tool.hatch.build.targets.sdist.force-include]
"../phonenumbers" = "./phonenumbers"
"../HISTORY.md" = "./HISTORY.md"
"../LICENSE" = "./LICENSE"
"../../README.md" = "./README.md"
"../tests" = "./tests"
"../testwrapper.py" = "./testwrapper.py"
[tool.hatch.build.targets.wheel]
packages = ["phonenumbers"]
[tool.hatch.version]
path = "../phonenumbers/__init__.py"
[tool.hatch.metadata.hooks.fancy-pypi-readme]
content-type = "text/markdown"
fragments = [{ path = "../../README.md" }]
The wheel seems to be correct, but the sdist includes the datafiles I want to exclude.
I haven't found a way to get the README inclusion to work (as project.readme = "../README.md" is invalid), so I've resorted to dynamic generation via fancy-readme
it depends on how you build at that point, if you build using Hatch then the wheel builds from the source directory whereas if you use build or UV then you build from an unpacked source distribution
Right, I'm trying to make it build-tool agnostic
For either building from sdist (like build) or building a wheel directly (like pip install)
force-include works as currently set up if I use build, but building a wheel directly is broken (the build succeeds but contains only metadata files)
I thought about this for a few hours and took a look at other cases of folks running into this and issues and I think the solution is for the wheel target to gain new duplicate file inclusion options suffixed by -from-sdist that only take precedence when the project directory has a PKG-INFO file
what do you think?
Please could you elaborate on "duplicate file inclusion"? I don't see any results on searching for "duplicate" in https://hatch.pypa.io/latest/config/build/
no I mean introduce options that are literally duplicates of the current options but with the suffix
yes
I think this would solve the 'building a wheel directly' case, but I don't think it solves the problem of the sdist itself including too much data
up to you whether you think -from-sdist or the inverse -from-source is better
oh I may have missed a requirement, what do you mean?
The config above has ../phonenumbers = "./phonenumbers" in the force-include section. I then also have the three modules/subdirectories I want to exclude in the exclude section.
The force-include config seems to take precedence over exclude, meaning the entire directory is included. I tried using a negative glob in force-include but (very reasonably) that config only allows literal paths
So building a distribution package with the above config leads to the wheel being the right size (~0.2MB) but the sdist containing the extra 2MB of content we want to exclude from the 'lite' package
Sorry if this was unclear, my mistake.
I would recommend never ever using the global [tool.hatch.build] config, it was a mistake on my part because it has caused a significant amount of user confusion
Let me try with the same config but build.targets.{sdist,wheel}
Ok, I've removed the global table and tried with the targets tables. Only the targets.wheel.exclude array seems to have any effect, the sdist is consistently the same size
I've tried both using ./ paths (for after the force-inclusion has set up the sdist virtual source tree) and ../ paths (to reflect the actual source tree filesystem)
one last question: what about using a negative glob for artifacts? I know this is hacky but just trying stuff
I added the below to try every path combination at once, but doesn't seem to work:
[tool.hatch.build.targets.sdist]
artifacts = [
"!../phonenumbers/carrierdata/*",
"!../phonenumbers/geodata/*",
"!../phonenumbers/tzdata/*",
"!phonenumbers/carrierdata/*",
"!phonenumbers/geodata/*",
"!phonenumbers/tzdata/*",
"!./phonenumbers/carrierdata/*",
"!./phonenumbers/geodata/*",
"!./phonenumbers/tzdata/*",
"!/phonenumbers/carrierdata/*",
"!/phonenumbers/geodata/*",
"!/phonenumbers/tzdata/*",
]
okay yeah then there must be a branch just for forced inclusions that it ignores everything else
you could do a custom build target that would inherit from the wheel builder and modify a method I think to get the desired behavior
Do custom build targets work with third party frontends (e.g. build or uv build)?
I'm very concious I'm contributing this to a project I'm not the primary maintainer for, so I want to keep things as simple as possible
taking a step back, how would you fix this i.e. what would your preferred UX be for this scenario?
Currently packaging for the project is done as ./setup.py / ./setup.py lite -- the file checks sys.argv at execution time!
As you said earlier, project.name can't be dynamic, so I think there must be two pyproject.toml files. Thinking out loud:
- I think I would expect to have
pip install .'just work' in the main project directory, so - the 'lite' version of the package needs to have its own metadata in a sibling or child directory.
- I'd want to avoid symlinks as much as possible (e.g. they are difficult on Windows), so replicating the project layout in the 'lite' directory with symlinks is not an option
- The modifications from the 'full' package only relate to file selection -- all other metadata remains the same (save the name)
- Building the package directly as a wheel must result in the same output whether from an sdist or the directly from the source tree
- Using third-party build frontends should be possible
I am a big fan of Hatch's path-rewriting via force-include, as it allows creating a 'virtual' filesystem for the distribution package that avoids actual file operations
A slightly radical suggestion:
The specification notes that:
"The lack of a
[project]table implicitly means the build backend will dynamically provide all keys."
Would it be possible to have something like:
[build-system]
requires = ["hatchling"]
build-backend = "hatchling.build"
# no [project]!
[tool.hatch]
inherit-pyproject-from = "../pyproject.toml"
[tool.hatch.override]
name = "phonenumberslite"
[tool.hatch.override.build]
exclude = ["replacement-excludes"]
This would take the metadata from the "inherited" pyproject.toml, and then supplant it with some additional metadata -- including allowing changing the name, as there is no [project] table (the inherit functionality and the project table would be mututally exclusive)
A more gradual proposal (instead of pyproject inheritance!) would be adding some more granularity to the path-rewriting logic, and perhaps e.g. resolving symlinks and replacing them with the files that they link to (as currently done by setuptools).
my instinct is to go with the radical approach because using a single line in a spec as a loophole sounds hilarious to me but let me sleep on that and circle back tomorrow. thank you for brainstorming here!
It may also be worth bringing this discussion to e.g. Discourse / somewhere more public if there is more merit to it than just my case at hand -- sorry for opening the can of worms!
Hey I'm having issues specifying the python version in hatch
I'm trying to use python 3.6
[tool.hatch.envs.default]
python = "3.6"
installer = "pip"
type = "virtual"
specified like this and getting the error RuntimeError: failed to find interpreter for Builtin discover of python_spec='None'
$HOME/.pyenv/shims/python3.6 is the path of python3.6
is python 3.6 not supported ?
more context is needed, also please note that python 3.6 is end of life since years now - its possible that a number of tools simply cant support it anymore
the oldes not end of life version of python is 3.9 - and it wil lbe eol in about 7 months
if you need to use python 3.6 - then you wil lhave to ensure compatibility for everything you use as most software these days simply doesn't even support 3.8 in their latest versions
scientific python is on min 3.11 these days
i was trying an old project that's why I needed 3.6. turns out 3.7 has also issues. So I'm guessing anything <3.9 would cause issues and won't compile
Most likely
There's some tools that help to pin dependencies for as available a few year's back
Those may be helpful to find a initial arrangement
I didn’t know that the dependency groups PEP has been accepted, nice! @umbral bridge what do you think of https://github.com/pypa/hatch/pull/1922?
I feel like it would definitely do the trick, but maybe dependency groups and environments should be tied together more tightly? Maybe dependency groups should be an alternative way to specify dependencies for epynomous environments or so?
[dependency-groups]
hatch-test = ["pytest", "foobar"]
the PR seems reasonable but I just don't have time
The lockfile PEP has been accepted! https://discuss.python.org/t/pep-751-one-last-time/77293/150
indeed, the most joyous of days!
oh so they turned the new uv release obsolete ?
cuz they advertised the very same feature iirc
I don't see any mention of PEP 751 support anywhere in the recent uv releases...
They just opened an issue for it "8h ago"
https://github.com/astral-sh/uv/issues/12584
Nice! So I definitely won't have to hesitate about starting to implement it for my own project.
How does one skip/exclude certain matrix entries? Someone asked here, but got no answer: https://github.com/pypa/hatch/discussions/1923
I don't think there is a nicer way than https://hatch.pypa.io/latest/config/environment/advanced/#name-overrides currently
I just responded with an example
Thanks!
did that work for you?
We’re making a cookiecutter template that generates projects that people should be able to modify, without too much complexity, so I think for that purpose, not really.
can you provide a concrete example of how that relates to ignoring a particular environment based on the value of multiple matrix variables?
Ah I see you replied in the GitHub discussion! Thanks! Copying your response:
[[tool.hatch.envs.hatch-test.matrix]]
deps = ["stable", "pre"]
python = ["3.13"]
[[tool.hatch.envs.hatch-test.matrix]]
deps = ["stable"]
python = ["3.10", "3.11", "3.12"]
[tool.hatch.envs.hatch-test.overrides]
matrix.deps.env-vars = [
{ key = "UV_PRERELEASE", value = "allow", if = [ "pre" ] },
]
I tried to document the fact that it's an array of matrices on top of the introductory matrix section https://hatch.pypa.io/latest/config/environment/advanced/#matrix
Thank you so much for the continued work.
I think in this case, it's totally on me. I just haven't thought about the fact that it's an array at all beyond the first time reading the docs
no worries! it's basically a requirement to have a series of matrices rather than just one, quite like the format of GitHub actions jobs
or if you're familiar with tox, that list of strings on top with each one being a generator of environments
does hatch/hatchling support dependency groups?
not yet, there is an open PR
Hatchling wouldn't support that because it's not package metadata, it's part of Hatch environment config
next pip release is the weekend of 26/27 April, to hop over Easter https://github.com/pypa/pip/issues/13185#issuecomment-2807401666
ah, nice
@umbral bridge any oppinion on adding a sdist mode to hatchling that would createa dist with the metadata included and no need for any dependencies for install - im thinking of creating a meta build backend that allows sdists with vastly smaller footprint (just including dist-info and the metadata to make the whell for pure python packages
you could do that currently with a custom build hook conditional on an environment variable
i plan to solve the bootstrap problem in multiple layers - first step is a meta buidl system that can build a reproducible wheel for pure python from statically shipped metadata + the sdist files, then i hope to expand to workspaces with vcs checkouts
so you want a source distribution but the only difference is to strip out the required dependencies from metadata?
yes - the recent importlib metadata vs setuptools_scm breakage made a mess - and a practical way to solve the from source bootstrap is to have a braindead but reproducible backend that turns the sdist into a wheel
can you please describe how this source distribution should differ exactly?
it would be a dist info directory + some json to map the files, full backend being opt-in but low level backend being usable
(the build process beign reduced to makign a zip fil and then adding the files an the dist info)
im goign to bring back my gumby elf package as the meta build backend
i think i'll add a hatch plugin to provide the required metadata - the goal being that the wheel build from the meta backend being reproducible just like the ones from hatch, but the meta backend only composing the wheel
I'm trying to understand but I can't quite grok the requirement here, I'm willing to make it so Hatchling supports your use case just I don't get what you want exactly
@umbral bridge i want to create a meta backend for bootstrapping that wont have any additional dependencies for building from sdist - the plan is to have a plugin for the real backend set up the metadata so this build bakcend can be a really dumb thing thats just illing in a wheel
and it shal have jokes about a gumby brain surgery elf packaging things up
Hi, is this the correct syntax to pull a module from github and specify the branch ?
dependencies = [
"web3-ethereum-defi @ git+https://github.com/Aviksaikat/web3-ethereum-defi@feat/gmx"
]
the branch is feat/gmx
yes that syntax is correct
hatch shell is stuck for some reason same thing for rye as well
might be an uv issue
I would need more info to diagnose
update: might be my system issue after the reboot the issue is fixed
guess we can fix linux PCs by rebooting lol
Time to start adding 3.14 classifiers! And then there's this: https://github.com/scikit-build/scikit-build-core/pull/1074#issuecomment-2861777708
Shouldn't hatchling ignore all future versions of versioned classifiers when validating them? (And, is there a way to turn off validation, it's not helpful for anyone except the developer (me)). 🙂
Thanks!
Can I make 3.14 conditional in the matrix so I can exclude it on Windows? Hatch doesn't support 3.14.0b1 on Windows (on GitHub Actions, anyway)
do you mean the default test matrix?
Yes. I just need to skip 3.14 on Windows in CI, so I could override it on the CLI if I can't do it there.
can you show the CI config?
I tricked it into working by using the free-threaded build. It's here: https://github.com/scientific-python/repo-review/pull/271/files
It's just the non-free-threading build that is broken
I've got a package, plumbum, and I'd like to pull out two packages as namespace packages (plumbum.colorlib and plumbum.cli), with the original package remaining a normal package that depends on those two namespace packages. Does someone need to talk me out of it? 🙂
what would be the purpose of each?
Ability to use color/cli without depenencies (pywin32, not available for 3.14 yet, as it's binary only) (and plumbum installs a background thread atexit function that isn't needed for color/cli)
if you want to do separate packages then do that but without namespacing, I personally dislike the increased import time
I don't use that package though so I'm not sure if it's a factor for you
