Skip to content

Workshops aimed for Bachelor's student showing how to fight against Dependency Hell effectively!

Notifications You must be signed in to change notification settings

KTFish/tud-dsc-dependency-hell

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🌊 Dependency Hell Workshops 🌊

Workshops aimed for Bachelor's student showing how to fight against Dependency Hell effectively!

Consider giving a ⭐ for this repository!

Agenda

  1. Learn what is Dependency Management and why do you need it!
  2. Theory: get the minimal amount of additional context to select your tools like a true craftsman.
  3. Practice: learn how to use a modern dependency manager.

Requirements to participate

  • Take your laptop with you.
  • Join our Discord server, it will be used during the workshops.
  • Installed PyCharm. The PyCharm Professional version 2024.03 is 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!

Practice

After finishing each step please react with the ✅ (check emoji) on our Discord server. This will help us adjust the right pace.

Next step: Clone/download the repository

Clone the repo.

Next step: Install uv

Install uv on your machine. Details can be found here.

Next step: Open repo in PyCharm. Setup Python interpreter and create a virtual envorinment.

  • For details see here.

Next step: Install your first package

  • 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 pandas

Now 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.0

The 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.0

Next step: Remove a package which we do not need anymore

uv remove pandas

Inspect pyproject.toml

  • 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.

Next step: Add some dev dependencies

uv add ruff --group dev
uv add pytest --group dev

To 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.

Next step: Bump project version

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 patch

Run the command and see what changed in pyproject.toml!

uv version --bump minor

Run the command and see what changed in pyproject.toml!

uv version --bump major

Next step: Run pytest with uv

uv run pytest

Next step: Run an streamlit app

uv run streamlit run main.py

There are plenty other things you can do! (Out of scope for today)

About

Workshops aimed for Bachelor's student showing how to fight against Dependency Hell effectively!

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages