Sync your packages with your dotfiles (and vice versa).
Project description
Sync your packages with your dotfiles
=====================================
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, etc
}
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 command ``syp --init`` and 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
===============
- more tests
- auto-recognize a virtualenv
- undo last action
- auto commit
- allow for more than a requirement file for one package manager.
Bust most of all... use `Guix <https://gnu.org/software/guix/>`__ !
=====================================
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, etc
}
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 command ``syp --init`` and 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
===============
- more tests
- auto-recognize a virtualenv
- undo last action
- auto commit
- allow for more than a requirement file for one package manager.
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.3.tar.gz
(8.3 kB
view details)
Built Distribution
syp-0.1.3-py2-none-any.whl
(17.8 kB
view details)
File details
Details for the file syp-0.1.3.tar.gz
.
File metadata
- Download URL: syp-0.1.3.tar.gz
- Upload date:
- Size: 8.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | c11b5388f8ebeadb7c371239856e1263e9a875e6b0beb88d884796d08c32efc4 |
|
MD5 | 3b8abf86cd3eac36913c2d48a67ed67a |
|
BLAKE2b-256 | 831b7db2edcef27fa1aeb5fe2043fb61984372c1aca4c72926d8ce9e7e9d4da6 |
File details
Details for the file syp-0.1.3-py2-none-any.whl
.
File metadata
- Download URL: syp-0.1.3-py2-none-any.whl
- Upload date:
- Size: 17.8 kB
- Tags: Python 2
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | b59a662ca7e991c78bf3d407ff21d7e9c65f120e4790c2f16f516b87ee8669e8 |
|
MD5 | 4d4d8c20b3bc139ebd5728403ba06673 |
|
BLAKE2b-256 | d396c987ae45aa4a7e8df0a514e943d252b8b52ca803f2121dcde168c617f2c2 |