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

Switch to poetry #314

Open
reckart opened this issue May 4, 2024 · 7 comments
Open

Switch to poetry #314

reckart opened this issue May 4, 2024 · 7 comments
Assignees
Milestone

Comments

@reckart
Copy link
Member

reckart commented May 4, 2024

Describe the refactoring action
Switch to poetry and pyproject.toml.

Expected benefit
Align with pycaprio and I kind of like the declarative nature of pyproject.toml vs the setup.py.

@reckart reckart added this to the 0.10.0 milestone May 4, 2024
@reckart reckart self-assigned this May 4, 2024
reckart added a commit that referenced this issue May 4, 2024
- Remove setup.py
- Switch to pyproject.toml
- Update GitHub actions to use poetry
- Clean up code a bit according to feedback from flake8
- Update release guide
reckart added a commit that referenced this issue May 4, 2024
- Use ruff
- Address linter issues in json.py
@DavidHuebner
Copy link
Collaborator

DavidHuebner commented May 6, 2024

Aside from personal preference, do you see any advantages of using poetry over plain pip? Why not align pycaprio with dkpro-cassis by using a pip-variant everywhere?

In my experience, poetry is useful for larger projects, but has a little more overhead whereas pip is faster to set up and more suited for small projects like this one.

@reckart
Copy link
Member Author

reckart commented May 6, 2024

I prefer a declarative approach to the build like it is provided by pyproject.toml versus the programmatic approach adopted by setup.py.

I have briefly tried using pyproject.toml with setuptools as the build system, but it does not automatically pin down the versions (i.e. it does not create a requirements.txt or similar file like a poetry.lock that would ensure that builds always use the same dependency graph).

@DavidHuebner
Copy link
Collaborator

Yes, locking down the dependency graph is probably the biggest advantage of poetry.

Personally, I think that the installation of poetry itself (see https://python-poetry.org/docs/#installation) is a little more complicated and poetry itself is a bit more unfamiliar to some Python developers compared to plain pip / venv.

However, this shouldn't block you if you think it is a good decision to switch to poetry.

We will need to pay special attention to adjusting the Github actions to Poetry as they are not tested automatically (especially the release build).

@reckart
Copy link
Member Author

reckart commented May 6, 2024

So far, all I had to do was pip install poetry. At least locally, I never work without venvs. With the GH actions, I didn't have trouble with PyCaprio either.

@DavidHuebner
Copy link
Collaborator

On the link that I posted above, it says:

Poetry should always be installed in a dedicated virtual environment to isolate it from the rest of your system. It should in no case be installed in the environment of the project that is to be managed by Poetry. This ensures that Poetry’s own dependencies will not be accidentally upgraded or uninstalled. (Each of the following installation methods ensures that Poetry is installed into an isolated environment.) In addition, the isolated virtual environment in which poetry is installed should not be activated for running poetry commands.

So you will need to use a second virtual environment to manage poetry itself.

@reckart
Copy link
Member Author

reckart commented May 6, 2024

So you will need to use a second virtual environment to manage poetry itself.

Meh... 👎 😐

Are there sensible alternatives to setuptools and poetry that could be considered? Or is there a way to have setuptools lock down the dependency graph?

@DavidHuebner
Copy link
Collaborator

There is a library called pip-tools which brings pip-compile that creates a requirements.txt from requirements.in, pyproject.toml or setup.cfg or setup.py. This requirements.txt then contains the locked down versions and is used by the installers.
See: https://pip-tools.readthedocs.io/en/latest/cli/pip-compile/

Again, I am not sure if this is actually required for a small project with rather limited dependencies.

reckart added a commit that referenced this issue May 6, 2024
- Use ruff
- Address linter issues in json.py
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants