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

feat: add a build:wheel task to Taskfile.yml #128

Merged
merged 1 commit into from
Jan 25, 2024
Merged

Conversation

0xDEC0DE
Copy link
Contributor

@0xDEC0DE 0xDEC0DE commented Jan 23, 2024

Adds a build sub-target called build:wheel, that will assemble Python wheels for all artifacts built under dist/, according to the PEP 491 specification.

The script does the absolute bare minimum to generate a package that will allow pip install and pip uninstall to place the gilt binary under bin/, using packages that should be entirely available via the Python stdlib. i.e., a minimalist Python runtime should be able to do the work, with no venv or anything required.

It does not make sdists.

It does not upload to PyPI.

Tested on Debian 12, Alpine 3.16, Mac OS X 10.15, and macOS 14.2, all x86_64. ARM builds were not tested for lack of hardware.

Drive-by: change the name of the Goreleaser name_template so that snapshot builds will make/use version numbers that are compatible with PEP 440.

Fixes: Issue #127

@0xDEC0DE 0xDEC0DE changed the title Add a build:wheel task to Taskfile.yml feat: add a build:wheel task to Taskfile.yml Jan 23, 2024
@0xDEC0DE
Copy link
Contributor Author

Please view this entire endeavor with as skeptical of an eye as you can manage.

It's rather icky. It's immediate technical debt. But all of the other solutions I came across involved maintaining yet another set of identical project metadata; this one has the (small) benefit of letting you continue to only fight with the tooling you're already fighting with.

And it's nominally standards-compliant, and only uses the stdlib, so as long as it works well enough now, it should keep doing the trick into perpetuity. Maybe.

@retr0h
Copy link
Owner

retr0h commented Jan 23, 2024

It does not upload to PyPI.

Would we be able to upload the wheel to pypi tho right? I just need to build the actions to do so, yeah?

@0xDEC0DE
Copy link
Contributor Author

Would we be able to upload the wheel to pypi tho right? I just need to build the actions to do so, yeah?

That's supposed to be the idea. But I don't have any projects on PyPI, so I couldn't tell you for sure if they'll behave.

scripts/dist2wheel.py Outdated Show resolved Hide resolved
python/dist2wheel.py Outdated Show resolved Hide resolved
@0xDEC0DE 0xDEC0DE force-pushed the issue/127 branch 2 times, most recently from 56dacb0 to 16aa470 Compare January 24, 2024 00:39
@retr0h
Copy link
Owner

retr0h commented Jan 24, 2024

Am I doing something wrong?

❯ pip install dist/go-gilt-2.0.4-0next-py3-none-macosx_10_15_x86_64.whl
ERROR: go-gilt-2.0.4-0next-py3-none-macosx_10_15_x86_64.whl is not a supported wheel on this platform.

[notice] A new release of pip available: 22.2.2 -> 23.3.2
[notice] To update, run: pip3 install --upgrade pip

❯ uname -a
Darwin Johns-MacBook-Pro-2.local 23.1.0 Darwin Kernel Version 23.1.0: Mon Oct  9 21:27:27 PDT 2023; root:xnu-10002.41.9~6/RELEASE_X86_64 x86_64

.goreleaser.yaml Outdated Show resolved Hide resolved
@0xDEC0DE
Copy link
Contributor Author

0xDEC0DE commented Jan 24, 2024

Am I doing something wrong?

❯ pip install dist/go-gilt-2.0.4-0next-py3-none-macosx_10_15_x86_64.whl
ERROR: go-gilt-2.0.4-0next-py3-none-macosx_10_15_x86_64.whl is not a supported wheel on this platform.

[notice] A new release of pip available: 22.2.2 -> 23.3.2
[notice] To update, run: pip3 install --upgrade pip

❯ uname -a
Darwin Johns-MacBook-Pro-2.local 23.1.0 Darwin Kernel Version 23.1.0: Mon Oct  9 21:27:27 PDT 2023; root:xnu-10002.41.9~6/RELEASE_X86_64 x86_64

