Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remove hard dependency on editables #1255

Merged
merged 9 commits into from
Feb 19, 2024
Merged

Conversation

gotmax23
Copy link
Contributor

Instead of a hard dependency on editables, include it in get_requires_for_build_editable. This makes it easier to bootstrap Python and makes installation slightly faster for the typical case.

Copy link
Sponsor Collaborator

@ofek ofek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is an interesting idea! The current change will break the hatch build command because when Hatch builds projects that use Hatchling the usual mechanisms are elided for simplicity. Specifically, you would have to manually add editables to this line.

Can you please explain precisely how this would help with bootstrapping?

backend/src/hatchling/constants.py Outdated Show resolved Hide resolved
@gotmax23
Copy link
Contributor Author

Thanks for the feedback!

The current change will break the hatch build command because when Hatch builds projects that use Hatchling the usual mechanisms are elided for simplicity. Specifically, you would have to manually add editables to this line.

I was under the impression that hatch build only builds standard wheels. Does it also have an option to build editables?

Can you please explain precisely how this would help with bootstrapping?

There's no loop it breaks or anything (editables just needs flit_core to build), but it's nice having one less package in the initial dependency tree.

Instead of a hard dependency on editables, include it in
get_requires_for_build_editable. This makes it easier to bootstrap
Python and makes installation slightly faster for the typical
case.
@ofek
Copy link
Sponsor Collaborator

ofek commented Feb 12, 2024

You can by doing hatch build -t wheel:editable but you're absolutely right no one would do that in practice. Hmm, I guess I'm inclined to accept this but please understand that I'm also fearful because this is used by so many projects under so many conditions.

@gotmax23
Copy link
Contributor Author

Ah, I see. I don't think that's documented anywhere (or at least I couldn't find it), but I wouldn't want to introduce a change that completely breaks it. I'll push a follow up to add to https://github.com/pypa/hatch/blob/hatch-v1.9.3/src/hatch/cli/build/__init__.py#L112.

backend/src/hatchling/builders/constants.py Outdated Show resolved Hide resolved
@ofek
Copy link
Sponsor Collaborator

ofek commented Feb 12, 2024

To fix the error in CI you will have to add another line to this step and install the backend in editable mode similar to what we do for tests:

run: pip install -e .

@ofek
Copy link
Sponsor Collaborator

ofek commented Feb 12, 2024

Also, cool blog! I was reading this: https://gtmx.me/blog/week-of-2023-12-10/

Am I understanding correctly that after this is merged Fedora packagers would have an easier time? Specifically, I noticed that you decided to switch a package away from Hatchling.

I reduced the dependencies by switching from [...] hatchling to flit_core for the Python build backend. The goal is to make tomcli easier to bootstrap so it can be adopted more easily by baseline Python packages in Fedora.

@ofek
Copy link
Sponsor Collaborator

ofek commented Feb 12, 2024

cc @musicinmybrain @hroncok also for Fedora

@hroncok
Copy link

hroncok commented Feb 12, 2024

Thanks for this!

@gotmax23
Copy link
Contributor Author

Also, cool blog! I was reading this: https://gtmx.me/blog/week-of-2023-12-10/

Thanks! I really need to get back to my weekly reports...

Am I understanding correctly that after this is merged Fedora packagers would have an easier time?

Yes, this should make bootstrapping slightly easier, and I assume it'll help Fedora's downstreams (Red Hat Enterprise Linux et al.) to reduce the amount of packages it has to support. If the patch a huge burden to maintain, it's probably not worth merging, but I don't believe that's the case.

Specifically, I noticed that you decided to switch a package away from Hatchling.

I reduced the dependencies by switching from [...] hatchling to flit_core for the Python build backend. The goal is to make tomcli easier to bootstrap so it can be adopted more easily by baseline Python packages in Fedora.

Ah, that decision was unrelated to this. My goal is for tomcli to eventually become the "blessed" way for Fedora packagers to read from and patch pyproject.toml, so I'd like it to have a very small dependency footprint so we can use it early in the overall Python dependency tree. tomcli is currently used in the hatch package to print a list of test dependencies from hatch.toml to feed to our Python dependency generator.

I do prefer hatch for my other personal projects. Last year, we also switched all the antsibull* projects (Ansible build tools) from poetry to hatch, and we have been much happier with it.

.github/workflows/test.yml Outdated Show resolved Hide resolved
.github/workflows/build-hatch.yml Outdated Show resolved Hide resolved
src/hatch/cli/build/__init__.py Outdated Show resolved Hide resolved
Copy link
Sponsor Collaborator

@ofek ofek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

@ofek ofek merged commit a5f62c2 into pypa:master Feb 19, 2024
38 checks passed
github-actions bot pushed a commit that referenced this pull request Feb 19, 2024
Co-authored-by: Ofek Lev <ofekmeister@gmail.com> a5f62c2
@gl-yziquel
Copy link

You can by doing hatch build -t wheel:editable but you're absolutely right no one would do that in practice. Hmm, I guess I'm inclined to accept this but please understand that I'm also fearful because this is used by so many projects under so many conditions.

I guess I just ran into that.

ImportError: cannot import name 'EDITABLES_REQUIREMENT' from 'hatchling.builders.constants'

I just upgraded to python 3.12.2 because of an OSTYPE issue, and rebuilt some packages, including hatch, just now. And I hit that.

Instructions for a quick fix would be more than welcome.

@ofek
Copy link
Sponsor Collaborator

ofek commented Feb 19, 2024

Can you please explain exactly how to reproduce the error? I haven't even released.

@gl-yziquel
Copy link

Can you please explain exactly how to reproduce the error? I haven't even released.

I built from source. Latest. I tend to do that. Here's how to, perhaps, reproduce:

pyenv install 3.12.2
pyenv shell 3.12.2
pip install build
pushd hatch.git
git checkout a5f62c2f298e7da39f1ca19877a362e8e97c2c24
python -m build --wheel
pip install dist/*.whl
popd
hatch new bugproject

This last command yields the ImportError about EDITABLES_REQUIREMENT from hatchling.builders.constants.

@hroncok
Copy link

hroncok commented Feb 19, 2024

Perhaps hatchling also needs to be installed from git?

@ofek
Copy link
Sponsor Collaborator

ofek commented Feb 19, 2024

Yes that's it exactly, the actual release will make sure the versions are compatible.

@gl-yziquel
Copy link

Perhaps hatchling also needs to be installed from git?

Perhaps.

But with version 1.9.3, on tag hatch-v1.9.3, it works fine.

@hroncok
Copy link

hroncok commented Feb 19, 2024

Yes, because it predates this change which has been done in both hatch and hatchling.

18alantom added a commit to frappe/bench that referenced this pull request Feb 21, 2024
18alantom added a commit to frappe/bench that referenced this pull request Feb 21, 2024
jwodder added a commit to jwodder/versioningit that referenced this pull request Mar 16, 2024
So that `test_editable_mode_hatch` won't fail due to
pypa/hatch#1255
arnout pushed a commit to buildroot/buildroot that referenced this pull request May 10, 2024
Changelog:
https://hatch.pypa.io/dev/history/hatchling/#hatchling-v1.22.4

Remove now optional editables dependency [1].

[1] pypa/hatch#1255

Signed-off-by: Marcus Hoffmann <buildroot@bubu1.eu>
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
ThomasBinsfeld added a commit to acsone/acsone-odoo-project-template that referenced this pull request May 15, 2024
Since hatchling 1.22.4, editables is not a hard dependency, (it is provided by the get_requires_for_build_editable hook (pypa/hatch#1255).
We need to add it as a build dependency.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants