denosaurs / denosaurs/python.mod.land
suggestion: Auto-install Python modules with pip if module is not installed
- Lingua principale
- TypeScript
- Stelle
- 11
- Fork
- 1
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Descrizione
Great work on this project! 🎉
I think it would be a good idea to add code to try and install a Python module if it's not already installed.
I wrote a very simple proof-of-concept for one of my projects here:
https://github.com/tjosepo/deno_numpy/blob/main/src/shared/numpy.ts
```ts
import { python, PythonError } from "../../deps.ts";
let numpy: any;
try {
numpy = python.import("numpy");
} catch (error: unknown) {
if (!(error instanceof PythonError)) throw error;
if (error.message !== "No module named 'numpy'") throw error;
const p = Deno.run({ cmd: "pip install numpy".split(" ") });
await p.status();
numpy = python.import("numpy");
}
export default numpy;
```
This approach isn't perfect as it assumes the user has pip installed, but I feel like it would be a good improvement for most users, and it can be further iterated upon in the future.
Guida per i contributori
Nessuna guida per i contributori indicizzata per questo repository
Direzione di ricerca
Non è indicato alcun file del repository né alcun test. Inizia leggendo l’importazione del modulo e la gestione di PythonError intorno a python.import, quindi confronta la proof of concept collegata in src/shared/numpy.ts e il relativo flusso di Deno.run per pip install. Done dovrebbe includere una politica di installazione concordata, il comportamento in caso di errore e test per i moduli mancanti e per quelli installati correttamente.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- python, typescript
- Ambito
- tooling
- Tipo di issue
- Funzionalità
- Difficoltà
- 5/5
- Tempo stimato
- Più di una settimana
- Stato di attività
- Ferma
- Chiarezza
- Abbastanza chiara
- Idoneità per principianti
- 25/100