Skip to main content

CustomDeps

CustomDeps is a tool that manages your modules paths and that lets you import specific versions of modules designated by their Git commit hashes. CustomDeps does this by keeping, in a directory, one copy of the source code of the module(s) for each version you have used at least once.

CustomDeps usually helps you to track the versions of the modules you import directly. However, it does not track imports within the imported modules. If this is relevant to you, please consider other alternatives such as virtual environments.

Installation

pip install CustomDeps

Usage

Let's say you use a module some_module located in a Git project some-project, and you want to do this:

import some_module  # yes, but I want the version at commit 14b2b29a6a5231146245d7b2cc9ce8841eef293c!

With CustomDeps, this is simply done with:

import custom_deps
gr = custom_deps.GitRepos()
gr.insert_path('some-project', '14b2b29a6a5231146245d7b2cc9ce8841eef293c')
import some_module

To be able to use the script above, you first need to register the Git repository some-project. This only needs to be done once, for example in a Python console:

>>> import custom_deps
>>> gr = custom_deps.GitRepos()
>>> gr.add('https://example.com/some-project.git', 'some-project')

add() takes two arguments. The first one is the clone URL of the Git project. The second one is a label that you can freely assign and that designates the project within CustomDeps. Note that the clone URL can also be a local path.

After that, you can start writing scripts that use various versions of some_module as shown above, with insert_path(). This method appends an appropriate directory, containing the project checked out at the relevant commit, to the search paths used to find modules. After the import statement, you can check what file is used by the import like this:

import custom_deps
gr = custom_deps.GitRepos()
gr.insert_path('some-project', '14b2b29a6a5231146245d7b2cc9ce8841eef293c')
import some_module
print(some_module.__file__)
...

which prints something like this:

/home/username/.local/share/CustomDeps/snaps/some-project/14b2b29a6a5231146245d7b2cc9ce8841eef293c/some_module/__init__.py

insert_path() manages automatically the creation of directories with different project versions. When insert_path() is used with a new commit hash, CustomDeps will also perform a git pull from the external repository at the location you indicated when using add(). Therefore, project updates are retrieved transparently, without further action than calling insert_path().

If the module to import is not located at the root of the Git project, you can specify the modules location relative to the project root by passing a third argument to insert_path():

gr.insert_path('some-project', '14b2b29a6a5231146245d7b2cc9ce8841eef293c', 'src/python/modules')

CustomDeps internal directories

Directories used by CustomDeps to manage the different project versions are by default in your user data directory (for example, ~/.local/share/CustomDeps on Ubuntu). For each project, CustomDeps always keeps there working trees checked out at all the versions you have requested once. The location of these directories can be changed by editing the CustomDeps user configuration file (~/.config/CustomDeps/config on Ubuntu).

Licence

Copyright (C) 2018, 2021 Nicolas Bruot (https://www.bruot.org/hp/)

CustomDeps is published under the GPLv3.0 licence.

Metadata

Release files for CustomDeps 0.0.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for CustomDeps 0.0.2
File Size Uploaded
CustomDeps-0.0.2.tar.gz 16.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for CustomDeps 0.0.2
File Interpreter ABI Platform
CustomDeps-0.0.2-py3-none-any.whl Python 3 none any Details

Total release size: 33.6 kB

Release files / CustomDeps-0.0.2.tar.gz

Download URL CustomDeps-0.0.2.tar.gz
Size 16.7 kB
Tags Source
SHA-256 checksum
How to use checksums
cae7f57eee1200f633228a766b15c89ec9e02fd2bf3a39ce205d495593ecf0eb
BLAKE2b-256 checksum
How to use checksums
b84e8e2f958d441e48be211d528f388137b00800105ff1a3a38701d2aa9ac1fb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.1 importlib_metadata/3.10.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.1

Release files / CustomDeps-0.0.2-py3-none-any.whl

Download URL CustomDeps-0.0.2-py3-none-any.whl
Size 16.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
f7a192877b7c44a576133dbab810899f80a7d0737b7bd8225d31a4224f54719f
BLAKE2b-256 checksum
How to use checksums
eda787d70b24fa5a84530d72f81fff1e1541f0c575378994449652132ca203eb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.1 importlib_metadata/3.10.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.1

Release history Release notifications | RSS feed

This release

0.0.2 This release

2 release files

0.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page