{"id":15276,"date":"2024-10-16T13:45:51","date_gmt":"2024-10-16T13:45:51","guid":{"rendered":"https:\/\/shivlab.com\/blog\/\/"},"modified":"2024-10-17T12:38:25","modified_gmt":"2024-10-17T12:38:25","slug":"how-to-create-a-python-package","status":"publish","type":"post","link":"http:\/\/167.86.116.248\/shivlab\/blog\/how-to-create-a-python-package\/","title":{"rendered":"How to Create a Python Package: A Detailed Guide"},"content":{"rendered":"<p>Creating a Python package is an essential skill for developers who want to organize their code, share it with others, or reuse it in different projects. Python packages allow you to bundle your code in a structured way, making it easy to distribute and install. Whether you are building a utility, a library, or a full-fledged framework, packaging your Python code can help make it more accessible and maintainable.<\/p>\n<p>This guide will walk you through the process of creating a Python package from scratch, covering everything from the basic folder structure to publishing it on PyPI (Python Package Index).<\/p>\n<h2><strong><span style=\"color: #ff8625;\">1.<\/span> Understanding Python Packages<\/strong><\/h2>\n<hr \/>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-15283\" src=\"http:\/\/167.86.116.248\/shivlab\/wp-content\/uploads\/2024\/10\/Understanding-Python-Packages.jpg\" alt=\"Understanding Python Packages\" width=\"950\" height=\"564\" srcset=\"http:\/\/167.86.116.248\/shivlab\/wp-content\/uploads\/2024\/10\/Understanding-Python-Packages.jpg 950w, http:\/\/167.86.116.248\/shivlab\/wp-content\/uploads\/2024\/10\/Understanding-Python-Packages-300x178.jpg 300w, http:\/\/167.86.116.248\/shivlab\/wp-content\/uploads\/2024\/10\/Understanding-Python-Packages-768x456.jpg 768w\" sizes=\"auto, (max-width: 950px) 100vw, 950px\" \/><\/p>\n<p>Before diving into the creation process, let\u2019s clarify what a Python package is. In Python, a package is essentially a collection of modules, organized in a directory, with an __init__.py file in it. This file signals to Python that the directory should be treated as a package, and it may contain package initialization code.<\/p>\n<p>Modules, on the other hand, are simply Python files containing code (functions, classes, variables) that you can import and reuse in other scripts.<\/p>\n<h3><strong> Why Use Python Packages?<\/strong><\/h3>\n<ul class=\"orangeList\">\n<li><strong>Modularization:<\/strong> By breaking your code into smaller, reusable modules, you can reduce duplication and improve maintainability.<\/li>\n<li><strong>Code sharing:<\/strong> Packaging your code allows others to easily install and use it in their projects.<\/li>\n<li><strong>Versioning:<\/strong> You can release different versions of your package, allowing users to upgrade as needed.<\/li>\n<li><strong>Namespace organization:<\/strong> Packaging helps to avoid name conflicts by organizing your code within namespaces.<\/li>\n<\/ul>\n<h2><strong><span style=\"color: #ff8625;\">2.<\/span> Basic Folder Structure of a Python Package<\/strong><\/h2>\n<hr \/>\n<p>The first step in creating a Python package is organizing your files and directories. A typical Python package structure looks like this:<\/p>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">\r\n\/mypackage\/\r\n\/mypackage\/\r\n__init__.py\r\nmodule1.py\r\nmodule2.py\r\ntests\/\r\ntest_module1.py\r\ntest_module2.py\r\nsetup.py\r\nLICENSE\r\nREADME.md\r\nrequirements.txt\r\n\r\n<\/pre>\n<p>Let\u2019s break down the key components:<\/p>\n<h3><strong> Main Package Directory<\/strong><\/h3>\n<p>This directory contains the actual package code. Inside it, you\u2019ll find:<\/p>\n<ul class=\"orangeList\">\n<li><strong>__init__.py:<\/strong> Marks this directory as a package. It can be empty or contain initialization code.<\/li>\n<li><strong>module1.py, module2.py:<\/strong> These are Python files that contain the functionality of your package. You can have as many modules as you need.<\/li>\n<\/ul>\n<p><strong>Tests Directory<\/strong><br \/>\nIt\u2019s a good practice to include tests in your package to ensure that everything works as expected. Each module should have corresponding test files, for example, test_module1.py for module1.py. Tools like pytest or unittest can be used to run these tests.<\/p>\n<p><strong>setup.py<\/strong><br \/>\nThis file contains the metadata about your package and instructions on how to install it. It\u2019s the most critical file when it comes to building and distributing your package.<\/p>\n<p><strong>LICENSE<\/strong><br \/>\nIt\u2019s important to specify the terms under which your package can be used by others. Common licenses include MIT, GPL, and Apache 2.0. Choose the one that best fits your needs.<\/p>\n<p><strong>README.md<\/strong><br \/>\nThis file is used to provide information about your package. It typically includes a description of what the package does, how to install it, and examples of how to use it.<\/p>\n<p><strong>requirements.txt<\/strong><br \/>\nThis file lists the dependencies required by your package. When someone installs your package, these dependencies will also be installed.<\/p>\n<h2><strong><span style=\"color: #ff8625;\">3.<\/span> Writing Your Package Code<\/strong><\/h2>\n<hr \/>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-15284\" src=\"http:\/\/167.86.116.248\/shivlab\/wp-content\/uploads\/2024\/10\/Writing-Your-Package-Code.jpg\" alt=\"Writing Your Package Code\" width=\"950\" height=\"564\" srcset=\"http:\/\/167.86.116.248\/shivlab\/wp-content\/uploads\/2024\/10\/Writing-Your-Package-Code.jpg 950w, http:\/\/167.86.116.248\/shivlab\/wp-content\/uploads\/2024\/10\/Writing-Your-Package-Code-300x178.jpg 300w, http:\/\/167.86.116.248\/shivlab\/wp-content\/uploads\/2024\/10\/Writing-Your-Package-Code-768x456.jpg 768w\" sizes=\"auto, (max-width: 950px) 100vw, 950px\" \/><\/p>\n<p>Now that you have the folder structure in place, let\u2019s start writing the code for your package.<\/p>\n<h3><strong><span style=\"color: #ff8625;\">Step 1:<\/span> Create __init__.py<\/strong><\/h3>\n<p>The __init__.py file is a special file that Python uses to mark a directory as a package. It can be empty or contain initialization code. If you want certain modules or functions to be directly accessible when the package is imported, you can import them here.<\/p>\n<p><strong>Example:<\/strong><\/p>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">\r\n\r\n# mypackage\/__init__.py\r\n\r\nfrom .module1 import some_function\r\nfrom .module2 import AnotherClass\r\n\r\n\r\n<\/pre>\n<p>Now, when someone imports your package, they can access some_function and AnotherClass directly:<\/p>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">\r\nimport mypackage\r\n\r\nmypackage.some_function()\r\n<\/pre>\n<h3><strong><span style=\"color: #ff8625;\">Step 2:<\/span> Create Module Files<\/strong><\/h3>\n<p>Next, create the actual functionality of your package in separate module files.<\/p>\n<p>For example, let\u2019s say you are building a simple package that provides mathematical operations.<\/p>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">\r\n# mypackage\/module1.py\r\n\r\ndef add(a, b):\r\nreturn a + b\r\n\r\ndef subtract(a, b):\r\nreturn a - b\r\n<\/pre>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">\r\n# mypackage\/module2.py\r\n\r\nclass Calculator:\r\ndef multiply(self, a, b):\r\nreturn a * b\r\n\r\ndef divide(self, a, b):\r\nif b == 0:\r\nraise ValueError(&quot;Cannot divide by zero&quot;)\r\nreturn a \/ b\r\n<\/pre>\n<h2><strong><span style=\"color: #ff8625;\">4.<\/span> Creating the setup.py File<\/strong><\/h2>\n<hr \/>\n<p>The setup.py file is the heart of your package. It contains the metadata and instructions required for distributing and installing your package. Here\u2019s a basic example:<\/p>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">\r\n# setup.py\r\n\r\nfrom setuptools import setup, find_packages\r\n\r\nsetup(\r\nname=&quot;mypackage&quot;,\r\nversion=&quot;0.1&quot;,\r\nauthor=&quot;Your Name&quot;,\r\nauthor_email=&quot;youremail@example.com&quot;,\r\ndescription=&quot;A simple example Python package&quot;,\r\nlong_description=open(&#039;README.md&#039;).read(),\r\nlong_description_content_type=&quot;text\/markdown&quot;,\r\nurl=&quot;https:\/\/github.com\/yourusername\/mypackage&quot;,\r\npackages=find_packages(),\r\nclassifiers=&#x5B;\r\n&quot;Programming Language :: Python :: 3&quot;,\r\n&quot;License :: OSI Approved :: MIT License&quot;,\r\n&quot;Operating System :: OS Independent&quot;,\r\n],\r\npython_requires=&#039;&gt;=3.6&#039;,\r\ninstall_requires=&#x5B;\r\n# Add any dependencies here\r\n&quot;requests&quot;,\r\n],\r\n)\r\n<\/pre>\n<p>Let\u2019s break down the key elements:<\/p>\n<ul class=\"orangeList\">\n<li><strong>name:<\/strong> The name of your package.<\/li>\n<li><strong>version:<\/strong> The current version of your package.<\/li>\n<li><strong>author, author_email:<\/strong> Your name and contact email.<\/li>\n<li><strong>description:<\/strong> A short description of your package.<\/li>\n<li><strong>long_description:<\/strong> A detailed description, typically pulled from your README file.<\/li>\n<li><strong>url:<\/strong> The URL of your package\u2019s repository or homepage.<\/li>\n<li><strong>packages:<\/strong> A list of all Python import packages that should be included. The find_packages() function will automatically find them for you.<\/li>\n<li><strong>classifiers:<\/strong> These are used to categorize your package on PyPI.<\/li>\n<li><strong>python_requires:<\/strong> Specifies the minimum Python version your package supports.<\/li>\n<li><strong>install_requires:<\/strong> A list of external dependencies required by your package.<\/li>\n<\/ul>\n<h2><strong><span style=\"color: #ff8625;\">5.<\/span> Testing Your Package Locally<\/strong><\/h2>\n<hr \/>\n<p>Before distributing your package, it\u2019s important to test it locally. You can do this by installing it in &#8220;editable&#8221; mode.<\/p>\n<p>Navigate to the root directory of your package (the one containing setup.py).<br \/>\nRun the following command:<\/p>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">pip install -e .\r\n<\/pre>\n<p>The -e flag stands for &#8220;editable,&#8221; meaning any changes you make to the package will be reflected immediately.<\/p>\n<p>You can now import your package in Python and test it:<\/p>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">\r\nimport mypackage\r\n\r\nmypackage.some_function()\r\n<\/pre>\n<h2><strong><span style=\"color: #ff8625;\">6.<\/span> Adding Unit Tests<\/strong><\/h2>\n<hr \/>\n<p>Good packages come with tests. These ensure that your code behaves as expected and helps other developers understand how to use it.<\/p>\n<p>You can use unittest, pytest, or another testing framework of your choice. Here\u2019s a simple example using unittest:<\/p>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">\r\n# tests\/test_module1.py\r\n\r\nimport unittest\r\nfrom mypackage.module1 import add, subtract\r\n\r\nclass TestMathOperations(unittest.TestCase):\r\ndef test_add(self):\r\nself.assertEqual(add(1, 2), 3)\r\n\r\ndef test_subtract(self):\r\nself.assertEqual(subtract(5, 3), 2)\r\n\r\nif __name__ == &quot;__main__&quot;:\r\nunittest.main()\r\n<\/pre>\n<p>You can run the tests by simply executing:<\/p>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">python -m unittest discover\r\n<\/pre>\n<h2><strong><span style=\"color: #ff8625;\">7.<\/span> Building and Publishing Your Package<\/strong><\/h2>\n<hr \/>\n<p>Once you\u2019re satisfied with your package, it\u2019s time to distribute it. Python packages are commonly published on PyPI, the Python Package Index. Here\u2019s how you can do it:<\/p>\n<h3><strong><span style=\"color: #ff8625;\">Step 1:<\/span> Install Necessary Tools<\/strong><\/h3>\n<p>You\u2019ll need setuptools and twine to build and upload your package:<\/p>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">pip install setuptools twine\r\n<\/pre>\n<h3><strong><span style=\"color: #ff8625;\">Step 2:<\/span> Build the Package<\/strong><\/h3>\n<p>Run the following command to build your package:<\/p>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">python setup.py sdist bdist_wheel\r\n<\/pre>\n<p>This will generate distribution archives in the dist\/ directory.<\/p>\n<h3><strong><span style=\"color: #ff8625;\">Step 3:<\/span> Upload to PyPI<\/strong><\/h3>\n<p>First, create an account on PyPI. Then, upload your package using twine:<\/p>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">twine upload dist\/*\r\n<\/pre>\n<p>You\u2019ll be prompted to enter your PyPI credentials. After the upload is successful, your package will be available on PyPI for others to install using:<\/p>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">pip install mypackage\r\n<\/pre>\n<h2><strong><span style=\"color: #ff8625;\">8.<\/span> Versioning and Updating Your Package<\/strong><\/h2>\n<hr \/>\n<p>Versioning is an important aspect of package development. Follow semantic versioning guidelines to manage your package versions:<\/p>\n<p>MAJOR.MINOR.PATCH<\/p>\n<ul class=\"orangeList\">\n<li><strong>Major:<\/strong> Significant changes, often breaking backward compatibility.<\/li>\n<li><strong>Minor:<\/strong> New features, but backward-compatible.<\/li>\n<li><strong>Patch:<\/strong> Bug fixes and small improvements.<\/li>\n<\/ul>\n<p>To update your package, simply change the version number in setup.py, rebuild the package, and upload it to PyPI again.<\/p>\n<h4><strong>Conclusion<\/strong><\/h4>\n<hr \/>\n<p>Creating a Python package may seem daunting at first, but once you understand the process, it becomes straightforward. Packaging your code is not only a way to share your work with others but also a way to organize and manage your code more efficiently. By following the steps outlined in this guide, you&#8217;ll be able to package, distribute, and maintain your Python projects with ease.<\/p>\n<p>If you&#8217;re looking to take your Python development to the next level, <a href=\"http:\/\/167.86.116.248\/shivlab\/\">Shiv Technolabs<\/a> is here to help. Whether you need to hire Python developers or <a href=\"http:\/\/167.86.116.248\/shivlab\/hire-dedicated-python-developers\/\">hire Python experts<\/a>, our team can provide the expertise to bring your project to life efficiently and effectively. Let us assist you in building high-quality Python solutions tailored to your specific needs!<\/p>\n","protected":false},"excerpt":{"rendered":"<p> Discover a step-by-step guide to creating a Python package, covering everything from structuring your code to publishing on PyPI. Perfect for developers aiming to organize and distribute their projects.<\/p>\n","protected":false},"author":4,"featured_media":15282,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[11],"tags":[],"class_list":["post-15276","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-software-development"],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v24.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>How to Create a Python Package: A Detailed Guide<\/title>\n<meta name=\"description\" content=\"Learn how to create a Python package from scratch, including folder structure, setup.py, testing, and publishing to PyPI. A complete guide for developers.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"http:\/\/167.86.116.248\/shivlab\/blog\/how-to-create-a-python-package\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How to Create a Python Package: A Detailed Guide\" \/>\n<meta property=\"og:description\" content=\"Learn how to create a Python package from scratch, including folder structure, setup.py, testing, and publishing to PyPI. A complete guide for developers.\" \/>\n<meta property=\"og:url\" content=\"http:\/\/167.86.116.248\/shivlab\/blog\/how-to-create-a-python-package\/\" \/>\n<meta property=\"og:site_name\" content=\"Shiv Technolabs Pvt. Ltd.\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/ShivTechnolabs\/\" \/>\n<meta property=\"article:author\" content=\"https:\/\/www.facebook.com\/dipen.majithiya\" \/>\n<meta property=\"article:published_time\" content=\"2024-10-16T13:45:51+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2024-10-17T12:38:25+00:00\" \/>\n<meta property=\"og:image\" content=\"http:\/\/167.86.116.248\/shivlab\/wp-content\/uploads\/2024\/10\/How-to-Create-a-Python-Package-A-Detailed-Guide.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"1140\" \/>\n\t<meta property=\"og:image:height\" content=\"762\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Dipen Majithiya\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@dip_majithiya\" \/>\n<meta name=\"twitter:site\" content=\"@Shiv_Technolabs\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Dipen Majithiya\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"6 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"http:\/\/167.86.116.248\/shivlab\/blog\/how-to-create-a-python-package\/#article\",\"isPartOf\":{\"@id\":\"http:\/\/167.86.116.248\/shivlab\/blog\/how-to-create-a-python-package\/\"},\"author\":{\"name\":\"Dipen Majithiya\",\"@id\":\"http:\/\/167.86.116.248\/shivlab\/#\/schema\/person\/656b1fcc45a591961e3f3b061cd03206\"},\"headline\":\"How to Create a Python Package: A Detailed Guide\",\"datePublished\":\"2024-10-16T13:45:51+00:00\",\"dateModified\":\"2024-10-17T12:38:25+00:00\",\"mainEntityOfPage\":{\"@id\":\"http:\/\/167.86.116.248\/shivlab\/blog\/how-to-create-a-python-package\/\"},\"wordCount\":1500,\"publisher\":{\"@id\":\"http:\/\/167.86.116.248\/shivlab\/#organization\"},\"image\":{\"@id\":\"http:\/\/167.86.116.248\/shivlab\/blog\/how-to-create-a-python-package\/#primaryimage\"},\"thumbnailUrl\":\"http:\/\/167.86.116.248\/shivlab\/wp-content\/uploads\/2024\/10\/How-to-Create-a-Python-Package-A-Detailed-Guide.jpg\",\"articleSection\":[\"Software Development\"],\"inLanguage\":\"en-US\"},{\"@type\":\"WebPage\",\"@id\":\"http:\/\/167.86.116.248\/shivlab\/blog\/how-to-create-a-python-package\/\",\"url\":\"http:\/\/167.86.116.248\/shivlab\/blog\/how-to-create-a-python-package\/\",\"name\":\"How to Create a Python Package: A Detailed Guide\",\"isPartOf\":{\"@id\":\"http:\/\/167.86.116.248\/shivlab\/#website\"},\"primaryImageOfPage\":{\"@id\":\"http:\/\/167.86.116.248\/shivlab\/blog\/how-to-create-a-python-package\/#primaryimage\"},\"image\":{\"@id\":\"http:\/\/167.86.116.248\/shivlab\/blog\/how-to-create-a-python-package\/#primaryimage\"},\"thumbnailUrl\":\"http:\/\/167.86.116.248\/shivlab\/wp-content\/uploads\/2024\/10\/How-to-Create-a-Python-Package-A-Detailed-Guide.jpg\",\"datePublished\":\"2024-10-16T13:45:51+00:00\",\"dateModified\":\"2024-10-17T12:38:25+00:00\",\"description\":\"Learn how to create a Python package from scratch, including folder structure, setup.py, testing, and publishing to PyPI. A complete guide for developers.\",\"breadcrumb\":{\"@id\":\"http:\/\/167.86.116.248\/shivlab\/blog\/how-to-create-a-python-package\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"http:\/\/167.86.116.248\/shivlab\/blog\/how-to-create-a-python-package\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"http:\/\/167.86.116.248\/shivlab\/blog\/how-to-create-a-python-package\/#primaryimage\",\"url\":\"http:\/\/167.86.116.248\/shivlab\/wp-content\/uploads\/2024\/10\/How-to-Create-a-Python-Package-A-Detailed-Guide.jpg\",\"contentUrl\":\"http:\/\/167.86.116.248\/shivlab\/wp-content\/uploads\/2024\/10\/How-to-Create-a-Python-Package-A-Detailed-Guide.jpg\",\"width\":1140,\"height\":762,\"caption\":\"How to Create a Python Package A Detailed Guide\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"http:\/\/167.86.116.248\/shivlab\/blog\/how-to-create-a-python-package\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"http:\/\/167.86.116.248\/shivlab\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"How to Create a Python Package: A Detailed Guide\"}]},{\"@type\":\"WebSite\",\"@id\":\"http:\/\/167.86.116.248\/shivlab\/#website\",\"url\":\"http:\/\/167.86.116.248\/shivlab\/\",\"name\":\"Shiv Technolabs Pvt. Ltd.\",\"description\":\"\",\"publisher\":{\"@id\":\"http:\/\/167.86.116.248\/shivlab\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"http:\/\/167.86.116.248\/shivlab\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"http:\/\/167.86.116.248\/shivlab\/#organization\",\"name\":\"Shiv Technolabs Pvt. Ltd\",\"url\":\"http:\/\/167.86.116.248\/shivlab\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"http:\/\/167.86.116.248\/shivlab\/#\/schema\/logo\/image\/\",\"url\":\"http:\/\/167.86.116.248\/shivlab\/wp-content\/uploads\/2022\/11\/stl-logo1.png\",\"contentUrl\":\"http:\/\/167.86.116.248\/shivlab\/wp-content\/uploads\/2022\/11\/stl-logo1.png\",\"width\":1280,\"height\":371,\"caption\":\"Shiv Technolabs Pvt. Ltd\"},\"image\":{\"@id\":\"http:\/\/167.86.116.248\/shivlab\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/ShivTechnolabs\/\",\"https:\/\/x.com\/Shiv_Technolabs\",\"https:\/\/www.linkedin.com\/company\/shivtechnolabs\/\",\"https:\/\/www.instagram.com\/shivtechnolabs\/\",\"https:\/\/in.pinterest.com\/ShivTechnolabs\/\"]},{\"@type\":\"Person\",\"@id\":\"http:\/\/167.86.116.248\/shivlab\/#\/schema\/person\/656b1fcc45a591961e3f3b061cd03206\",\"name\":\"Dipen Majithiya\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"http:\/\/167.86.116.248\/shivlab\/#\/schema\/person\/image\/\",\"url\":\"http:\/\/167.86.116.248\/shivlab\/wp-content\/uploads\/2022\/09\/02_emp_pic-dipen-150x150.png\",\"contentUrl\":\"http:\/\/167.86.116.248\/shivlab\/wp-content\/uploads\/2022\/09\/02_emp_pic-dipen-150x150.png\",\"caption\":\"Dipen Majithiya\"},\"description\":\"I am a proactive chief technology officer (CTO) of Shiv Technolabs. I have 10+ years of experience in eCommerce, mobile apps, and web development in the tech industry. I am Known for my strategic insight and have mastered core technical domains. I have empowered numerous business owners with bespoke solutions, fearlessly taking calculated risks and harnessing the latest technological advancements.\",\"sameAs\":[\"http:\/\/167.86.116.248\/shivlab\/\",\"https:\/\/www.facebook.com\/dipen.majithiya\",\"https:\/\/www.linkedin.com\/in\/dipenmajithiya\/\",\"https:\/\/x.com\/dip_majithiya\"],\"url\":\"http:\/\/167.86.116.248\/shivlab\/author\/dipen_majithiya\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"How to Create a Python Package: A Detailed Guide","description":"Learn how to create a Python package from scratch, including folder structure, setup.py, testing, and publishing to PyPI. A complete guide for developers.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"http:\/\/167.86.116.248\/shivlab\/blog\/how-to-create-a-python-package\/","og_locale":"en_US","og_type":"article","og_title":"How to Create a Python Package: A Detailed Guide","og_description":"Learn how to create a Python package from scratch, including folder structure, setup.py, testing, and publishing to PyPI. A complete guide for developers.","og_url":"http:\/\/167.86.116.248\/shivlab\/blog\/how-to-create-a-python-package\/","og_site_name":"Shiv Technolabs Pvt. Ltd.","article_publisher":"https:\/\/www.facebook.com\/ShivTechnolabs\/","article_author":"https:\/\/www.facebook.com\/dipen.majithiya","article_published_time":"2024-10-16T13:45:51+00:00","article_modified_time":"2024-10-17T12:38:25+00:00","og_image":[{"width":1140,"height":762,"url":"http:\/\/167.86.116.248\/shivlab\/wp-content\/uploads\/2024\/10\/How-to-Create-a-Python-Package-A-Detailed-Guide.jpg","type":"image\/jpeg"}],"author":"Dipen Majithiya","twitter_card":"summary_large_image","twitter_creator":"@dip_majithiya","twitter_site":"@Shiv_Technolabs","twitter_misc":{"Written by":"Dipen Majithiya","Est. reading time":"6 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"http:\/\/167.86.116.248\/shivlab\/blog\/how-to-create-a-python-package\/#article","isPartOf":{"@id":"http:\/\/167.86.116.248\/shivlab\/blog\/how-to-create-a-python-package\/"},"author":{"name":"Dipen Majithiya","@id":"http:\/\/167.86.116.248\/shivlab\/#\/schema\/person\/656b1fcc45a591961e3f3b061cd03206"},"headline":"How to Create a Python Package: A Detailed Guide","datePublished":"2024-10-16T13:45:51+00:00","dateModified":"2024-10-17T12:38:25+00:00","mainEntityOfPage":{"@id":"http:\/\/167.86.116.248\/shivlab\/blog\/how-to-create-a-python-package\/"},"wordCount":1500,"publisher":{"@id":"http:\/\/167.86.116.248\/shivlab\/#organization"},"image":{"@id":"http:\/\/167.86.116.248\/shivlab\/blog\/how-to-create-a-python-package\/#primaryimage"},"thumbnailUrl":"http:\/\/167.86.116.248\/shivlab\/wp-content\/uploads\/2024\/10\/How-to-Create-a-Python-Package-A-Detailed-Guide.jpg","articleSection":["Software Development"],"inLanguage":"en-US"},{"@type":"WebPage","@id":"http:\/\/167.86.116.248\/shivlab\/blog\/how-to-create-a-python-package\/","url":"http:\/\/167.86.116.248\/shivlab\/blog\/how-to-create-a-python-package\/","name":"How to Create a Python Package: A Detailed Guide","isPartOf":{"@id":"http:\/\/167.86.116.248\/shivlab\/#website"},"primaryImageOfPage":{"@id":"http:\/\/167.86.116.248\/shivlab\/blog\/how-to-create-a-python-package\/#primaryimage"},"image":{"@id":"http:\/\/167.86.116.248\/shivlab\/blog\/how-to-create-a-python-package\/#primaryimage"},"thumbnailUrl":"http:\/\/167.86.116.248\/shivlab\/wp-content\/uploads\/2024\/10\/How-to-Create-a-Python-Package-A-Detailed-Guide.jpg","datePublished":"2024-10-16T13:45:51+00:00","dateModified":"2024-10-17T12:38:25+00:00","description":"Learn how to create a Python package from scratch, including folder structure, setup.py, testing, and publishing to PyPI. A complete guide for developers.","breadcrumb":{"@id":"http:\/\/167.86.116.248\/shivlab\/blog\/how-to-create-a-python-package\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["http:\/\/167.86.116.248\/shivlab\/blog\/how-to-create-a-python-package\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"http:\/\/167.86.116.248\/shivlab\/blog\/how-to-create-a-python-package\/#primaryimage","url":"http:\/\/167.86.116.248\/shivlab\/wp-content\/uploads\/2024\/10\/How-to-Create-a-Python-Package-A-Detailed-Guide.jpg","contentUrl":"http:\/\/167.86.116.248\/shivlab\/wp-content\/uploads\/2024\/10\/How-to-Create-a-Python-Package-A-Detailed-Guide.jpg","width":1140,"height":762,"caption":"How to Create a Python Package A Detailed Guide"},{"@type":"BreadcrumbList","@id":"http:\/\/167.86.116.248\/shivlab\/blog\/how-to-create-a-python-package\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"http:\/\/167.86.116.248\/shivlab\/"},{"@type":"ListItem","position":2,"name":"How to Create a Python Package: A Detailed Guide"}]},{"@type":"WebSite","@id":"http:\/\/167.86.116.248\/shivlab\/#website","url":"http:\/\/167.86.116.248\/shivlab\/","name":"Shiv Technolabs Pvt. Ltd.","description":"","publisher":{"@id":"http:\/\/167.86.116.248\/shivlab\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"http:\/\/167.86.116.248\/shivlab\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"http:\/\/167.86.116.248\/shivlab\/#organization","name":"Shiv Technolabs Pvt. Ltd","url":"http:\/\/167.86.116.248\/shivlab\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"http:\/\/167.86.116.248\/shivlab\/#\/schema\/logo\/image\/","url":"http:\/\/167.86.116.248\/shivlab\/wp-content\/uploads\/2022\/11\/stl-logo1.png","contentUrl":"http:\/\/167.86.116.248\/shivlab\/wp-content\/uploads\/2022\/11\/stl-logo1.png","width":1280,"height":371,"caption":"Shiv Technolabs Pvt. Ltd"},"image":{"@id":"http:\/\/167.86.116.248\/shivlab\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/ShivTechnolabs\/","https:\/\/x.com\/Shiv_Technolabs","https:\/\/www.linkedin.com\/company\/shivtechnolabs\/","https:\/\/www.instagram.com\/shivtechnolabs\/","https:\/\/in.pinterest.com\/ShivTechnolabs\/"]},{"@type":"Person","@id":"http:\/\/167.86.116.248\/shivlab\/#\/schema\/person\/656b1fcc45a591961e3f3b061cd03206","name":"Dipen Majithiya","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"http:\/\/167.86.116.248\/shivlab\/#\/schema\/person\/image\/","url":"http:\/\/167.86.116.248\/shivlab\/wp-content\/uploads\/2022\/09\/02_emp_pic-dipen-150x150.png","contentUrl":"http:\/\/167.86.116.248\/shivlab\/wp-content\/uploads\/2022\/09\/02_emp_pic-dipen-150x150.png","caption":"Dipen Majithiya"},"description":"I am a proactive chief technology officer (CTO) of Shiv Technolabs. I have 10+ years of experience in eCommerce, mobile apps, and web development in the tech industry. I am Known for my strategic insight and have mastered core technical domains. I have empowered numerous business owners with bespoke solutions, fearlessly taking calculated risks and harnessing the latest technological advancements.","sameAs":["http:\/\/167.86.116.248\/shivlab\/","https:\/\/www.facebook.com\/dipen.majithiya","https:\/\/www.linkedin.com\/in\/dipenmajithiya\/","https:\/\/x.com\/dip_majithiya"],"url":"http:\/\/167.86.116.248\/shivlab\/author\/dipen_majithiya\/"}]}},"jetpack_featured_media_url":"http:\/\/167.86.116.248\/shivlab\/wp-content\/uploads\/2024\/10\/How-to-Create-a-Python-Package-A-Detailed-Guide.jpg","_links":{"self":[{"href":"http:\/\/167.86.116.248\/shivlab\/wp-json\/wp\/v2\/posts\/15276","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/167.86.116.248\/shivlab\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/167.86.116.248\/shivlab\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/167.86.116.248\/shivlab\/wp-json\/wp\/v2\/users\/4"}],"replies":[{"embeddable":true,"href":"http:\/\/167.86.116.248\/shivlab\/wp-json\/wp\/v2\/comments?post=15276"}],"version-history":[{"count":11,"href":"http:\/\/167.86.116.248\/shivlab\/wp-json\/wp\/v2\/posts\/15276\/revisions"}],"predecessor-version":[{"id":15302,"href":"http:\/\/167.86.116.248\/shivlab\/wp-json\/wp\/v2\/posts\/15276\/revisions\/15302"}],"wp:featuredmedia":[{"embeddable":true,"href":"http:\/\/167.86.116.248\/shivlab\/wp-json\/wp\/v2\/media\/15282"}],"wp:attachment":[{"href":"http:\/\/167.86.116.248\/shivlab\/wp-json\/wp\/v2\/media?parent=15276"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/167.86.116.248\/shivlab\/wp-json\/wp\/v2\/categories?post=15276"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/167.86.116.248\/shivlab\/wp-json\/wp\/v2\/tags?post=15276"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}