Workshops aimed for Bachelor's student showing how to fight against Dependency Hell effectively!
Consider giving a ⭐ for this repository!
- Learn what is Dependency Management and why do you need it!
- Theory: get the minimal amount of additional context to select your tools like a true craftsman.
- Practice: learn how to use a modern dependency manager.
- Take your laptop with you.
- Join our Discord server, it will be used during the workshops.
- Installed PyCharm. The PyCharm Professional version
2024.03is recommended. Older PyCharm version do not support the tools we will be using during the workshop. You may use any other IDE of course if you prefer and feel more convenient with it!
After finishing each step please react with the ✅ (check emoji) on our Discord server. This will help us adjust the right pace.
Clone the repo.
Install uv on your machine. Details can be found here.
- For details see here.
- Install first package!
- We expect to run into some errors!
First install pandas, this command will just pick a fitting pandas version and install it:
uv add pandasNow let's try to install an old version of numpy in order to get a conflict. Such situation occurs often in real-life
projects. The tool we use shoul somehow help us in such situations:
uv add numpy==1.24.0The error should look something like this:
uv add numpy==1.24
× No solution found when resolving dependencies:
╰─▶ Because only the following versions of numpy are available:
numpy<=1.26.0
numpy==1.26.1
numpy==1.26.2
... (skipped some numpy versions for berivety) ...
numpy==2.3.4
numpy==2.3.5
and pandas==2.3.3 depends on numpy>=1.26.0, we can conclude that pandas==2.3.3 depends on numpy>=1.26.0.
And because only pandas<=2.3.3 is available, we can conclude that pandas>=2.3.3 depends on numpy>=1.26.0.
And because your project depends on numpy==1.24 and pandas>=2.3.3, we can conclude that your project's requirements are unsatisfiable.
help: If you want to add the package regardless of the failed resolution, provide the `--frozen` flag to skip locking and syncing.To resolve it we just pick one of the suggested numpy versions:
uv add numpy==1.26.0uv remove pandas- Let's discuss what we have right now!
- What is each part meaning?
[project]
name = "tud-dsc-dependency-hell"
version = "0.1.0"
description = "Add your description here"
requires-python = ">=3.12"
dependencies = [
"pytest>=9.0.1",
]
authors = [
{ name = "Jan Karas" }
]Now let's take a look into the uv.lock file.
uv add ruff --group dev
uv add pytest --group devTo install dependencies from all groups (including dev) you can use uv sync --all-extras in the future. Using groups
is helpful when you want:
- Separate production and dev environments.
- Make your CI/CD pipeline lighter (and thus faster).
- Install only necessary packages for what you are currently doing.
Now when we did some work we want to tag our project state with a version. For more details about semantic versioning check this.
- Semantic versioning makes it easier to publish your project as a package.
- Great when cooperating in a team.
- uv's commands help you avoid manual mistakes.
Run the command and see what changed in pyproject.toml!
uv version --bump patchRun the command and see what changed in pyproject.toml!
uv version --bump minorRun the command and see what changed in pyproject.toml!
uv version --bump majoruv run pytestuv run streamlit run main.py- Install different Python version
- Build and Publish your own Python package.
- Migrate from pip in a hassle-free way.