/Mypackage

Primary LanguagePythonMIT LicenseMIT

Certainly! Let's go through another method using a more structured layout and incorporating best practices for creating Python packages. We'll use a project structure that includes separate directories for source code, tests, and documentation.

#Project Structure

mypackage/
|-- mypackage/
|   |-- __init__.py
|   |-- module1.py
|   |-- module2.py
|-- README.md
|-- setup.py
mkdir mypackage
cd mypackage
mkdir mypackage
touch mypackage/module1.py
touch mypackage/module2.py
def my_function():
    print("Hello from module1")
touch mypackage/__init__.py
touch setup.py
from setuptools import setup, find_packages

setup(
    name='mypackage',
    version='0.1',
    packages=find_packages(),
)
touch README.md
pip install setuptools wheel
python setup.py sdist bdist_wheel
pip install .
from mypackage import module1

module1.my_function()
python test_script.py
output:-
Hello from module1