Skip to main content

Abode: Friendly Python Packaging

Most experienced Python users know that Python packaging is rough. Abode is an attempt to make things nicer by extending Conda. It uses Conda under the hood, but makes things a bit easier and robust.

Conda is by far my preferred packaging solution. It works as an environment manager (better than virtualenv in my opinion) as well as a package manager. The default repository is focused on data science software. However, Conda also installs packages from PyPI with pip. Also, unlike pip, Conda installs non-Python libraries such as MKL and CUDA that often increase operation speeds by 10-100x.

An aside: I recommend installing Miniconda instead of the full Anaconda distribution. The vast majority of people won't need every single package in the Anaconda distribution. So save yourself some time, bandwidth, and storage. Install Miniconda, then create environments and install packages as needed.

The Main Attraction

The biggest issue with Conda is saving an environment's dependencies and sharing it across platforms. You can get the dependencies using conda env export > environment.yml. Say I have an environment where I have installed Flask, Numpy, and PyTorch. Even though those are the only packages I intentionally installed, Conda installs all the dependencies as well. Conda exports the environment to a YAML file that looks like:

name: flask
channels:
  - pytorch
  - defaults
dependencies:
  - blas=1.0=mkl
  - ca-certificates=2019.5.15=1
  - certifi=2019.6.16=py37_1
  - cffi=1.12.3=py37hb5b8e2f_0
  - intel-openmp=2019.4=233
  - libcxx=4.0.1=hcfea43d_1
  - libcxxabi=4.0.1=hcfea43d_1
  - libedit=3.1.20181209=hb402a30_0
  - libffi=3.2.1=h475c297_4
  - libgfortran=3.0.1=h93005f0_2
  - mkl=2019.4=233
  - mkl-service=2.0.2=py37h1de35cc_0
  - mkl_fft=1.0.14=py37h5e564d8_0
  - mkl_random=1.0.2=py37h27c97d8_0
  - ncurses=6.1=h0a44026_1
  - ninja=1.9.0=py37h04f5b5a_0
  - numpy=1.16.4=py37hacdab7b_0
  - numpy-base=1.16.4=py37h6575580_0
  - openssl=1.1.1c=h1de35cc_1
  - pip=19.1.1=py37_0
  - pycparser=2.19=py37_0
  - python=3.7.4=h359304d_1
  - pytorch=1.2.0=py3.7_0
  - readline=7.0=h1de35cc_5
  - setuptools=41.0.1=py37_0
  - six=1.12.0=py37_0
  - sqlite=3.29.0=ha441bb4_0
  - tk=8.6.8=ha441bb4_0
  - wheel=0.33.4=py37_0
  - xz=5.2.4=h1de35cc_4
  - zlib=1.2.11=h1de35cc_3
  - pip:
    - click==7.0
    - flask==1.1.1
    - itsdangerous==1.1.0
    - jinja2==2.10.1
    - markupsafe==1.1.1
    - werkzeug==0.15.5
prefix: /Users/mat/miniconda3/envs/flask

The issue here is that defining the versions potentially breaks the environment on platforms other than the original one. I created this environment on my MacBook. It is not guaranteed that all these dependencies are available for Linux or Windows, likely breaking the environment on these platforms.

Also, a lot of the time we're not concerned with the exact versions of our packages. Instead we are okay with the newest versions, or any version greater than some release with a specific feature. In these cases, locking to specific versions is overly strict.

You can create essentially the same environment with this file:

name: flask
channels:
  - pytorch
  - defaults
dependencies:
  - numpy
  - pip
  - python=3
  - pytorch
  - pip:
    - flask
prefix: /Users/mat/miniconda3/envs/flask

Conda will take this file and solve all the necessary dependencies on whatever platform you're using. Of course if there are specific versions you want (like python=3 here) you can define those.

Abode manages Conda environments by creating and editing minimal environment files like these. Hopefully this will allow users to take advantage of the great things Conda is doing, while making the environments portable.

Abode Dependencies

  • Python 3.6+ because I like f-strings
  • PyYAML
  • Conda, as noted above, I suggest installing Miniconda instead of the full Anaconda distribution

Installation

Abode is available from PyPI:

pip install abode

Usage

Warning: This is very early. Use at your own risk.

So far this is what I have implemented.

Create an environment

To create a new environment with Python 3 installed:

abode create -n env_name python=3

Behind the scenes this creates an environment file and uses Conda to create an environment from the file.

Create from environment file

To create an environment from an environment file (a YAML file created by Abode or Conda):

abode create -f FILE

Enter an environment

I haven't figure out how to do this without using conda in the shell, so for now:

conda activate env_name

This is pretty high priority for me. It's awkward to switch between abode and conda commands.

Install packages

Installing packages is the same as Conda:

abode install numpy matplotlib

Behind the scenes, Abode is adding these dependencies to the environment file, then updating the environment from the file.

Install with pip

Use the --pip flag to install a package with pip.

abode install flask --pip

Install from a non-default channel

The channel option -c adds the channel to the environment file.

abode install pytorch -c pytorch

Update packages

This updates all the packages in the environment without locked versions.

abode update

Export the environment

abode export > environment.yml

This just copies the active environment's dependency file to the new file.

List packages in the current environment

To print out the list of all installed packages, equivalent to conda list:

abode list

If you want to see which packages have been installed with Abode:

abode list -f

or

abode list --file

List environments managed with Abode

abode env list

Contributions

Happy to work with you on this. Create an issue or a pull request. Say hi.

Release files for abode 0.1.4

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

Source distribution (sdist)

Source distribution for abode 0.1.4
File Size Uploaded
abode-0.1.4.tar.gz 6.4 kB Details

Built distribution (wheel)

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

Total release size: 16.1 kB

Release files / abode-0.1.4.tar.gz

Download URL abode-0.1.4.tar.gz
Size 6.4 kB
Tags Source
SHA-256 checksum
How to use checksums
3009a39ea2b88066d985736c540795c24d4d5dbecfb03a28b65c2a9812119c36
BLAKE2b-256 checksum
How to use checksums
8a79fd3151472e110447022fd725adcc86973595c5a1e1fea8da91dc79a9dc42
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.11.0 pkginfo/1.4.2 requests/2.22.0 setuptools/41.1.0 requests-toolbelt/0.8.0 tqdm/4.23.4 CPython/3.6.9

Release files / abode-0.1.4-py3-none-any.whl

Download URL abode-0.1.4-py3-none-any.whl
Size 9.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
4436fc56c327e12a1048f8d43369b8e1734352069c2d39b1fd1294bd9be90ac7
BLAKE2b-256 checksum
How to use checksums
302d74924b721b9115ddb66df35c73820eb07289c5993e7de69ae28da6e7592f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.11.0 pkginfo/1.4.2 requests/2.22.0 setuptools/41.1.0 requests-toolbelt/0.8.0 tqdm/4.23.4 CPython/3.6.9

Release history Release notifications | RSS feed

This release

0.1.4 This release

2 release files

0.1.3

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

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