hatch icon indicating copy to clipboard operation
hatch copied to clipboard

How to specify that a package is pure?

Open sanmai-NL opened this issue 9 months ago • 10 comments

An analogue of this option with PDM: https://backend.pdm-project.org/build_config/#is-purelib

sanmai-NL avatar Mar 11 '25 15:03 sanmai-NL

As a user this should happen automatically. Can you please explain what the issue is exactly?

ofek avatar Mar 11 '25 15:03 ofek

I run CI pipelines that are conditional on this property.

sanmai-NL avatar Mar 11 '25 16:03 sanmai-NL

How are you reading the property/what property?

ofek avatar Mar 11 '25 16:03 ofek

The PDM property, by reading the pyproject.toml through PDM. Will share example code soon.

sanmai-NL avatar Mar 11 '25 21:03 sanmai-NL

@ofek https://gitlab.com/han-aim/template/main/-/blob/721bb61461de3ade02453eb8dc3347b5f3704835/python/.gitlab-ci/releasepythonpackage-bootstrapped-production_script.sh#L28-31

The CI job then exits with a status conditional on the property.

sanmai-NL avatar Mar 12 '25 09:03 sanmai-NL

@ofek What are your current thoughts?

sanmai-NL avatar Mar 24 '25 15:03 sanmai-NL

Thanks for the reminder, I forgot!

The field you're checking for doesn't actually provide a guarantee as anything could happen at build time that includes non-Python files. The only way to check is to look at the resulting wheel metadata.

In the case of Hatchling, by default packages may only contain what is not ignored by the VCS which means probably no extension modules. If there are build hooks then you can't be sure without more information.

ofek avatar Mar 24 '25 15:03 ofek

@ofek My use case is not to be sure, and it is to avoid having to build the wheel a priori. I only want an indication whether it's a purelib. PDM seems to provide this parameter. What's different with hatchling here?

sanmai-NL avatar Mar 27 '25 14:03 sanmai-NL

Oh, then what you're asking is impossible because Hatchling allows for build hooks which can do anything.

ofek avatar Mar 27 '25 15:03 ofek

PDM does too. I think there's a misunderstanding. I want informative metadata in the pyproject.toml that indicates when it's a purelib. That's certainly not impossible. But you seem to want some absolute truth in the pyproject.toml that then controls all aspects of hatchlings operation. That's not what I'm asking.

sanmai-NL avatar Apr 09 '25 09:04 sanmai-NL