diff --git a/dev_builder.sh b/dev_builder.sh new file mode 100755 index 0000000..0e71703 --- /dev/null +++ b/dev_builder.sh @@ -0,0 +1,42 @@ +#!/bin/bash + +# Step 1: Ensure conda is available +if ! command -v conda &> /dev/null +then + echo "Conda could not be found. Please install Miniconda or Anaconda." + exit 1 +fi + +# Step 2: Extract environment name correctly (remove extra quotes) +env_name=$(grep "^name:" environment.yml | awk '{print $2}' | tr -d '"') + +if [ -z "$env_name" ]; then + echo "Error: Could not determine the environment name from environment.yml." + exit 1 +fi + +echo "Checking if the environment '$env_name' exists..." +if conda info --envs | awk '{print $1}' | grep -qx "$env_name"; then + echo "Environment '$env_name' already exists. Skipping creation." +else + echo "Creating the Conda environment: $env_name" + conda env create -f environment.yml +fi + +# Step 3: Ensure Conda is properly initialized +eval "$(conda shell.bash hook)" + +# Step 4: Install dependencies using Poetry +echo "Installing dependencies with Poetry..." +if ! command -v poetry &> /dev/null +then + echo "Poetry is not installed. Installing Poetry..." + curl -sSL https://install.python-poetry.org | python3 - + export PATH="$HOME/.local/bin:$PATH" +fi + +poetry install + +# Step 5: Confirm successful setup +echo "Setup complete! To activate your environment, run:" +echo " conda activate $env_name" \ No newline at end of file diff --git a/environment.yml b/environment.yml new file mode 100644 index 0000000..2086f25 --- /dev/null +++ b/environment.yml @@ -0,0 +1,9 @@ +name: "datastructpy" + +channels: + - conda-forge + - defaults + +dependencies: + - python=3.11 + - poetry=2.0.1 \ No newline at end of file diff --git a/poetry.lock b/poetry.lock new file mode 100644 index 0000000..5b1f371 --- /dev/null +++ b/poetry.lock @@ -0,0 +1,80 @@ +# This file is automatically @generated by Poetry 2.0.1 and should not be changed by hand. + +[[package]] +name = "colorama" +version = "0.4.6" +description = "Cross-platform colored terminal text." +optional = false +python-versions = "!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*,!=3.5.*,!=3.6.*,>=2.7" +groups = ["dev"] +markers = "sys_platform == \"win32\"" +files = [ + {file = "colorama-0.4.6-py2.py3-none-any.whl", hash = "sha256:4f1d9991f5acc0ca119f9d443620b77f9d6b33703e51011c16baf57afb285fc6"}, + {file = "colorama-0.4.6.tar.gz", hash = "sha256:08695f5cb7ed6e0531a20572697297273c47b8cae5a63ffc6d6ed5c201be6e44"}, +] + +[[package]] +name = "iniconfig" +version = "2.0.0" +description = "brain-dead simple config-ini parsing" +optional = false +python-versions = ">=3.7" +groups = ["dev"] +files = [ + {file = "iniconfig-2.0.0-py3-none-any.whl", hash = "sha256:b6a85871a79d2e3b22d2d1b94ac2824226a63c6b741c88f7ae975f18b6778374"}, + {file = "iniconfig-2.0.0.tar.gz", hash = "sha256:2d91e135bf72d31a410b17c16da610a82cb55f6b0477d1a902134b24a455b8b3"}, +] + +[[package]] +name = "packaging" +version = "24.2" +description = "Core utilities for Python packages" +optional = false +python-versions = ">=3.8" +groups = ["dev"] +files = [ + {file = "packaging-24.2-py3-none-any.whl", hash = "sha256:09abb1bccd265c01f4a3aa3f7a7db064b36514d2cba19a2f694fe6150451a759"}, + {file = "packaging-24.2.tar.gz", hash = "sha256:c228a6dc5e932d346bc5739379109d49e8853dd8223571c7c5b55260edc0b97f"}, +] + +[[package]] +name = "pluggy" +version = "1.5.0" +description = "plugin and hook calling mechanisms for python" +optional = false +python-versions = ">=3.8" +groups = ["dev"] +files = [ + {file = "pluggy-1.5.0-py3-none-any.whl", hash = "sha256:44e1ad92c8ca002de6377e165f3e0f1be63266ab4d554740532335b9d75ea669"}, + {file = "pluggy-1.5.0.tar.gz", hash = "sha256:2cffa88e94fdc978c4c574f15f9e59b7f4201d439195c3715ca9e2486f1d0cf1"}, +] + +[package.extras] +dev = ["pre-commit", "tox"] +testing = ["pytest", "pytest-benchmark"] + +[[package]] +name = "pytest" +version = "8.3.4" +description = "pytest: simple powerful testing with Python" +optional = false +python-versions = ">=3.8" +groups = ["dev"] +files = [ + {file = "pytest-8.3.4-py3-none-any.whl", hash = "sha256:50e16d954148559c9a74109af1eaf0c945ba2d8f30f0a3d3335edde19788b6f6"}, + {file = "pytest-8.3.4.tar.gz", hash = "sha256:965370d062bce11e73868e0335abac31b4d3de0e82f4007408d242b4f8610761"}, +] + +[package.dependencies] +colorama = {version = "*", markers = "sys_platform == \"win32\""} +iniconfig = "*" +packaging = "*" +pluggy = ">=1.5,<2" + +[package.extras] +dev = ["argcomplete", "attrs (>=19.2)", "hypothesis (>=3.56)", "mock", "pygments (>=2.7.2)", "requests", "setuptools", "xmlschema"] + +[metadata] +lock-version = "2.1" +python-versions = "^3.11" +content-hash = "d9e4ac9b033cc3666a36a858a41995fad1d47cf30e7998b5bf04eb2b3a104c56" diff --git a/pyproject.toml b/pyproject.toml index aae8406..24ca038 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -9,6 +9,9 @@ readme = "README.md" [tool.poetry.dependencies] python = "^3.11" +[tool.poetry.group.dev.dependencies] +pytest = "^8.3.4" + [tool.semantic_release] version_toml = [ "pyproject.toml:tool.poetry.version", diff --git a/src/datastructpy/__init__.py b/src/datastructpy/__init__.py index 2063f6c..ffd52d1 100644 --- a/src/datastructpy/__init__.py +++ b/src/datastructpy/__init__.py @@ -1,10 +1,10 @@ -# read version from installed package +# Read version from installed package from importlib.metadata import version __version__ = version("datastructpy") -# Import key submodules or classes for easy access -from node import Node -from non_linear.trees.binary_search_tree import BinarySearchTree +# Use absolute imports +from datastructpy.node import Node +from datastructpy.non_linear.trees.binary_search_tree import BinarySearchTree # Define the public API of the package __all__ = [ diff --git a/tests/conftest.py b/tests/conftest.py new file mode 100644 index 0000000..64ef9e9 --- /dev/null +++ b/tests/conftest.py @@ -0,0 +1,9 @@ +import sys +import os + +# Get the absolute path to the src directory +src_path = os.path.abspath(os.path.join(os.path.dirname(__file__), "../src")) + +# Add it to sys.path if not already included +if src_path not in sys.path: + sys.path.insert(0, src_path) \ No newline at end of file diff --git a/tests/non-linear/trees/binary_search_tree/test_delete.py b/tests/non-linear/trees/binary_search_tree/test_delete.py index be88d3c..07144d5 100644 --- a/tests/non-linear/trees/binary_search_tree/test_delete.py +++ b/tests/non-linear/trees/binary_search_tree/test_delete.py @@ -1,2 +1,2 @@ -from datastructpy.non_linear.trees.binary_search_trees import BinarySearchTree +from datastructpy.non_linear.trees.binary_search_tree import BinarySearchTree diff --git a/tests/non-linear/trees/binary_search_tree/test_insert.py b/tests/non-linear/trees/binary_search_tree/test_insert.py index f86679f..1be09b5 100644 --- a/tests/non-linear/trees/binary_search_tree/test_insert.py +++ b/tests/non-linear/trees/binary_search_tree/test_insert.py @@ -1 +1 @@ -from datastructpy.non_linear.trees.binary_search_trees import BinarySearchTree +from datastructpy.non_linear.trees.binary_search_tree import BinarySearchTree diff --git a/tests/non-linear/trees/binary_search_tree/test_list_to_tree.py b/tests/non-linear/trees/binary_search_tree/test_list_to_tree.py index f86679f..1be09b5 100644 --- a/tests/non-linear/trees/binary_search_tree/test_list_to_tree.py +++ b/tests/non-linear/trees/binary_search_tree/test_list_to_tree.py @@ -1 +1 @@ -from datastructpy.non_linear.trees.binary_search_trees import BinarySearchTree +from datastructpy.non_linear.trees.binary_search_tree import BinarySearchTree diff --git a/tests/non-linear/trees/binary_search_tree/test_search.py b/tests/non-linear/trees/binary_search_tree/test_search.py index f86679f..1be09b5 100644 --- a/tests/non-linear/trees/binary_search_tree/test_search.py +++ b/tests/non-linear/trees/binary_search_tree/test_search.py @@ -1 +1 @@ -from datastructpy.non_linear.trees.binary_search_trees import BinarySearchTree +from datastructpy.non_linear.trees.binary_search_tree import BinarySearchTree diff --git a/tests/test_datastructpy.py b/tests/test_datastructpy.py deleted file mode 100644 index 23b7987..0000000 --- a/tests/test_datastructpy.py +++ /dev/null @@ -1,3 +0,0 @@ -from datastructpy import datastructpy - -# To do: Delete file later \ No newline at end of file