Giter Club home page Giter Club logo

idae's Introduction

Idae

Poetry Code style: black Ruff Imports: isort Checked with mypy codecov

CI PyPI - Python Version PyPI PyPI - License

A PEP 723 implementation

Usage

Run like normal Python except that the first argument must be a path to the script.

idae example.py

The dependency specification within the Python script must be like the following (example from PEP 723):

#!/usr/bin/env idae
# /// script
# requires-python = ">=3.11"
# dependencies = [
#   "requests<3",
#   "rich",
# ]
# ///

import requests
from rich.pretty import pprint

resp = requests.get("https://peps.python.org/api/peps.json")
data = resp.json()
pprint([(k, v["title"]) for k, v in data.items()][:10])

If you need to pass arguments that look like options for idae to the script you want to run, use the standard UNIX convention of --. For example, let's say you have a script

# script.py
import sys
print(" ".join(sys.argv[1:]))

and you want that script to output I am --help. To run it with Idae, use

idae script.py -- I am --help

Caveats

How it works

  1. Detect script file
  2. Detect appropriate Python executable
  3. Use venv to create a temporary virtual environment in the user cache directory using the executable detected
  4. Find PEP 723 pip requirements
  5. Install them into the virtual environment
  6. Run the script within the virtual environment

Run idae clean to remove all cached environments to free up space. Environments are cached per set of requirements.

Installation

You can get this project via pip

$ pip install idae

But we highly recommend you install this project using pipx

$ pipx install idae

Why the name

The scientific name for Pythons is "Pythonidae". I just removed the "Python" and we get "idae".

License

This project is licensed under the GNU GPL v3+.

In short, this means you can do anything with it (distribute, modify, sell) but if you were to publish your changes, you must make the source code and build instructions readily available.

If you are a company using this project and want an exception, email me at [email protected] and we can discuss.

idae's People

Contributors

flying-sheep avatar thatxliner avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

Forkers

flying-sheep

idae's Issues

[REQUEST]: Check for broken venv

Prerequisites

  • I have searched the issues and believe that it has not already been requested (and possibly rejected)
  • I have made sure that this feature isn't possible with this project's plugin system and/or configuration; core changes must be made to make this happen.
  • I agree to follow the Code of Conduct

Feature description

e.g. when bin/python doesn't exist

Better caching

Prerequisites

  • I have searched the issues and believe that it has not already been requested (and possibly rejected)
  • I have made sure that this feature isn't possible with this project's plugin system and/or configuration; core changes must be made to make this happen.
  • I agree to follow the Code of Conduct

Feature description

By resolving the dependencies before hand. This way, requirements such as beautifulsoup<4.12.3,>4.12.1 and beautifulsoup4==4.12.2 are practically equal.

This viability of this needs further discussion

Better UI

Prerequisites

  • I have searched the issues and believe that it has not already been requested (and possibly rejected)
  • I have made sure that this feature isn't possible with this project's plugin system and/or configuration; core changes must be made to make this happen.
  • I agree to follow the Code of Conduct

Feature description

  • It should be clear on what step we're currently on and there should be a clear distinction between idae output and program output.
  • pip install failures should be shown and addressed.
  • Make the command line utility more fully-fledged, with proper option parsing
  • Option to not use cache

[REQUEST]: Logging

Prerequisites

  • I have searched the issues and believe that it has not already been requested (and possibly rejected)
  • I have made sure that this feature isn't possible with this project's plugin system and/or configuration; core changes must be made to make this happen.
  • I agree to follow the Code of Conduct

Feature description

  • pip output reporting
  • Better internal logging
  • Verbosity flags

[Bug]: Update to accepted 723 syntax

Prerequisites

  • I have searched the issues and believe that it has not already been reported
  • I have made sure this bug reproduces on the latest version
  • I agree to follow the Code of Conduct

Bug description

PEP 723 has been adjusted to the following syntax:

# /// script
# requires-python = ">=3.11"
# dependencies = [
#   "requests<3",
#   "rich",
# ]
# ///

Posting this here just in case you have not followed the lengthy discussions. I’ll look into doing a pr if I have some time this week.

Reproduction steps

  1. See https://peps.python.org/pep-0723/

Other information

No response

Reproduces how often

I can reproduce this bug 100% of the time

[REQUEST]: Caching

Prerequisites

  • I have searched the issues and believe that it has not already been requested (and possibly rejected)
  • I have made sure that this feature isn't possible with this project's plugin system and/or configuration; core changes must be made to make this happen.
  • I agree to follow the Code of Conduct

Feature description

Idae deletes the venv every time, which is slow. We could store environments so they can be reused as long as the dependencies stay the same.

A good way to get a hash for the set of dependencies would be Hatch’s code, which takes care of normalizing dependencies: https://github.com/pypa/hatch/blob/ce186ae60beb4b5f73ebd78fd9bd0c6d27a62a4c/src/hatch/utils/dep.py#L23-L34

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.