lark-parser / lark_cython

Cython plugin for Lark, reimplementing the LALR parser & lexer for better performance
MIT License
45 stars 5 forks source link

Actions for sdist and pypi deployment #4

Closed Erotemic closed 2 years ago

Erotemic commented 2 years ago

Next step to hopefully get this on pypi (and letting me declare it as a dependency in my projects).

This adds two new actions to deploy to the test pypi server and to deploy to the live pypi server. There is a third new step that also builds source distributions, so any platform with a compiler can pip install this even if the wheels don't directly support it (which probably isn't too many people).

I haven't used the gh-action-pypi-publish action yet, so this may not work (I have custom publishing logic that also signs my wheels with a CI gpg key), but it should be too hard to debug.

@erezsh To support this it would be helpful if you could generate a token for test.pypi.org (you may need to create an account if you don't have one, it's distinct from pypi.org) and then populate the TEST_PYPI_API_TOKEN secret with that token. When that works, you can do the same for regular pypi.

The logic is setup such authorized PRs will try to publish to test.pypi. When you want to make a release, you would generate a new git tag (which can be done via the github release process), and the live pypi action will run when it sees a new tag.

Erotemic commented 2 years ago

Hmm, I would have thought if: github.event_name == 'push' && ! startsWith(github.event.ref, 'refs/tags') would execute on this PR, but apparently not. Maybe without github.event_name will execute? (It did correctly fail on my fork though: https://github.com/Erotemic/lark_cython/runs/7553191016?check_suite_focus=true )

The sdist is correctly included in the artifacts though.

EDIT: Looking into it is is because this doesn't correspond to a branch on this remote yet. If you merged this into master it would run the test pypi upload. That might be the best way forward: Add the TEST_PYPI_API_TOKEN secret, merge into master, verify that it uploads to test pypi, then add PYPI_API_TOKEN and publish a new release which should now deploy to live pypi.

erezsh commented 2 years ago

@Erotemic What if I put it on a branch, like test_pypi ?

Erotemic commented 2 years ago

@Erotemic What if I put it on a branch, like test_pypi ?

Yes, I think as long as it merges into this repo it will run.

Erotemic commented 2 years ago

Looks like setup.py is missing some information. It also probably isn't advisable to use distutils. Just use the setuptools.setup. I pushed up a commit that should add the missing info (and a bit more) to make twine happy.

erezsh commented 2 years ago

It also probably isn't advisable to use distutils. Just use the setuptools.setup

Not sure what you mean. Just change whatever you think is necessary.

Erotemic commented 2 years ago

distutils is deprecated: https://peps.python.org/pep-0632/#:~:text=In%20Python%203.10%20and%203.11,platforms%20will%20not%20be%20added. and will be removed in the future. Using setuptools.setup should work fine. I pushed up the change.

erezsh commented 2 years ago

Latest error:

The workflow is not valid. .github/workflows/tests.yml: (Line: 186, Col: 11, Idx: 5459) - (Line: 186, Col: 12, Idx: 5460): While parsing a tag, did not find expected tag URI.
Erotemic commented 2 years ago

whoops, had that line staged and didn't mean to commit it.

erezsh commented 2 years ago

Seems to have worked!

image

Erotemic commented 2 years ago

@erezsh I'd like to add this to my project requirements, but I can't compile from source in some instances. Any chance of getting this merged + either an updated release of 0.0.11 or a bump to 0.0.12 with wheels?

erezsh commented 2 years ago

@Erotemic Now that it's merged, what the right way to trigger it?

Usually I just update the version, push it, and then create a new release via github, which also creates a git tag. Would that work?

Erotemic commented 2 years ago

Yup. Any action that creates the tag will work.

erezsh commented 2 years ago

Looks like it worked!

Erotemic commented 2 years ago

Thank you! That really helps me out!

erezsh commented 2 years ago

Thank you for a great contribution!