Skip to main content

Sync your packages with your dotfiles (and vice versa).

Project description

Sync your packages with your dotfiles (and vice versa)
======================================================

When we use a package manager (be it apt, pip, npm,…), we want to sync
the list of installed packages in requirement files. We then declare a
mapping that links a package manager to its requirements file:

.. code:: python

REQUIREMENTS_ROOT_DIR = "~/dotfiles/"
REQUIREMENTS_FILES = {
"apt": {
"file": "apt.txt", # => ~/dotfiles/apt.txt
"pacman": "apt-get",
"install": "install -y --force-yes",
"uninstall": "remove",
},
# and so on for pip, pip3, gem, npm, docker and guix.
}

and we call

.. code:: example

syp --pm apt foo bar

to add the two packages "foo" and "bar" in ``~/dotfiles/apt.txt`` and at
the same time, to check if this list has been edited manually (with
packages added or removed) and act accordingly (we make diffs against
the cache at ``~/.syp/apt.txt``).

See the Settings section below.

Tested on python 2.7 and 3.4.

Usage
-----

The basic usage is to check all of the package managers, and install and
remove what's necessary:

Example:

.. code:: example

syp

can output:

.. raw:: html

<img src="http://i.imgur.com/NXiddZB.png" </img>

We set the package manager with ``--pm`` and **give one or many packages
to install**:

.. code:: example

syp --pm pip syp foo bar

will append "syp", "foo" and "bar" at the bottom of
``~/dotfiles/pip.txt`` (if they are not there yet), check if pip.txt was
manually edited, and suggest a list of packages to install and remove.

So a suggested alias is

.. code:: example

alias sypip="syp --pm pip "

If no package manager is specified, **we use apt by default** (see
Settings below).

To **remove packages**, use ``--rm``:

.. code:: example

syp --pm pip foo --rm

We can **add a message** with ``-m``. It will be appended on the same
line:

.. code:: example

syp --pm pip foo -m "foo is a cool package"

We can **edit the list** of packages for that package manager before the
operations with ``-e`` (``--editor``):

.. code:: example

syp --pm pip foo --rm -e

Settings
========

The default settings come with a configuration for ``apt``, ``pip``,
``pip3``, ``gem``, ``npm``, ``docker`` and ``guix``.

The user settings, stored at ``~/.syp/settings.py``, is a regular python
file that will be ``exec``'ed on startup. So, if you want to add or
overide a package manager settings, edit the ``REQUIREMENTS_FILES``
dictionnary accordingly. Only the key "file" is required:

.. code:: python

REQUIREMENTS_FILES['apt'] = {
"file": "requirements-apt.txt", # required. appended to REQUIREMENTS_ROOT_DIR
"pacman": "aptitude", # by default, same as the package manager name, here 'apt'
"install": "install -y", # 'install' by default
"uninstall": "remove", # 'uninstall' by default.
}

See also

.. code:: python

#: The base directory where lies the configuration files.
REQUIREMENTS_ROOT_DIR = "~/dotfiles/"

#: System package manager, as a default.
SYSTEM_PACMAN = "apt-get"

Develop
=======

.. code:: example

pip install -e .

Todos and ideas
===============

- auto commit
- auto-recognize a virtualenv ?
- allow for more than a requirement file for one package manager.
- ask all and apply
- more tests

Bust most of all... use `Guix <https://gnu.org/software/guix/>`__ !

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

syp-0.1.6.tar.gz (8.3 kB view details)

Uploaded Source

Built Distributions

syp-0.1.6-py2.7.egg (23.2 kB view details)

Uploaded Source

syp-0.1.6-py2-none-any.whl (17.8 kB view details)

Uploaded Python 2

File details

Details for the file syp-0.1.6.tar.gz.

File metadata

  • Download URL: syp-0.1.6.tar.gz
  • Upload date:
  • Size: 8.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for syp-0.1.6.tar.gz
Algorithm Hash digest
SHA256 bd3b559f8acc2b359d9a1b0c04fd6eb6c6e347a9052149f42e056729bdf7ed9b
MD5 90a2aa9030d63f7bde94ff0ae2463dff
BLAKE2b-256 ac7f7e568fb1aa7c95073c10425095ae29cd8158e50e815763a0e93e784ca8d2

See more details on using hashes here.

File details

Details for the file syp-0.1.6-py2.7.egg.

File metadata

  • Download URL: syp-0.1.6-py2.7.egg
  • Upload date:
  • Size: 23.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for syp-0.1.6-py2.7.egg
Algorithm Hash digest
SHA256 719f8b734a1d39e765be709d1fd652bde0bc0e4b0aa07a4c9988cd9a717be37e
MD5 21330c2b3b867e0ce7973ee485e45b4b
BLAKE2b-256 7c053beae5051c4f197762fa57dcf57ac2aac48b4ae25e7d548b8cce0c841bb0

See more details on using hashes here.

File details

Details for the file syp-0.1.6-py2-none-any.whl.

File metadata

File hashes

Hashes for syp-0.1.6-py2-none-any.whl
Algorithm Hash digest
SHA256 536a1b906e27c4a3de723f18e5a6a9f7c89feffec4df950341596b1915295e23
MD5 e5f76da48fa8ca78974aa82c97743dac
BLAKE2b-256 7eb6679b166ea380f5030556f07e2e33c9b259d6acc56f62bdbdd9647e32f19d

See more details on using hashes here.

Supported by

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