Package: hatch-zipped-directory
hatch-zipped-directoryThis is aHatchplugin that provides
a custom builder to support building zip archives for quasi-manual
installation into various foreign package installation systems.
(Specifically, I use this for packagingInkscapeextensions and symbols libraries,
but it may be useful in other contexts, such as deploying to cloud
compute platforms.)The builder creates a zip archive.  All the contents of the zip
archive will be included under a single specific top-level directory.
The default name of the top-level directory is a file-name-safe
version of the project name, however the name of the directory may be
configured by setting theinstall-namekey in the target-specific
configuration section.
This behavior may be disabled by settinginstall-name = ''.In addition to whatever files are selected for inclusion in the
archive via Hatch’s regularbuild configuration
settings, any configured
project README and license files will be included in the top level of
the install directory within the zip archive.As well, aMETADATA.jsonfile containing the project metadata in
JSON format (as described inPEP 566)
will be included in the top level of the install directory within the
zip archive.ExampleAssume a project source directory looking something like:.
├── pyproject.toml
├── LICENSE.txt
├── README.md
├── src
│   ├── subdir
│   │   ├── data.txt
│   │   └── more-code.py
│   └── my-code.py
└── tests
    └── test_foo.pyWherepyproject.tomllooks like:[build-system]requires=["hatchling","hatch-zipped-directory",]build-backend="hatchling.build"[project]name="test-project"version="0.42"[tool.hatch.build.targets.zipped-directory]install-name="org.example.test"sources=["/src",]Then, runninghatchbuild--targetzipped-directorywill build a zip archive nameddist/test_project-0.42.zipwith the following
structure:.
└── org.example.test
    ├── LICENSE.txt
    ├── METADATA.json
    ├── README.md
    ├── my-code.py
    └── subdir
        ├── data.txt
        └── more-code.pyReproducible BuildsBy default, this plugin attempts to buildreproduciblearchives by setting the timestamps of the zip entries to a
fixed value. When building in reproducible mode, the UNIX file modes
of the archive entries is also normalized (to either 0644 or 0755
depending on whether the file is executable.)The timestamp used for reproducible builds may be configured by
setting theSOURCE_DATE_EPOCHenvironment variable.Reproducible builds may be disabled by settingreproducible = falsein an appropriate section ofpyproject.tomlorhatch.toml.  See
Hatch’s documentation onBuild Configurationfor details.AuthorJeff Dairikidairiki@dairiki.orgLicensehatch-zipped-directoryis distributed under the terms of theMITlicense.Changes0.1.0 (2023-12-12)BitrotFix for hatchling 1.19 (hatch 1.8).BuilderInterface.buildarguments are now all kw-only. ([hatch/6c252f8])[hatch/6c252f8]:https://github.com/pypa/hatch/commit/6c252f8b8a65711846a6060c3d54f02936da2aa0)0.1.0b4 (2023-09-10)FeaturesAdd support forreproducible buildswhich are now enabled by
default. When enabled, timestamps in the zip archive are set to a
fixed value (configurable via theSOURCE_DATE_EPOCHenvironment
variable) and the UNIX access modes of archive members arenormalized to either 0644 or 0755depending on
whether the file is executable or not.0.1.0b3 (2023-05-10)FeaturesRefactor JSON metadata code. Now we usehatchlingto generate
conventionall RFC 822-formatted distribution metadata, then convert
that to JSON, explicitly following the steps outline inPEP
566.
Among other things, this allows configuration of theMetadata-Versionby settingtool.hatch.build.targets.zipped-directory.core-metadata-version.TestsWe now have 100% test coverage.0.1.0b2 (2023-01-10)FeaturesThe prefixing of file names under a top-level directory in the zip
archive can now be disabled by settinginstall-name = "".
Thank you @gwerbin(#1)BugsUse explicit encoding in hatch metadata hook (for Windows).0.1.0b1 (2022-10-07)Initial release.