Great! You want to turn your oci_tools folder into a Python package that you can install via pip, and use it in another project located at main/react/scripts.
Here’s a step-by-step guide to help you create the package, install it, and use it in your project.
✅ Step 1: Structure Your Package
Assuming your current structure is:
/main
├── /oci_tools
│ ├── __init__.py
│ ├── setup.py ← We'll create this
│ ├── module1.py ← contains functions/classes
│ └── module2.py ← contains functions/classes
└── /react
└── /scripts
└── your_project_script.py
You need to properly fill in the setup.py file inside oci_tools.
✅ Step 2: Create setup.py
Create or edit the setup.py file inside /main/oci_tools/setup.py with the following content:
from setuptools import setup, find_packages
setup(
name="oci-tools", # This is the name you'll use with pip install
version="0.1.0",
description="Small utility package for OCI-related tools",
author="Your Name",
author_email="your.email@example.com",
packages=find_packages(), # finds oci_tools as a package
include_package_data=True,
classifiers=[
"Programming Language :: Python :: 3",
"License :: OSI Approved :: MIT License",
"Operating System :: OS Independent",
],
python_requires='>=3.6',
)
🔍 Note: The package name (oci-tools) is what you’ll use when installing via pip.
✅ Step 3: Install the Package in Development Mode
Navigate to the directory containing setup.py:
cd /main/oci_tools
Then run:
pip install -e .
This installs the package in editable mode, so any changes you make to module1.py or module2.py will be reflected immediately without reinstalling.
✅ Step 4: Use It in Your Project
Now in your script located at /main/react/scripts/your_project_script.py, you can import from your package like this:
from oci_tools.module1 import some_function_or_class
from oci_tools.module2 import another_function
Example usage:
# your_project_script.py
from oci_tools.module1 import get_oci_client
client = get_oci_client()
print(client.list_instances())
✅ Step 5: Optional – Build a Distributable Wheel (for Deployment)
If you want to build a distributable .whl file (for sharing or deploying):
cd /main/oci_tools
python setup.py sdist bdist_wheel
This creates a dist/oci-tools-0.1.0.tar.gz and a .whl file.
To install it elsewhere:
pip install dist/oci-tools-0.1.0-py3-none-any.whl
✅ Summary
| Task | Command |
|---|
| Create package structure | Add files + setup.py |
| Install locally in dev mode | pip install -e . |
| Import in scripts | from oci_tools.moduleX import Y |
| Build distributable wheel | python setup.py sdist bdist_wheel |
Let me know if you'd like to publish it to PyPI or manage dependencies.