Oh, here we go. It installs for me on my local machine (and the Linux wheel installed in an Ubuntu container) but I was absolutely winging it wrt. compatibility.

Can I see what you get when you run these commands?

uname -a
sw_vers
pip3 debug --verbose | grep -E 'py3-none-macosx_\d+_\d+.*x86_64' | sort -V | uniq

@0xDEC0DE 0xDEC0DE marked this pull request as draft January 24, 2024 05:43
@0xDEC0DE
Copy link
Contributor Author

0xDEC0DE commented Jan 24, 2024

Stupid question: you're not running pip with a Python 2 runtime, are you?

I suppose there's no reason NOT to allow it to install on Python 2, but I did draw the line at Python 3, because it's all I have to test with. (and honestly, Python 2.x shouldn't be allowed within 500m of a production environment)

@0xDEC0DE
Copy link
Contributor Author

I also just installed it on a 2012 MacBook Pro running Catalina; no issues spotted.

Something funny is definitely going on. That your task build step is still naming it go-gilt may be causing trouble; do you need to rename your remote?

@retr0h
Copy link
Owner

retr0h commented Jan 25, 2024

I also just installed it on a 2012 MacBook Pro running Catalina; no issues spotted.

Something funny is definitely going on. That your task build step is still naming it go-gilt may be causing trouble; do you need to rename your remote?

Yeah, was a remote issue.

@retr0h
Copy link
Owner

retr0h commented Jan 25, 2024

Stupid question: you're not running pip with a Python 2 runtime, are you?

❯ python --version
Python 3.10.8

I'll retry again, I must be doing something dumb.

update

Looks to have been an issue on my end:

❯ /Users/retr0h/.asdf/installs/python/3.10.8/bin/gilt version
{"version":"2.0.11.dev","commit":"12a86657e489328bdff2c20c31679bfee8fc84da","date":"2024-01-25T00:36:09Z"}

@0xDEC0DE 0xDEC0DE marked this pull request as ready for review January 25, 2024 04:32
@0xDEC0DE
Copy link
Contributor Author

BRB, rewriting history on this PR...

@0xDEC0DE
Copy link
Contributor Author

At this point, I think it's in suitable shape to throw over the wall to you, @retr0h .

With this script, the proposed (manual) Python release process is:

git checkout $TAG
goreleaser release --clean --skip=announce,publish,validate
python/dist2wheel.py
$PYPI_UPLOAD_SCRIPT

...since the dist2wheel.py script uses the existing dist/ directory contents, you could lightly adjust the above to back-fill prior releases, if that was your thing.

It should be a fairly simple matter to adjust your Github actions to handle whatever parts you don't want to run by hand.

Adds a `build` sub-target called `build:wheel`, that will assemble
Python wheels for all artifacts built under dist/, according to the
PEP 491 specification.

The script does the absolute bare minimum to generate a package
that will allow `pip install` and `pip uninstall` to place the gilt
binary under bin/, using packages that should be entirely available
via the Python stdlib.  i.e., a minimalist Python runtime should
be able to do the work, with no venv or anything required.

It does not make sdists.

It does not upload to PyPI.

Tested on Debian 12, Alpine 3.16.2, Mac OS X 10.15, and macOS 14.2.1,
all x86_64.  ARM builds were not tested for lack of hardware.

Drive-by: change the name of the Goreleaser `name_template` so that
snapshot builds will make/use version numbers that are compatible
with PEP 440.

Fixes: Issue retr0h#127
@retr0h
Copy link
Owner

retr0h commented Jan 25, 2024

Thanks for busting this out @0xDEC0DE I had avoided implementing, b/c I figured you would introduce a nice solution 🥇

@retr0h retr0h merged commit d7d1cf6 into retr0h:main Jan 25, 2024
6 checks passed
@0xDEC0DE 0xDEC0DE deleted the issue/127 branch January 25, 2024 18:54
@retr0h retr0h added the v2.1 label Jan 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants