Skip to main content

Makes it easy to work with Python projects containing lots of packages, of which you only want to develop some.

Project description

mxdev [mɪks dɛv] is a utility that makes it easy to work with Python projects containing lots of packages, of which you only want to develop some.

It builds on top of the idea to have stable version constraints and then develop from a VCS on top of it.

Other software following the same idea are mr.developer for Python’s zc.buildout or mrs-developer for NPM packages.

Overview

mxdev procedure is:

  1. Configuration is read,

  2. Requirements and constraints (given in configuration) are read.

  3. Sources from VCS are fetched into a target directory,

  4. Modified constraints (handled packages commented)/ requirements (handled packages as editable from sources) are written.

mxdev will not run pip for you!

Configuration

Given a requirements.txt (or similar named) file which itself references a constraints.txt file inside.

Create an INI file, like sources.ini in configparser.ExtendedInterpolation syntax.

The main section must be called [settings], even if kept empty. In the main sections the input and output files are defined.

requirements-in

Main requirements file to start with. This can be an URL too. Default: requirements.txt

requirements-out

Output of the combined requirements including development sources to be used later with pip install. Default: requirements-dev.txt

constraints-out

Output of the combined constraints. Default: constraints-dev.txt

default-target

Target directory for sources from VCS. Default: ./sources

default-install-mode

Default for install-mode on section, read there for details Allowed values: direct, interdependency, skip Default: interdependency

Additional, custom variables can be defined as key = value pair. Those can be referenced in other values as ${settings:key} and will be expanded there.

Subsequent sections are defining the sources.

[PACKAGENAME]

The section name is the package name.

url = URL

the URL to the source in VCS and must follow the pip install editable format.

Attention, this differs from the format one copies from Github/Gitlab, etc. Fo convienince mxdev applies auto-correction for these common cases:

  • ssh:// -> git+ssh://

  • git@ -> git+ssh://git@

  • https:// t-> git+https://

The URL is required.

branch = BRANCHNAME_OR_TAG

the branch name or tag to checkout. Defaults to main.

extras = EXTRA1,EXTRA2

Package extras to install. Default empty.

subdirectory = SUBPATH

For specifying the path to the Python package, when it is not in the root of the VCS directory. Default empty.

target

Target directory for source from this section. Default to target directory configured in main section [settings] default-target = value.

install-mode

There are different modes of pip installation:

skip

Do not install with pip, just clone/update the repository.

direct

Install the package using pip -e PACKAGEPATH. Dependencies are resolved immediately.

interdependency

Pre-install the packages first using pip -e PACKAGEPATH --install-option="--no-deps". After all packages are pre-installed, install them again with dependencies using pip -e PACKAGEPATH. This helps if one develops many package with dependencies between those packages. With direct the order of the packages matters, so a developer would need to do manual dependency management. With interdependency mode this is circumevented by pre-installing all this packages without dependencies first.

Defaults to install-dependencies configured in main section [settings] default-install-mode = value.

Usage

Run mxdev -c sources.ini.

Now use the generated requirements and constrainst files with pip install -r NEW_REQUIREMENTS_FILENAME.txt.

Example Configuration

This looks like so:

[settings]
requirements-in = requirements-infile.txt
requirements-out = requirements-outfile.txt
contraints-out = constraints-outfile.txt

# custom variables
github = git+ssh://git@github.com/

[foo.bar]
url = ${settings:github}orga/foo.bar.git
branch = fix99
extras = test,baz

Rationale

Problem

There is a constraint file like -c constraints.txt with a package foo.bar with a version pin. Then it is not possible to install this package in a requirements file editable like -r requirements.txt with -e git+ssh://git@github.com/orga/foo.bar.git@fix-99.

Idea

A pre-processor fetches (as this can be an URL) and expands all -c SOMEOTHER_FILE_OR_URL and -r SOMEOTHER_FILE_OR_URL files into one, filtering out all packages given in a configuration file. For each of those packages a -e ... entry is generated instead and written to a new TARGET.txt. The configuration is written in a file sources.ini in ExtendedInterpolation INI syntax (YAML would be nice, but the package must have as less dependencies as possible to other packages).

Trivia

Mx (generally pronounced like mix [mɪks], or [məks] in the UK) is meant to be a gender-neutral alternative to the titles Mr. and Ms. but also associates with mix.

Changelog

1.0.0a9 (2021-12-01)

  • Added autocorrection for pip urls, so that github or gitlab urls can be used as copied in sources.ini . [zworkb]

1.0.0a8 (2021-11-30)

  • Added interdependency handling to avoid manual dependency order resolution. [jensens, gogobd]

  • Added skip mode to exclude packages from installation (clone/update only). [jensens, gogobd]

  • Removed position feature. [jensens, gogobd]

1.0.0a7 (2021-11-30)

  • Removed Workaround for libvcs and depend on libcs>=0.10.1. [jensens]

1.0.0a6 (2021-11-30)

1.0.0a5 (2021-11-30)

1.0.0a4 (2021-11-29)

  • Fix: editables can be configured to be processed before or after initial requirements. [jensens]

1.0.0a3 (2021-11-23)

  • Fix #1: Re-run of pip vanishes comitted changes [jensens]

1.0.0a2 (2021-11-21)

  • Fix/simplify packaging. [jensens]

  • Implement subdirectory editable install [jensens]

  • Implement package extras [jensens]

1.0.0a1 (2021-11-21)

  • Initial work. [jensens]

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mxdev-1.0.0a9.tar.gz (8.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

mxdev-1.0.0a9-py3-none-any.whl (7.0 kB view details)

Uploaded Python 3

File details

Details for the file mxdev-1.0.0a9.tar.gz.

File metadata

  • Download URL: mxdev-1.0.0a9.tar.gz
  • Upload date:
  • Size: 8.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.6.0 importlib_metadata/4.8.2 pkginfo/1.8.1 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.8

File hashes

Hashes for mxdev-1.0.0a9.tar.gz
Algorithm Hash digest
SHA256 c4b04ac36b6eb5edfddfa1d05b29e024f3ff83670273280192e05915df27ce50
MD5 95a35342fa29e68646376c505777aa6c
BLAKE2b-256 2c33dda1c63c7867f47c90fc5051b16b9a4dfc3919f8fa825aef0cbcf9e9de09

See more details on using hashes here.

File details

Details for the file mxdev-1.0.0a9-py3-none-any.whl.

File metadata

  • Download URL: mxdev-1.0.0a9-py3-none-any.whl
  • Upload date:
  • Size: 7.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.6.0 importlib_metadata/4.8.2 pkginfo/1.8.1 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.8

File hashes

Hashes for mxdev-1.0.0a9-py3-none-any.whl
Algorithm Hash digest
SHA256 b96e117c7bcbb2eaddd6da4f2ffa246ffd9c240041858bc19e217b0d47c741ee
MD5 480f57751acc264d0c7a254298453916
BLAKE2b-256 981df251bc8b8c9f24eb489d84b56304558a84d6f2efeb96b091b21deb26e9ad

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page