@fnet/to-pyip
v0.1.5
Published
## Introduction
Downloads
9
Readme
@fnet/to-pyip
Introduction
The @fnet/to-pyip
project is designed to streamline the process of setting up and managing a Python package environment. It automates the procedure of configuring necessary directories, installing dependencies, and preparing a package for distribution. This tool aims to assist developers by simplifying the steps needed to deploy their Python code.
How It Works
@fnet/to-pyip
operates by creating and managing directories for your package and output files. It sets up a basic environment using template files, organizes the source code, and automates the installation of Python dependencies through integrating with Conda environments. Additionally, it consolidates the package into a distributable format and facilitates its upload to repositories, aiding in smooth project distribution.
Key Features
- Template Rendering: Automatically generates necessary project files based on templates.
- Directory Management: Creates and organizes directories effectively for project source and output files.
- Dependency Installation: Utilizes Conda environments to install necessary dependencies and packages.
- Package Distribution: Prepares the package in a distributable format and supports uploading to repositories.
Conclusion
In essence, @fnet/to-pyip
provides a straightforward way to automate the preliminary steps in Python package management and distribution. It removes much of the manual work involved in setting up and deploying Python projects, allowing developers to focus more on coding and less on configuration.
Developer Guide for @fnet/to-pyip
Overview
The @fnet/to-pyip
library is designed to facilitate the conversion and management of source files, using templating capabilities to prepare those files for deployment in a Python environment. It automates the environment setup, which includes creating necessary directories, copying files, and executing essential Python package management commands. With this library, developers can efficiently transition their Node.js projects into Python packages and manage the associated dependencies seamlessly.
Installation
To install @fnet/to-pyip
using npm, execute the following command in your terminal:
npm install @fnet/to-pyip
Alternatively, if you are using yarn, you can install it with:
yarn add @fnet/to-pyip
Usage
Follow these usage guidelines to integrate @fnet/to-pyip
into your workflow:
Setup Project with Source and Destination: You need to specify source and destination directories where the library will find the necessary project files and generate output, respectively.
Configuration Parameters: Customize parameters like the package name and directory paths if needed. The library will handle default values if not specified.
Automated Environment Setup: The library will automatically establish and manage a Conda environment to handle Python dependencies, execute scripts, and package your project.
Here's a streamlined example demonstrating its usage:
import toPyip from '@fnet/to-pyip';
const config = {
params: {
name: "my_project",
version: "1.0.0",
package_name: "my_project",
bin_name: "my_project_cli"
},
src: "./project/source",
dest: "./project/destination"
};
toPyip(config).then(() => {
console.log('Project successfully converted and packaged.');
}).catch(err => {
console.error('Error during conversion:', err);
});
Examples
Below are concise examples that showcase the main functionality of the library.
Template Rendering and Packaging
import toPyip from '@fnet/to-pyip';
// Basic Configuration
const params = {
name: "example_project",
version: "0.2.0"
};
toPyip({
params,
src: "./example/src",
dest: "./example/dest"
}).then(() => {
console.log('Packaging completed successfully.');
}).catch(err => {
console.error('An error occurred:', err);
});
Automated Python Environment Setup
Using the library, a Python environment is automatically managed. The following operations are executed:
- Installation of necessary Python packages
- Listing current Python packages
- Executing package scripts and commands
// Executing Python commands and scripts within managed environment
toPyip({
params: {
package_name: "automated_pkg"
},
src: "./source_path",
dest: "./dest_path"
}).then(() => {
console.log('Environment setup and execution finished.');
}).catch(err => {
console.error('Execution error:', err);
});
Acknowledgement
The @fnet/to-pyip
library leverages the functionalities of the Flownet ecosystem, particularly the @flownet/lib-render-templates-dir
for template management and @fnet/auto-conda-env
for managing Conda environments, to deliver a seamless development experience.
Input Schema
$schema: https://json-schema.org/draft/2020-12/schema
type: object
properties:
params:
type: object
properties:
name:
type: string
description: Name of the package
default: pyip
version:
type: string
description: Version of the package
package_name:
type: string
description: Name of the package
bin_name:
type: string
description: Name of the binary
package_dir:
type: string
description: Directory for the package
dependencies:
type: array
description: List of dependencies
items:
type: object
default: []
out_dir:
type: string
description: Output directory
required: []
config:
type: object
description: Configuration object
src:
type: string
description: Source directory
dest:
type: string
description: Destination directory
required:
- params
- src
- dest