From 380b3aacb254b86559d826475a903df9fa02299a Mon Sep 17 00:00:00 2001 From: Falko Habel Date: Thu, 30 Jan 2025 11:37:49 +0100 Subject: [PATCH 1/2] overhall, added proper source dir and and improved code to not need python anymore and renaming it --- example.py | 2 +- pyproject.toml | 10 ++++++++++ setup.py | 18 ++++++++++++------ src/prodir/__init__.py | 1 + {tree_structurer => src/prodir}/__main__.py | 2 +- .../prodir}/cpp/bindings.cpp | 0 .../prodir}/cpp/tree_structurer.cpp | 0 .../prodir}/cpp/tree_structurer.hpp | 0 tests/test_tree_structurer.py | 2 +- tree_structurer/__init__.py | 1 - 10 files changed, 26 insertions(+), 10 deletions(-) create mode 100644 pyproject.toml create mode 100644 src/prodir/__init__.py rename {tree_structurer => src/prodir}/__main__.py (94%) rename {tree_structurer => src/prodir}/cpp/bindings.cpp (100%) rename {tree_structurer => src/prodir}/cpp/tree_structurer.cpp (100%) rename {tree_structurer => src/prodir}/cpp/tree_structurer.hpp (100%) delete mode 100644 tree_structurer/__init__.py diff --git a/example.py b/example.py index 4dd9443..ddd8af9 100644 --- a/example.py +++ b/example.py @@ -1,4 +1,4 @@ -from tree_structurer import create_tree_structurer, get_structure +from prodir import create_tree_structurer, get_structure create_tree_structurer() for file in get_structure(): diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..6a57252 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,10 @@ +[build-system] +requires = ["setuptools>=64", "wheel"] +build-backend = "setuptools.build_meta" + +[project] +name = "prodir" +version = "0.0.6" +description = "A module for analyzing directory structures" +scripts = {prodir = "prodir.__main__:main"} +dependencies = [] diff --git a/setup.py b/setup.py index 44c083e..79f7bc5 100644 --- a/setup.py +++ b/setup.py @@ -1,4 +1,4 @@ -from setuptools import setup, Extension +from setuptools import setup, Extension, find_packages import platform extra_compile_args = [] @@ -11,17 +11,23 @@ else: extra_compile_args.append('-std=c++17') tree_structurer_module = Extension( - 'tree_structurer._tree_structurer', - sources=['tree_structurer/cpp/bindings.cpp', 'tree_structurer/cpp/tree_structurer.cpp'], - include_dirs=['tree_structurer/cpp'], + 'prodir._tree_structurer', # Remove 'src.' from the module name + sources=['src/prodir/cpp/bindings.cpp', 'src/prodir/cpp/tree_structurer.cpp'], + include_dirs=['src/prodir/tree_structurer/cpp'], extra_compile_args=extra_compile_args, extra_link_args=extra_link_args, ) setup( - name='tree_structurer', + name='prodir', version='0.0.6', description='A module for analyzing directory structures', ext_modules=[tree_structurer_module], - packages=['tree_structurer'], + packages=find_packages(where="src"), + package_dir={"": "src"}, + entry_points={ + "console_scripts": [ + "prodir=prodir.__main__:main", + ], + }, ) \ No newline at end of file diff --git a/src/prodir/__init__.py b/src/prodir/__init__.py new file mode 100644 index 0000000..520a304 --- /dev/null +++ b/src/prodir/__init__.py @@ -0,0 +1 @@ +from prodir._tree_structurer import create_tree_structurer, get_structure \ No newline at end of file diff --git a/tree_structurer/__main__.py b/src/prodir/__main__.py similarity index 94% rename from tree_structurer/__main__.py rename to src/prodir/__main__.py index 35fdff9..1967b82 100644 --- a/tree_structurer/__main__.py +++ b/src/prodir/__main__.py @@ -1,7 +1,7 @@ import os import sys import argparse -from tree_structurer import create_tree_structurer, get_structure +from prodir import create_tree_structurer, get_structure def main(): parser = argparse.ArgumentParser(description='Display directory structure in a tree-like format') diff --git a/tree_structurer/cpp/bindings.cpp b/src/prodir/cpp/bindings.cpp similarity index 100% rename from tree_structurer/cpp/bindings.cpp rename to src/prodir/cpp/bindings.cpp diff --git a/tree_structurer/cpp/tree_structurer.cpp b/src/prodir/cpp/tree_structurer.cpp similarity index 100% rename from tree_structurer/cpp/tree_structurer.cpp rename to src/prodir/cpp/tree_structurer.cpp diff --git a/tree_structurer/cpp/tree_structurer.hpp b/src/prodir/cpp/tree_structurer.hpp similarity index 100% rename from tree_structurer/cpp/tree_structurer.hpp rename to src/prodir/cpp/tree_structurer.hpp diff --git a/tests/test_tree_structurer.py b/tests/test_tree_structurer.py index aade0d0..4ff8207 100644 --- a/tests/test_tree_structurer.py +++ b/tests/test_tree_structurer.py @@ -1,6 +1,6 @@ import pytest from pathlib import Path -from tree_structurer import create_tree_structurer, get_structure +from prodir import create_tree_structurer, get_structure def test_basic_structure(temp_directory): """Test that the basic directory structure is correctly represented.""" diff --git a/tree_structurer/__init__.py b/tree_structurer/__init__.py deleted file mode 100644 index d99440a..0000000 --- a/tree_structurer/__init__.py +++ /dev/null @@ -1 +0,0 @@ -from tree_structurer._tree_structurer import create_tree_structurer, get_structure \ No newline at end of file From 763083a5cc04d66c956038a9b7e639238d5531b0 Mon Sep 17 00:00:00 2001 From: Falko Habel Date: Thu, 30 Jan 2025 11:39:04 +0100 Subject: [PATCH 2/2] updated readme to work with nre name --- README.md | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 2e6b0a5..d8f46c7 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# Tree-Structurer +# prodir This is a Python package designed to display directory structures in a tree-like format. This tool provides an easy-to-read overview of the directory hierarchy, making it easier for developers to navigate complex project structures. @@ -7,7 +7,7 @@ This is a Python package designed to display directory structures in a tree-like To install `tree_structurer`, you can use pip: ```bash - pip install git+https://gitea.fabelous.app/Fabel/Tree-Structurer.git + pip install git+https://gitea.fabelous.app/Fabel/prodir.git ``` @@ -18,13 +18,19 @@ You can run `tree_structurer` from the command line. By default, it will analyze To display the directory structure of the current directory: ```bash -python -m tree_structurer +python -m prodir +``` + +or + +```bash +prodir ``` To display the directory structure of a specific directory: ```bash -python -m tree_structurer /path/to/directory +python -m prodir /path/to/directory ``` #### Options @@ -34,12 +40,12 @@ python -m tree_structurer /path/to/directory Example: ```bash -python -m tree_structurer /path/to/directory -v +python -m prodir /path/to/directory -v ``` #### Important Files and Folders Ignored -By default, `tree_structurer` ignores files and folders that start with `_` or `.`. However, it does include the following exceptions: +By default, `prodir` ignores files and folders that start with `_` or `.`. However, it does include the following exceptions: - `__init__.py` and `__main__.py` files: These are considered important and will be included in the output. - Special folders like `build`, `.git`, `node_modules`, etc.: These are also ignored to keep the output focused on the essential parts of the directory structure.