Skip to main content

depz

Generic badge PyPI version shields.io Actions Status Generic badge Generic badge

Command-line tool for symlinking directories with reusable source code into the project.

Language-agnostic.

Why

Reusing code should be simple. If I have the needed code in a directory on a local drive, I just want to include it in the project. Without packaging it as a library for distribution or messing with IDE settings.

My first thought is to create a symlink:

$ ln -s /abc/libs/mylib /abc/project/mylib

Now project sees mylib as a local directory project/mylib. I can edit both project and mylib while working on the project.

But here problems arise:

  • Portability. How do I make the symlinks easy to recreate on another system?
  • Recursive local dependencies. How to include not only mylib, but all the dependencies of mylib?

The answer is depz. It reduces these tasks to a one-line command.

Install

Get a working Python ≥3.7 and pip. You may also need a computer. Then:

$ pip3 install depz

Make sure that it is installed:

$ depz --help

Upgrade it later:

$ pip3 install depz --upgrade

Use

  • Specify dependencies in depz.txt
  • Run the command depz

Specify dependencies

File xxx/depz.txt lists dependencies for xxx:

  • /abc/myproject/depz.txt for myproject
  • /abc/libs/mylib/depz.txt for mylib

The depz.txt format:

# lines that specify local directory 
# names are LOCAL dependencies

/absolute/path/to/mylib1
../libs/mylib2
~/path/mylib3

# lines that cannot be resolved to an existing 
# directory are considered EXTERNAL dependencies

requests
numpy

Run

$ cd /abc/myproject
$ depz

This recursively scans /abc/myproject/depz.txt and prints all the found dependencies. Doesn't make any changes to the file system.


$ cd /abc/myproject
$ depz --relink

Removes all the symlinks found in /abc/myproject. Adds new symlinks to the local dependent directories. Prints external dependencies.

Local dependencies

They are recursive

When a project depends on local mylib, it means, it also depends on all the dependencies of mylib. So after scanning myproject/depz.txt we will also scan mylib/depz.txt to include its dependencies too.

Paths are relative to the current depz.txt

When we scan /abc/myproject/depz.txt, the paths are relative to /abc/myproject. Then we found a link to mylib and started scanning /abc/mylib/depz.txt. The paths found there are relative to /abc/mylib.

But all the symlinks will go directly into /abc/myproject.

The following examples show how the directories will be linked when running depz for /abc/project:

Default behavior

File Line Resolves to Creates symlink
/abc/project/depz.txt /abc/libs/aaa /abc/libs/aaa /abc/project/aaa
/abc/project/depz.txt ../libs/bbb /abc/libs/bbb /abc/project/bbb
/abc/libs/aaa/depz.txt ../ccc /abc/libs/ccc /abc/project/ccc

With --mode=layout

File Line Resolves to Creates symlink
/abc/project/depz.txt /abc/libs/aaa /abc/libs/aaa/src
/abc/libs/aaa/test
/abc/project/src/aaa
/abc/project/test/aaa
/abc/project/depz.txt ../libs/aaa /abc/libs/bbb/src
/abc/libs/bbb/test
/abc/project/src/bbb
/abc/project/test/bbb
/abc/libs/aaa/depz.txt ../ccc /abc/libs/ccc/src
/abc/libs/ccc/test
/abc/project/src/ccc
/abc/project/test/ccc

This is useful for frameworks with strict directory structures such as Flutter.

External dependencies

By default, the list of all external dependencies is simply printed to the terminal like that:

$ depz

Depz file: /abc/myproject/depz.txt
...
External dependencies: pandas numpy requests

The -e argument causes the command to print only the list of dependencies.

Print in one line:

$ depz -e line

pandas numpy requests
[click to open] This can be useful for installing Python external dependencies
$ pip3 install $(depz -e line)

Or install external dependencies and symlink local ones:

$ pip3 install $(depz -e line --relink)

Print one per line:

$ depz -e multi

pandas
numpy
requests
[click to open] Sample usage for creating requirements.txt for Python
$ depz -e multi > requirements.txt

Metadata

Release files for depz 0.0.6.1

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

Source distribution (sdist)

Source distribution for depz 0.0.6.1
File Size Uploaded Provenance
depz-0.0.6.1.tar.gz 13.5 kB Without provenance Details

Built distribution (wheel)

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

Total release size: 28.1 kB

Release files / depz-0.0.6.1.tar.gz

Download URL depz-0.0.6.1.tar.gz
Size 13.5 kB
Tags Source
SHA-256 checksum
How to use checksums
6df0912576fb44d6999e8a03d9140677fd43c0e89724894c3fc268eb9cdedbc8
BLAKE2b-256 checksum
How to use checksums
f63faa9f18cffe7fef59b3cd398138720bc19df647f4aca326b079570815ec90
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.58.0 CPython/3.9.2

Release files / depz-0.0.6.1-py3-none-any.whl

Download URL depz-0.0.6.1-py3-none-any.whl
Size 14.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
0d300365d4ba3431a032506f4534534acc44857f266b99e53c07a32850ec8aa6
BLAKE2b-256 checksum
How to use checksums
c9c03e69d360ff3b5ebdfb227bb80910f0457b9dda0db3e759096f4dd76bbd14
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.58.0 CPython/3.9.2

Security for depz 0.0.6.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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