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

Refactor dependency management to pyproject.toml #313

Merged

Conversation

s-heppner
Copy link
Contributor

@s-heppner s-heppner commented Oct 11, 2024

Previously, our dependency management was a bit of a mess. We had both a requirements.txt and a pyproject.toml and some dependencies were only defined in one but not the other, leading to a lot of problems.

This aims to fix this mess and refactor towards only using pyproject.toml to define the dependencies.

At the same time, we also clean up the install process, which now works by simply calling pip install . or pip install -e .[dev] for the developer envrionment. This change is reflected in the .github/workflows.

Furthermore, we configure the already introduced setuptools_scm to automatically infer a version based on the most recent git tag.

Fixes #301
Fixes #303
Fixes #306

@s-heppner s-heppner marked this pull request as draft October 11, 2024 13:26
Previously, our dependency management was a bit of
a mess. We had both a `requirements.txt` and a
`pyproject.toml` and some dependencies were only
defined in one but not the other.

This aims to fix this mess and refactor towards
only using `pyproject.toml` to define the
dependencies.

At the same time, we also clean up the install
process, which now works by simply calling
`pip install .` or `pip install -e .[dev]` for the
developer envrionment. This change is reflected in
the `.github/workflows`.

Furthermore, we configure the already introduced
`setuptools_scm` to automatically infer a version
based on the most recent git tag.
@s-heppner s-heppner force-pushed the Refactor/DependencyManagement branch from 5087670 to 7a7635b Compare October 11, 2024 13:36
@s-heppner
Copy link
Contributor Author

After a lot of research regarding dependency management, I think I've come up with the proper way of using pyproject.toml and requirement.txt. Both seem to have their use cases and this stackoverflow discussion was especially useful to understanding the differences:

  • pyproject.toml is used to define everything needed in theory to build a package. This comes without strict pinning of versions so that the build system can choose the optimal versions if, for example different dependencies depend on different versions of the same package.
  • requirements.txt is used to create reproducible builds, especially for CI pipelines. It's a concrete set of instructions to pip which packages to install and usually contains pinned dependency versions.

Since we've not used pinned dependencies before (and to pin or not to pin is a whole other discussion that we shan't open right now), we do not have a need the requirements.txt anymore.

Instead, pip is smart enough to use the pyproject.toml to search for the dependencies. It now also became easier to install. As a user, wanting to use a local install of the SDK, we can now simply do:

pip install . 

and use the SDK (from basyx.aas import model).

If we are a developer on the SDK itself, we might want to install it dynamically (-e) and also install the additional developer requirements ([dev]:

pip install -e .[dev]

I've adapted the CI pipelines to do this as well. I've also changed the CONTRIBUTING.md instructions.

@s-heppner s-heppner marked this pull request as ready for review October 11, 2024 13:44
@Frosty2500
Copy link
Contributor

LGTM, I see no problems 👍
I dont have write access so someone else will have to merge this branch

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants