-
Notifications
You must be signed in to change notification settings - Fork 292
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
MNT: Switch to hatch build backend and update package metadata #2914
Conversation
Version scheme working, but dirty builds again:
|
Ah, need to merge |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, I'm going to follow suit in nibabies.
A few things I can't easily leave suggestions on:
- NOTICE/LICENSE copyright year bump
pyproject.toml
's[tool.black]
/[tool.isort]
skips can be removed
@mgxd One thing I'll note is that flit-scm installs the entire We might want to consider going to setuptools or trying out hatch as the build backend. We can still use |
cc5638d
to
2ab3ebf
Compare
8ff6f99
to
f6d268c
Compare
Changed quite a lot since last you reviewed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minor comments, but fine with it as is
Makefile
Outdated
@@ -14,4 +14,4 @@ docker-build: | |||
docker build --rm -t $(tag) \ | |||
--build-arg BUILD_DATE=`date -u +"%Y-%m-%dT%H:%M:%SZ"` \ | |||
--build-arg VCS_REF=`git rev-parse --short HEAD` \ | |||
--build-arg VERSION=`python get_version.py` . | |||
--build-arg VERSION=`python -m setuptools_scm` . |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should this be
--build-arg VERSION=`python -m setuptools_scm` . | |
--build-arg VERSION=`hatch version` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch. Thanks.
# | ||
|
||
[tool.hatch.build.targets.wheel] | ||
packages = ["src/fmriprep_docker"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just curious - why move to src/
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
src/
layouts are increasingly the recommended thing, so I wanted to make sure I knew how to do it. Figured since I was moving the file anyway, I might as well get the experience here.
wrapper/setup.cfg
Outdated
[options.entry_points] | ||
console_scripts = | ||
fmriprep-docker=fmriprep_docker:main | ||
|
||
[bdist_wheel] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
any pyproject.toml equivalent? [tools.setuptools.bdist_wheel]
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
wheel
is its own tool. Its docs don't advertise pyproject.toml support, so I didn't try it.
We can drop MANIFEST.in and custom package data declarations by letting setuptools_scm package everything version-controlled in the sdist.
Hatch has a hatch-vcs plugin that wraps around setuptools_scm while remaining flexible. In contrast, setuptools_scm hijacks setuptools' file finding, making package data management cumbersome. And flit handles dynamic version metadata by importing, turning install-time dependencies into build-time dependencies.
Errors introduced in #2914, caught by @mgxd doing the same over in nipreps/nibabies#265.
Changes proposed in this pull request
This PR aims to move away from setuptools+versioneer, which we've been using for a while.
Our packaging needs are actually quite simple so theflit_scm
wrapper aroundflit
andsetuptools_scm
works with only a little tweaking.One advantage to this approach is that
_version.py
can be updated by runningpython -m setuptools_scm
, which will ensure that patching withfmriprep-docker --patch fmriprep=...
will get a sensible version instead of the useless0+unknown
which breaks the reuse of workflow directories.One slight complication is that flit does not resolve symlinks when building sdists. I have added theNOTICE
file to the sdist inclusion list, but I also switched the direction of the symlink so that the authoritative copy is always inside the package and does not depend onwheel
resolving symlinks when building.I have moved to the hatch build system, which has some advantages. This is a plugin-oriented build-system, which means it should be fairly easy for us to find or write additional tools if our needs change. The hatch-vcs plugin wraps
setuptools_scm
with only minor changes to the configuration needed.One additional nice feature of hatch is that you can set different file include/exclude rules for sdists and wheels. In principle, an sdist should be testable without resorting to the original repository, so I have never much liked that we remove a large chunk of data. This allows us to exclude the
fmriprep/data/tests
directory only in the wheel. This preserves our 5.5MB wheel while allowing the sdist to grow to the 30MB monstrosity that it ought to be.