![]() Here’s an example Gist containing my datasette-expose-some-environment-variables plugin. This means it’s possible to create and host a full Python package just using a Gist, by packaging together a setup.py file and one or more Python modules. This isn’t as useful as checking out the code directly, since it’s harder to review the code in a text editor-but it’s useful knowing it’s possible. I can install that in a fresh environment on my machine using: pip install This is a new trick I discovered this morning: there’s a hard-to-find URL that lets you do the same thing for code in pull requests.Ĭonsider PR #1717 against Datasette, by Tim Sherratt, adding a -timeout option the datasette publish cloudrun command. Then in my requirements.txt file I drop in a URL to the fix in my own repository-with a comment reminding me to switch back to the official package as soon as they’ve applied the bug fix. I create a fork on GitHub, apply my fix and send a pull request to the project. I sometimes use this trick when I find a bug in an open source Python library and need to apply my fix before it has been accepted by upstream. But if you don’t want to remember or look them up you can instead find them using the Code -> Download ZIP menu item for any view onto the repository: That last option, installing for a specific commit hash, is particularly useful in requirements.txt files since unlike branches or tags you can be certain that the content will not change in the future.Īs you can see, the URLs are all predictable-GitHub has really good URL design. pip install -installs the package from the snapshot at commit e64d14e413a955a10df88e106a8b5f1572ec8613-note that you can use just the first few characters in the URL rather than the full commit hash.pip install -installs the latest head from my 0.60.x branch.pip install -installs version 0.61.1 of Datasette, via this tag.pip install installs the latest main branch from the simonw/datasette repository.This means you can use URLs to install tags, branches and even exact commits! If your repository contains a Python package with a setup.py file, those URLs will be compatible with pip install. The datasette publish commands have an -install option for installing plugin which works with URLs too: datasette publish cloudrun mydatabase.db \Īny reference in a GitHub repository can be downloaded as a zip file or tarball-that means branches, tags and commits are all available. This works with URLs too, so you can install that plugin like so: datasette install It exists purely so that people can install Datasette plugins easily without first having to figure out the location of Datasette’s Python virtual environment. datasette installĭatasette has a datasette install command which wraps pip install. You can also list URLs like this directly in your requirements.txt file, one per line. Here’s a quick and simple Datasette plugin I built a while ago that I install using this option: pip install '' I sometimes use this to distribute ad-hoc packages that I don’t want to upload to PyPI. The most common way of using pip is with package names from PyPi: pip install datasetteīut the pip install command has a bunch of other abilities-it can install files, pull from various version control systems and most importantly it can install packages from a URL. ![]() Combining these is a really useful trick for maintaining Python packages. GitHub provides URLs that can create a zip file of any branch, tag or commit in any repository. ![]() ![]() The pip install command can accept a URL to a zip file or tarball. Useful tricks with pip install URL and GitHub ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |