<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Anmol.py</title>
    <description>The latest articles on DEV Community by Anmol.py (@techwithanmol).</description>
    <link>https://dev.to/techwithanmol</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F751383%2F90a5e1c9-431e-4267-b9e4-7212059d5996.jpeg</url>
      <title>DEV Community: Anmol.py</title>
      <link>https://dev.to/techwithanmol</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/techwithanmol"/>
    <language>en</language>
    <item>
      <title>How to create and publish 🐍python library from start to 🔚...</title>
      <dc:creator>Anmol.py</dc:creator>
      <pubDate>Sat, 13 Nov 2021 03:49:42 +0000</pubDate>
      <link>https://dev.to/techwithanmol/how-to-create-and-publish-python-library-from-start-to--4mjh</link>
      <guid>https://dev.to/techwithanmol/how-to-create-and-publish-python-library-from-start-to--4mjh</guid>
      <description>&lt;h3&gt;Have you ever thought 💭 how should I create and publish a 🐍 python library&lt;h3&gt;

&lt;/h3&gt;
&lt;/h3&gt;
&lt;p&gt;I will guide you through all the process. And yes, I am also going to discuss about other stuff that will be required if you are going to create some big library.&lt;/p&gt;


&lt;h5&gt;So, starting from scratch first, let's talk what is a python library ✔️&lt;br&gt;
Well, a python library contains some function  that help you to make your work easy. So, you don't have to write 📝 code from scratch 👌 we'll, I hope all of you understood what I want to say if not then let take a quick example so, imagine a scenario where you are making a python program to edit a image in this case you are probably you need python library because you don't wanna to write 📝 the thousand lines of codes&lt;br&gt;
Currently all python libraries are on &lt;a href="https://pypi.org" rel="noopener noreferrer"&gt;pypi&lt;/a&gt;&lt;h5&gt;

&lt;/h5&gt;
&lt;/h5&gt;
&lt;p&gt;Currently there are around 338,584 projects on pypi you can check out website to get exact numbers&lt;/p&gt;

&lt;p&gt;Now, lets look at how to create a library 🌀&lt;/p&gt;

&lt;p&gt;First we need to create a folder 📂 and remember this folder name should be libraryname-master &lt;/p&gt;

&lt;p&gt;Note 🗒 :- it's not necessary to name the folder same as library name but for convince still recommended 😀&lt;/p&gt;

&lt;p&gt;inside this folder 📂 create another folder with name same to your library name&lt;/p&gt;

&lt;p&gt;Inside this folder 📂 create some files here is list 📃 of them&lt;/p&gt;

&lt;p&gt;List of files:_&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;init&lt;/strong&gt;.py, function.py, setup.py, readme.md, License, as your need like .gitgnore and more &lt;/p&gt;

&lt;p&gt;Note 🗒 :- recommended ~ use this python library (my suggestion) named &lt;a href="https://pypi.org/project/auto-file/" rel="noopener noreferrer"&gt;autofile&lt;/a&gt;&lt;a&gt; because it generates all required file and folder 📂 needed to create a python library 🔗 link:- &lt;/a&gt;&lt;a href="https://pypi.org/project/auto-file/" rel="noopener noreferrer"&gt;https://pypi.org/project/auto-file/&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now, your folder 📂 and files structure look like this :-&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fzu0qdbvpht8u87m0g5zi.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fzu0qdbvpht8u87m0g5zi.jpg" alt=" " width="267" height="979"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now, after creating all necessary files and folders you need to open setup.py file and write 📝 the following code :-&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fl4qn3i0ba9v7pkht3cfi.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fl4qn3i0ba9v7pkht3cfi.jpg" alt=" " width="800" height="536"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Code explanation :-&lt;/p&gt;

&lt;p&gt;Actually this is very simple to understand because there nothing hard keyword all are simple and yes, if you dont understood what the code is comment down 👇 bellow &lt;br&gt;
Still some code are hard so, I am explaining &lt;br&gt;
One thing is &lt;br&gt;install_requires&lt;br&gt; it's basically means if your library requires any other libraries if yes then write their name with commans&lt;/p&gt;

&lt;p&gt;Now, in readme.md add the description and in function.py write 📝 all the function required for your library example:-&lt;/p&gt;

&lt;p&gt;Class test():&lt;br&gt;
    def test():&lt;br&gt;
        print("test") &lt;/p&gt;

&lt;p&gt;So, this method return test when called like this write all your code in function.py and you can also create new files if your code goes big &lt;/p&gt;

&lt;p&gt;Now, in &lt;strong&gt;init&lt;/strong&gt;.py write 📝 following code &lt;/p&gt;

&lt;p&gt;from .function import test&lt;br&gt;
Basically you have import all files in this folder remember write .filename &lt;/p&gt;

&lt;p&gt;Now all done &lt;br&gt;
Open terminal navigate to libraryname-main directory   and write "setup.py sdist bdist_wheel" &lt;br&gt;
After this, you will see new files and folders 📂 in your project&lt;br&gt;
Don't edit them just open terminal and navigate to &lt;/p&gt;

&lt;p&gt;Libraryname-main&amp;gt;dist&lt;/p&gt;

&lt;p&gt;Inside DIST you see a file with extension .whl &lt;/p&gt;

&lt;p&gt;Just type "pip install and that file name"&lt;/p&gt;

&lt;p&gt;Test you library &lt;/p&gt;

&lt;p&gt;And finally time to publish open terminal and type "twine upload dist"&lt;br&gt;
And finally this command ask you for username and password you can create a account on pypi to get them &lt;/p&gt;

&lt;p&gt;Everything done &lt;/p&gt;

&lt;p&gt;Refer to these for more clear and relevant information :-&lt;/p&gt;

&lt;p&gt;recommended &lt;/p&gt;

&lt;p&gt;1st ~ &lt;a href="https://packaging.python.org/tutorials/packaging-projects/" rel="noopener noreferrer"&gt;python officials docs for this &lt;/a&gt;&lt;a&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;2nd ~ &lt;a href="https://youtu.be/Ttc2bu651VU" rel="noopener noreferrer"&gt;youtube video &lt;/a&gt;&lt;a&gt;&lt;/a&gt;&lt;/p&gt;

</description>
      <category>python</category>
      <category>library</category>
      <category>pypi</category>
    </item>
  </channel>
</rss>
