Coder Social home page Coder Social logo

pipsource's Introduction

pipsource - Install vendored Python pip packages from source

circleci

This package provides a simple utility for vendoring Python pip packages that are hosted in git repos and generating a script that will install them into a virtualenv without relying at all on the PyPI package repository.

See the Package repo security considerations for why vendoring, building from source (and code auditing) help protect against certain types of malicious package attacks.

Installation

Usage

Because pip packages depend on other packages, in order to vendor a single package requires vendoring its dependencies.

1. Identify the packages you want to vendor and install from source

Create a requirements.txt file with those packages. Only exact package numbers are supported. Example:

# requirements.txt
pynvim=0.3.2
autopep8=1.4.4

Run pipsource vendor requirements.txt

2. Vendor the source code for these packages

Run pipsource

1. Set up a package_repo_map.json file

Building those packages from source requires pulling in the source. In order to do that conveniently, this utility depends on a JSON file that maps pip package names to their Git (or Mercurial) source URLs and a way to find a commit for a particular version (via a tag pattern or version to commit map).

See the "JSON package map format" section below for details on the format.

2.

JSON package map format

You configure a list of desired pip packages by creating a JSON file that looks like this:

{
  "packages": [
    "[package-name]": {
      "git": "[git-https-url]",
      "hg": "[mercurial-https-url (use instead of `git` field if package uses hg)]"
      "version-tag-format": "[optional, format with %s, e.g. 'v%s', default is '%s']",
      "version-commits": {
        "[version]": "[git-sha-hash, use this map if package lacks version tags]"
      },
      "skip-vendor-python2": [set to true to not vendor if using python3],
      "skip-vendor-python3": [set to true to not vendor if using python2]
    },
    ...
  ]
}

Example package map

For example, in this config, PyYAML uses the default version tag format of %s, e.g. 5.1.1. The ansicolor package however does not have tags, so we need an explicit map of version to Git commit hash. The autoflake package shows an exmaple of a non-default version format; it has version tags with a v prefix, e.g. v1.3. The configparser shows a Mercurial URL example.

{
  "packages": {
    "PyYAML": {
      "git": "https://github.com/yaml/pyyaml"
    },
    "ansicolor": {
      "git": "https://github.com/numerodix/ansicolor",
      "version-commits": {
        "0.2.6": "a5a5c31dc6de5c864a0c5684ae326972573a712b"
      }
    },
    "autoflake": {
      "git": "https://github.com/myint/autoflake",
      "version-tag-format": "v%s"
    },
    "configparser": {
      "hg": "https://bitbucket.org/ambv/configparser"
    }
  }
}

pipsource's People

Contributors

draffensperger avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.