Vishal Pandey
10/11/2024, 10:52 AMdatajoely
10/11/2024, 10:52 AMuv
is the only tool you needdatajoely
10/11/2024, 10:52 AMVishal Pandey
10/11/2024, 10:52 AMVishal Pandey
10/11/2024, 10:53 AMdatajoely
10/11/2024, 10:53 AMdatajoely
10/11/2024, 10:53 AMVishal Pandey
10/11/2024, 10:54 AMVishal Pandey
10/11/2024, 11:00 AMuv pip compile <http://requirements.in|requirements.in> --universal --output-file requirements.txt
But this assumes that requirements.in is already present.
How do i create this ?datajoely
10/11/2024, 11:06 AMdatajoely
10/11/2024, 11:06 AMuv add
to add requirements in a way that compiles nicelydatajoely
10/11/2024, 11:07 AMrequirements.txt
into a <http://requiremements.in|requiremements.in>
and compile them that wayVishal Pandey
10/11/2024, 11:12 AMpip freeze
This simply dumps all the top level and sub packages in the requirements.txt file for some reason i did not found this very optimal.
Then I came across pipreqs for a minimal requirements. This created a requirements.in file which only dumps the packages which are directly imported in the project source code. Later when i used pip-tools to compile and generate a requirements.txt file I found many dependencies were missing like
kedro-datasets[pandas-csvdataset]
kedro-datasets[ibis]
kedro-kubeflow==0.8.0
ibis-framework==9.0.0
s3fs==2024.9.0
psycopg2-binary==2.9.9
Juan Luis
10/11/2024, 11:26 AM<http://requirements.in|requirements.in>
, or to the [project.dependencies]
table of pyproject.toml
(we in Kedro are moving towards the latter)Vishal Pandey
10/11/2024, 11:32 AM<http://requirements.in|requirements.in>
or pyproject.toml
.datajoely
10/11/2024, 11:34 AMuv add
it does the hard bit for youdatajoely
10/11/2024, 11:35 AMVishal Pandey
10/11/2024, 11:36 AMdatajoely
10/11/2024, 11:36 AMdatajoely
10/11/2024, 11:36 AMdatajoely
10/11/2024, 11:37 AMVishal Pandey
10/11/2024, 11:38 AMdatajoely
10/11/2024, 11:38 AMVishal Pandey
10/11/2024, 11:40 AMdatajoely
10/11/2024, 11:41 AMdatajoely
10/11/2024, 11:41 AMVishal Pandey
10/11/2024, 11:42 AMdatajoely
10/11/2024, 11:42 AMdatajoely
10/11/2024, 11:42 AMdatajoely
10/11/2024, 11:42 AMdatajoely
10/11/2024, 11:42 AMVishal Pandey
10/11/2024, 11:42 AMVishal Pandey
10/12/2024, 7:45 AMdatajoely
10/12/2024, 7:52 AMuv pip install -r requirements.txt
but the more modern way is to do uv add
as you go alongVishal Pandey
10/12/2024, 7:52 AMbuild_wheel()
(exit status: 1)Vishal Pandey
10/12/2024, 7:53 AMdatajoely
10/12/2024, 7:53 AMdatajoely
10/12/2024, 7:53 AMwhich python
what shows upVishal Pandey
10/12/2024, 7:59 AMwhich python
nothing shows up
So basically what i was really doing is I am trying to setup a kedro project in my new laptop. I simply cloned the project from github and ran
uv pip compile requirements.in --universal --output-file requirements.txt
After that I did uv init
- got some error saying that project already initialised and pyproject.toml
already exists , So i deleted the default one created by kedro init
and reran uv unit . It published a minimal pyproject.toml
[project]
name = "warehouse-pipeline"
version = "0.1.0"
description = "Add your description here"
readme = "README.md"
requires-python = ">=3.13"
dependencies = []
and a uv.lock file
version = 1
requires-python = ">=3.13"
[[package]]
name = "warehouse-pipeline"
version = "0.1.0"
source = { virtual = "." }
Now I am trying to make use of requirements file to setup the environment.Vishal Pandey
10/12/2024, 8:08 AMVishal Pandey
10/12/2024, 8:25 AMvenv --python 3.9
in the kedro project folder.
2. Activated the environment
3. uv init
Now I have proper python version declared in pyproject.toml earlier for some reason it took default latest python
4. Now i did uv pip install -r requirements.txt
Worked like a charm nowdatajoely
10/12/2024, 9:13 AMVishal Pandey
10/12/2024, 9:14 AMdatajoely
10/12/2024, 9:16 AMdatajoely
10/12/2024, 9:17 AMVishal Pandey
10/12/2024, 9:18 AMVishal Pandey
10/12/2024, 9:18 AMVishal Pandey
10/12/2024, 9:19 AMdatajoely
10/12/2024, 9:20 AMuv add
will compile them toodatajoely
10/12/2024, 9:20 AMdatajoely
10/12/2024, 9:20 AMVishal Pandey
10/12/2024, 9:25 AMuv sync
actually removes all the installed packages from requirements.txt becuase it actually trying to sync with dependencies defined in pyproject.toml
or uv.lock
which is empty for me currently 😛Juan Luis
10/13/2024, 5:01 PMVishal Pandey
10/13/2024, 5:59 PMJuan Luis
10/13/2024, 9:06 PMVishal Pandey
10/14/2024, 3:01 AMpoetry add
or uv add
, they both are backed by powerful dependency resolution algorithms.
4. The best thing is they will maintain a list of dependencies for you in pyproject.toml
5. Both of them offers a nice way to lock the exact versions of dependencies and the transitive dependencies in some kind of lock file, This lock file can be checked into VCS and can be later used by developers to reproduce an exact similar environment in which the application or library was developed.
6. The above points are mainly from dependency management point of view and we get rid of tools like pip
, pipreqs
, pip-tools
. One thing to note here is tools like poetry and uv does not just do dependency resolution but it manages for you and it does it really well.
7. At the end it makes the life easier to build and publish a package if needed.
8. Uv is superfast in everything .
Cheers 🥂Vishal Pandey
10/14/2024, 3:04 AMJuan Luis
10/14/2024, 7:50 AMdatajoely
10/14/2024, 8:01 AMJuan Luis
10/14/2024, 8:06 AMJuan Luis
10/14/2024, 8:08 AM