Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

autopy

Package Overview
Dependencies
Maintainers
2
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

autopy

Library for depending on Python packages from JavaScript that will automatically manage a venv and download Python and pip dependencies.

  • 1.1.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
90
increased by143.24%
Maintainers
2
Weekly downloads
 
Created
Source

autopy

Library for depending on Python packages from JavaScript that will automatically manage a venv and download Python and pip dependencies.

Autopy is a library that simplifies the integration of Python libraries in JavaScript projects. It can automatically download a Python distribution with a given version, create a virtual environment, and install the desired dependencies into that. It then gives you a function that you can use to run commands in the virtual environment, with all necessary environment variables set up correctly.

Autopy is designed for scenarios where you need to depend on Python tools and libraries that are not available or easy to use in JavaScript. With autopy, you can leverage the power of Python without leaving your JavaScript ecosystem.

Autopy works on Windows (32-bit and 64-bit), Linux (x86_64, i686, and aarch64), and macOS (x86_64 and arm64). It uses python-build-standalone to download pre-built Python distributions for these platforms and architectures. For that, it calls the GitHub API. Be aware of the privacy implications.

Installation

You can install autopy using yarn or npm:

yarn add autopy
# or `npm i autopy`

API reference

A full API reference can be found in the docs folder.

Example usage

Let's say you want to use the powerful mitmproxy for intercepting and modifying HTTP and HTTPS traffic in your JavaScript project. Here's how you can do that with autopy:

import { getVenv } from 'autopy';

(async () => {
    // Create a virtual environment with mitmproxy installed.
    const python = await getVenv({
        name: 'mitmproxy',
        pythonVersion: '~3.11', // Use any Python 3.11.x version.
        requirements: [{ name: 'mitmproxy', version: '>=9.0' }], // Use any mitmproxy version above 9.0.
    });

    // Run mitmdump to start a proxy server on port 8081.
    const proc = python('mitmdump', ['-p', '8081']);
    proc.stdout?.pipe(process.stdout);

    setTimeout(() => proc.kill(), 1000);
})();

// Output:
// [14:46:27.973] HTTP(S) proxy listening at *:8081.

License

This code is licensed under the MIT license, see the LICENSE file for details.

Issues and pull requests are welcome! Please be aware that by contributing, you agree for your work to be licensed under an MIT license.

FAQs

Package last updated on 08 Jun 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc