-
Notifications
You must be signed in to change notification settings - Fork 0
Hacking
The easiest way to get started with the latest beets source is to use pip to install an "editable" package. Use one of the following commands: (If you want to use the hg repo you will also need Mercurial installed.)
$ pip install -e git+https://github.com/sampsyo/beets.git#egg=beets
-- or --
$ pip install -e hg+https://bitbucket.org/adrian/beets#egg=beets
(To install into a virtualenv, provide the -E
option to
pip.) If you already have a released version of beets installed, you may need to
remove it first by typing pip uninstall beets
. The pip command above will put
the beets source in a src/beets
directory and install the beet
CLI script to
a standard location on your system. You may want to use the --src
option to specify
the parent directory where the source will be checked out and the --user
option
s.t. the package will be installed to your home directory (c.f. the output of
pip install --help
).
Alternatively, you can get the source via either
Mercurial at BitBucket
or
git at the GitHub mirror. The pip method above installs
dependencies automatically, but if you do it manually, you can use pip to
install the Python modules mutagen
, munkres
, unidecode
, pyYAML
, and
musicbrainzngs
. With that in place, you can just type ./beet
in the
source directory to run beets from there.
Consider joining the mailing list for beets. It's fairly low-traffic and is used by both users and developers on the project. Or hang out in the #beets IRC channel on Freenode.
You can help out with the beets project even if you're not a Python hacker! Here are a few ideas:
- Promote beets! Help get the word out by telling your friends, writing a blog post, or discussing it on a forum you frequent.
- Improve the Web site. Beets' current site is pretty basic. If you have design expertise, consider contributing a new homepage for the project.
- GUI design. For the time being, beets is a command-line-only affair. But that's mostly because I don't have any great ideas for what a good GUI should look like. If you have those great ideas, please get in touch.
- Benchmarks. I'd like to have a consistent way of measuring speed improvements in beets' tagger and other functionality as well as a way of comparing beets' performance to other tools. You can help by compiling a library of freely-licensed music files (preferably with incorrect metadata) for testing and measurement.
The Architecture page serves as an introduction to beets' design.
For more details, the docstrings in the code should be somewhat elucidating.
Type pydoc beets.ui
, for instance, to get information about the UI module.
There are always interesting problems (both features and bugs) to work on in the issue tracker.
There are a few coding conventions I use in beets that you should probably know about if you want to work on beets:
- I'm currently trying to target Python 2.6 as a minimum version -- so don't
try to use
DefaultDict
, for example. - Whenever you access the library database, do so through the provided Library
methods or via a Transaction object. Never call
lib.conn.*
directly. Transaction objects help control concurrent access to the database and assist in debugging conflicting accesses. - Consider using the future imports
print_function
,division
,absolute_import
, or evenunicode_literals
. These help keep your code modern and will help in the eventual move to Python 3. - Never
print
informational messages; use the logging module instead. Always log Unicode strings (e.g.,log.debug(u"hello world")
). Prefer str.format over the % operator. Remember to usebeets.util.displayable_path
to format paths for logging. (Note that there are still plenty of logging statements that need to be converted to Unicode. The commandack "log\.\w*\\([^u]"
reveals them.)
A great deal of convention deals with the handling of paths. Paths are stored internally -- in the database, for instance -- as byte strings (not unicode objects). This is because POSIX operating systems' path names are only reliably usable as byte strings -- even if you request unicode paths, you might still get back bytes. On Windows, the strings are always encoded with UTF-8; on Unix, the encoding is controlled by the filesystem. Here are some guidelines to follow:
- If you have a Unicode path or you're not sure whether something is Unicode or
not, pass it through
bytestring_path
function in thebeets.util
module to convert it to bytes. - Pass every path name trough the
syspath
function (also inbeets.util
) before sending it to any operating system file operation (open
, for example). This is necessary to use long filenames (which, maddeningly, must be Unicode) on Windows. This allows us to consistently store bytes in the database but use the native encoding rule on both POSIX and Windows. - Similarly, the
displayable_path
utility function converts bytestring paths to a Unicode string for displaying to the user. Every time you want to print out a string to the terminal or log it with thelogging
module, feed it through this function.
For style, I do my best to adhere to PEP 8 (but let me know if I get lazy).
Personally, I work on beets with vim. Here are some
.vimrc
lines that might help with PEP 8-compliant Python coding:
filetype indent on
autocmd FileType python setlocal shiftwidth=4 tabstop=4 softtabstop=4 expandtab shiftround autoindent
Consider installing this alternative Python indentation plugin. I also like pyflakes.vim.