| Name | neverland-tools JSON |
| Version |
0.1.dev7
JSON |
| download |
| home_page | None |
| Summary | A tool to compile Python files to shared objects using Cython. |
| upload_time | 2024-09-06 03:42:36 |
| maintainer | None |
| docs_url | None |
| author | None |
| requires_python | >=3.10 |
| license | MIT |
| keywords |
|
| VCS |
 |
| bugtrack_url |
|
| requirements |
No requirements were recorded.
|
| Travis-CI |
No Travis.
|
| coveralls test coverage |
No coveralls.
|
# Neverland Tools
A collection of tools for development.
## Installation
```bash
pip install neverland-tools
```
## neverland-compile
### Overview
`neverland-compile` is a tool designed to compile Python files into C extensions using Cython. This can help improve the performance of your Python code. The script supports parallel compilation to speed up the process, and it allows you to ignore certain files or directories, copy specific Python files without compiling them, and specify the output directory and Python language version.
### Command-Line Arguments
1. **`-i, --ignore`**: List of files or directories to ignore during compilation.
- **Type**: List of strings
- **Default**: `[]` (empty list)
- **Example**: `-i file_to_ignore.py dir_to_ignore`
2. **`-d, --dir`**: The directory where the compiled files will be stored.
- **Type**: String
- **Default**: `dist`
- **Example**: `-d output_directory`
3. **`-v, --version`**: The Python language level to use for the compilation.
- **Type**: Integer
- **Default**: `3`
- **Example**: `-v 2` for Python 2.x compatibility
4. **`-c, --copy_py`**: List of Python files to copy without compiling.
- **Type**: List of strings
- **Default**: `[]` (empty list)
- **Example**: `-c script1.py script2.py`
5. **`-p, --parallel`**: Number of parallel workers to use for compilation.
- **Type**: Integer
- **Default**: Number of CPU cores available
- **Example**: `-p 4` to use 4 parallel workers
### Example Usage
#### Basic Compilation
To compile all Python files in the current directory and store the compiled files in the `dist` directory:
```bash
neverland-compile
```
#### Ignoring Specific Files
To ignore specific files or directories during compilation:
```bash
neverland-compile -i file_to_ignore.py dir_to_ignore
```
#### Specifying Output Directory
To specify a custom output directory for the compiled files:
```bash
neverland-compile -d output_directory
```
#### Specifying Python Version
To specify the Python language level for the compilation:
```bash
neverland-compile -v 2
```
#### Copying Specific Python Files Without Compiling
To copy specific Python files without compiling them:
```bash
neverland-compile -c script1.py script2.py
```
#### Using Parallel Compilation
To use a specific number of parallel workers:
```bash
neverland-compile -p 4
```
### Script Breakdown
1. **Argument Parsing**: The `parse_args` function uses `argparse` to handle command-line arguments.
2. **File Listing**: The `ls` function recursively lists all files in the directory.
3. **Migration File Check**: The `is_migration_file` function checks if a file is a Django migration file.
4. **Copying Ignored Files**: The `copy_ignore` function copies files that should be ignored during compilation.
5. **Compilation**: The `compile_module` function compiles a single module using Cython.
6. **Build Process**: The `build` function handles the overall build process, including parallel compilation and cleanup.
7. **Main Function**: The `main` function is the entry point of the script, which parses arguments and calls the build function.
### Conclusion
`neverland-compile` is a versatile tool for compiling Python files into C extensions. By using the provided command-line arguments, you can customize the compilation process to suit your needs, whether it's ignoring specific files, copying certain Python files, or leveraging parallel processing to speed up the compilation.
Raw data
{
"_id": null,
"home_page": null,
"name": "neverland-tools",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.10",
"maintainer_email": null,
"keywords": null,
"author": null,
"author_email": "umaru <15875339926@139.com>",
"download_url": "https://files.pythonhosted.org/packages/8b/18/730e533e58c4b35b29ec8a5c1c70d1b299a27e4f2026a30f365bd633616d/neverland_tools-0.1.dev7.tar.gz",
"platform": null,
"description": "# Neverland Tools\n\nA collection of tools for development.\n\n## Installation\n\n```bash\npip install neverland-tools\n```\n\n## neverland-compile \n\n\n### Overview\n\n`neverland-compile` is a tool designed to compile Python files into C extensions using Cython. This can help improve the performance of your Python code. The script supports parallel compilation to speed up the process, and it allows you to ignore certain files or directories, copy specific Python files without compiling them, and specify the output directory and Python language version.\n\n### Command-Line Arguments\n\n1. **`-i, --ignore`**: List of files or directories to ignore during compilation.\n - **Type**: List of strings\n - **Default**: `[]` (empty list)\n - **Example**: `-i file_to_ignore.py dir_to_ignore`\n\n2. **`-d, --dir`**: The directory where the compiled files will be stored.\n - **Type**: String\n - **Default**: `dist`\n - **Example**: `-d output_directory`\n\n3. **`-v, --version`**: The Python language level to use for the compilation.\n - **Type**: Integer\n - **Default**: `3`\n - **Example**: `-v 2` for Python 2.x compatibility\n\n4. **`-c, --copy_py`**: List of Python files to copy without compiling.\n - **Type**: List of strings\n - **Default**: `[]` (empty list)\n - **Example**: `-c script1.py script2.py`\n\n5. **`-p, --parallel`**: Number of parallel workers to use for compilation.\n - **Type**: Integer\n - **Default**: Number of CPU cores available\n - **Example**: `-p 4` to use 4 parallel workers\n\n### Example Usage\n\n#### Basic Compilation\n\nTo compile all Python files in the current directory and store the compiled files in the `dist` directory:\n\n```bash\nneverland-compile\n```\n\n#### Ignoring Specific Files\n\nTo ignore specific files or directories during compilation:\n\n```bash\nneverland-compile -i file_to_ignore.py dir_to_ignore\n```\n\n#### Specifying Output Directory\n\nTo specify a custom output directory for the compiled files:\n\n```bash\nneverland-compile -d output_directory\n```\n\n#### Specifying Python Version\n\nTo specify the Python language level for the compilation:\n\n```bash\nneverland-compile -v 2\n```\n\n#### Copying Specific Python Files Without Compiling\n\nTo copy specific Python files without compiling them:\n\n```bash\nneverland-compile -c script1.py script2.py\n```\n\n#### Using Parallel Compilation\n\nTo use a specific number of parallel workers:\n\n```bash\nneverland-compile -p 4\n```\n\n### Script Breakdown\n\n1. **Argument Parsing**: The `parse_args` function uses `argparse` to handle command-line arguments.\n2. **File Listing**: The `ls` function recursively lists all files in the directory.\n3. **Migration File Check**: The `is_migration_file` function checks if a file is a Django migration file.\n4. **Copying Ignored Files**: The `copy_ignore` function copies files that should be ignored during compilation.\n5. **Compilation**: The `compile_module` function compiles a single module using Cython.\n6. **Build Process**: The `build` function handles the overall build process, including parallel compilation and cleanup.\n7. **Main Function**: The `main` function is the entry point of the script, which parses arguments and calls the build function.\n\n### Conclusion\n\n`neverland-compile` is a versatile tool for compiling Python files into C extensions. By using the provided command-line arguments, you can customize the compilation process to suit your needs, whether it's ignoring specific files, copying certain Python files, or leveraging parallel processing to speed up the compilation.\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "A tool to compile Python files to shared objects using Cython.",
"version": "0.1.dev7",
"project_urls": {
"Homepage": "https://github.com/NeverlandLab/neverland-tools"
},
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "cc93003a68e1015dc5f017ba09903bd30851cabc2149b89a540daac127d1b29e",
"md5": "6e24296b87081716dec2618fabeecb33",
"sha256": "16bfae1c4d1ed6f579ce803aa902d23259c6dc5a34f8b4cccf2f59a496e9b038"
},
"downloads": -1,
"filename": "neverland_tools-0.1.dev7-py3-none-any.whl",
"has_sig": false,
"md5_digest": "6e24296b87081716dec2618fabeecb33",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.10",
"size": 12110,
"upload_time": "2024-09-06T03:42:35",
"upload_time_iso_8601": "2024-09-06T03:42:35.024926Z",
"url": "https://files.pythonhosted.org/packages/cc/93/003a68e1015dc5f017ba09903bd30851cabc2149b89a540daac127d1b29e/neverland_tools-0.1.dev7-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "8b18730e533e58c4b35b29ec8a5c1c70d1b299a27e4f2026a30f365bd633616d",
"md5": "7fd714c7cd3928447d52bf7ceda5186e",
"sha256": "39ee5bdca459e7b948a1d44bacb262d018050900479f285cdc839b003fdd246b"
},
"downloads": -1,
"filename": "neverland_tools-0.1.dev7.tar.gz",
"has_sig": false,
"md5_digest": "7fd714c7cd3928447d52bf7ceda5186e",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.10",
"size": 11084,
"upload_time": "2024-09-06T03:42:36",
"upload_time_iso_8601": "2024-09-06T03:42:36.571221Z",
"url": "https://files.pythonhosted.org/packages/8b/18/730e533e58c4b35b29ec8a5c1c70d1b299a27e4f2026a30f365bd633616d/neverland_tools-0.1.dev7.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-09-06 03:42:36",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "NeverlandLab",
"github_project": "neverland-tools",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"lcname": "neverland-tools"
}