Hatchling install and GitHub actions
Adds a pyproject.toml based build using a pyproject based build
To install
python -m venv .venv
source ./.venv/bin/activate
python -m pip install --upgrade pip
pip install '.[test,build]'
pytest tests
This PR also adds Github Actions to automatically build and test the library, and to push tags to pypi.org. For this to work, the repository owner of https://pypi.org/project/fortranformat/ will need to add Github Actions as a trusted publisher. This basically means
- Go to https://pypi.org/manage/project/fortranformat/settings/publishing/
- On the Github tab, add owner:
brendanarnold, repository:py-fortranformat, workflow name:workflow_actions.yml, environment name:pypi-publishand click Add. See docs - Go to https://github.com/brendanarnold/py-fortranformat/settings/environments. Click
new environmentand add an environment calledpypi-publishand add maintainers as required reviewers. See docs - Make a new tag. This will automatically run the Github Action and then ask if you want to push to pypi
Thanks so much @tbody-cfs it’s really appreciated. I’m on leave right now without a computer until next week. When I get back and caught up I’ll take a look
i see from this that we should definitely have a toml file, although poetry is definitely a design choice so would like to investigate a bit first…
thanks again!
Thanks for making a very useful project!
That's true. I like poetry for neatly tracking the exact versions of the installed dependencies, and for automatically making isolated environments. However, if you'd prefer to use setuptools, I can adjust the pyproject.toml for this instead.
Happy to discuss when you're back.
Hi @tbody-cfs - It looks like poetry is a very popular build tool however I'm always a bit wary of introducing dependencies, especially when it isn't immediately clear what should be installed with conda, in a virtualenv, pipx is a sub-dependency and that is installed by curling a script from the web... (I know there are other ways but still...)
Would a setuptools approach be onerous? I presume the big advantage here is that it would work out of the box ...
Hi @brendanarnold,
I've now updated the PR to use the hatchling backend which works out of the box (no extra installs, works out of the box). This PR essentially follow https://packaging.python.org/en/latest/guides/writing-pyproject-toml/ line by line.
To test the GithubActions workflow, I opened a local merge on my fork. You can check this at https://github.com/tbody-cfs/py-fortranformat/pull/1.
Hey, don't want to mess you around but surely hatchling isn't part of the base Python library and needs to be installed? Hatch needs installing according to https://hatch.pypa.io/latest/install/
According to this website poetry is by far the most popular build tool after setuptools and so if a third party build tool is needed I would prefer poetry.
Note that the site does recommend not using setuptools and so poetry looks like the best option - I just wanted to be sure that we weren't installing unnecessary dependencies.
Hi @brendanarnold, No worries — packaging is important to get right!
I've never manually installed hatchling myself — it builds out of the box for me, as well as on mybinder.org. I did need to manually install poetry. I'm assuming that hatchling comes bundled with python, but couldn't find a definitive answer online.
Happy to proceed as you prefer. I can use setuptools, poetry or hatchling — whichever you prefer.
Hi Tom,
So I've downloaded your commits, 'm leaning towards the poetry version since it is much more popular and seems to be fairly straightforward. If you OK with that lets push ahead.
Presumably we can remove the setup.py in favour of the pyproject.toml? We also don't need twine since we can use poetry to deploy. These new steps should be documented in README.md - happy to help out with these changes.
Hi Brendan,
I've switched back to using poetry and updated the README. Let me know what you think :)
Cheers,
Tom
P.S. I'd recommend squishing the commit history.
Thanks for the suggestions @brendanarnold. Should be good to go now :)
Thanks so much @tbody-cfs for your coperation - its merged