npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

autopy

v1.1.1

Published

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

Downloads

171

Readme

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.