<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Oktapian Candra on Medium]]></title>
        <description><![CDATA[Stories by Oktapian Candra on Medium]]></description>
        <link>https://medium.com/@oktapiancaw?source=rss-52d83f9d3f87------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*cBhjcgA2yDsU6b8q1mvKaA.jpeg</url>
            <title>Stories by Oktapian Candra on Medium</title>
            <link>https://medium.com/@oktapiancaw?source=rss-52d83f9d3f87------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 22 Nov 2026 18:59:31 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@oktapiancaw/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Create Private Package Using Poetry, and Deploy on pypiserver]]></title>
            <link>https://medium.com/@oktapiancaw/create-private-package-using-poetry-and-deploy-on-pypiserver-e943f6199110?source=rss-52d83f9d3f87------2</link>
            <guid isPermaLink="false">https://medium.com/p/e943f6199110</guid>
            <category><![CDATA[package-management]]></category>
            <category><![CDATA[development]]></category>
            <category><![CDATA[poetry]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[private]]></category>
            <dc:creator><![CDATA[Oktapian Candra]]></dc:creator>
            <pubDate>Mon, 17 Feb 2025 09:31:01 GMT</pubDate>
            <atom:updated>2025-02-17T09:31:01.092Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*aGa9Rbz0JNL39-iRS29OGg.jpeg" /><figcaption>Photo by <a href="https://unsplash.com/@dtopkin1?utm_content=creditCopyText&amp;utm_medium=referral&amp;utm_source=unsplash">Dayne Topkin</a> on <a href="https://unsplash.com/photos/private-signage-door-u5Zt-HoocrM?utm_content=creditCopyText&amp;utm_medium=referral&amp;utm_source=unsplash">Unsplash</a></figcaption></figure><p>Ah, Python developers — masters of their craft, wielders of virtual environments, and occasional snackers of leftover pizza at 3 a.m. If you’ve ever wanted to create your own private Python package (because who doesn’t want to feel like a package-deploying secret agent?), this article will guide you through the process using <a href="https://python-poetry.org/"><strong>Poetry</strong></a> and <a href="https://github.com/pypiserver/pypiserver"><strong>pypiserver</strong></a>. By the end, you’ll not only have a private package but also a sense of accomplishment rivaled only by successfully debugging a KeyError at first glance.</p><h3>What is Poetry? (Not the Rhyming Kind)</h3><p>Before you start imagining yourself as a wordsmith crafting verses under the moonlight, let me clarify: <strong>Poetry</strong> in this context is a tool for managing Python projects. It simplifies dependency management, package versioning, and publishing. Think of it as your Python project’s personal assistant — organizing everything neatly so you can focus on writing code (and googling stack traces).</p><p>Key Features of Poetry:</p><ul><li><strong>Dependency Management</strong>: Specify, resolve, and manage your project dependencies in one place.</li><li><strong>Virtual Environment Integration</strong>: Automatically creates virtual environments for your project.</li><li><strong>Packaging Made Easy</strong>: Build and publish Python packages with minimal effort — no need to wrestle with setup.py.</li></ul><p>In short, Poetry is like that one coworker who always keeps their desk tidy and remembers everyone’s birthday.</p><h3>What is pypiserver? (Hint: It’s Not a Fancy Dessert)</h3><p>Now, let’s talk about <strong>pypiserver</strong>: a simple, lightweight PyPI (Python Package Index) server you can host yourself. Why would you want this? Well, maybe you’re building proprietary software, or maybe you just want to feel like a Python supervillain hoarding private packages. Either way, pypiserver lets you securely host and serve your own packages without relying on public repositories like PyPI.</p><p>Key Features of pypiserver:</p><ul><li><strong>Private Package Hosting</strong>: Store your own packages locally or on a private server.</li><li><strong>Lightweight</strong>: Minimal setup and resource usage, perfect for small-scale hosting.</li><li><strong>Compatibility</strong>: Works seamlessly with pip and other Python tools.</li></ul><p>Essentially, it’s like running your own private PyPI, but without needing a degree in server management.</p><h3>Why Would You Want a Private Package Anyway?</h3><p>Good question! Here are some common reasons:</p><ul><li>You have proprietary code you don’t want to share with the world.</li><li>You’re building reusable modules for internal use within your organization.</li><li>You just want to flex on your teammates by saying, “Oh, I have my own PyPI server.”</li></ul><p>Now that we’ve got the basics down, let’s jump into the fun part: creating a private package and deploying it on pypiserver.</p><h4><strong>Step 1: Install Poetry</strong></h4><p>First, install Poetry. If you don’t already have it, run the following command:</p><pre>curl -sSL https://install.python-poetry.org | python3 -</pre><p>After installation, make sure Poetry is accessible by checking its version:</p><pre>poetry --version</pre><p>If you see something like Poetry version 1.6.0, congratulations — you’re ready to roll. If not, double-check your installation steps, and try not to curse too loudly.</p><h4>Step 2: Create Your Python Package</h4><p>Let’s create that private package. For this example, we’re going to make a package called my_private_package because creativity is overrated. Run the following:</p><pre>poetry new my_private_package</pre><p>This command creates a new directory with the following structure:</p><pre>my_private_package/  <br>├── my_private_package/  <br>│   └── __init__.py  <br>├── tests/  <br>│   └── __init__.py  <br>├── pyproject.toml  </pre><ul><li>The pyproject.toml file is Poetry’s version of a project blueprint. It defines everything about your project, from its dependencies to its version number.</li><li>The tests/ directory is where you can write tests… you know, once you stop procrastinating.</li></ul><h4>Step 3: Write Some Code</h4><p>Now, let’s add some code to your package. Open my_private_package/__init__.py and add the following:</p><pre>def greet(name: str) -&gt; str:  <br>    return f&quot;Hello, {name}! Welcome to your private package.&quot;</pre><p>It’s simple, but hey, it gets the job done.</p><h4>Step 4: Build the Package</h4><p>To build your package, navigate to the root directory of your project and run:</p><pre>poetry build</pre><p>This will create a dist/ directory containing .tar.gz and .whl files for your package. These are the files you’ll upload to your private PyPI server (or, as I like to call it, your “Python treasure chest”).</p><h4><strong>Step 5: Set Up pypiserver</strong></h4><p><strong>Install pypiserver</strong></p><p>Now it’s time to set up your private PyPI server. First, install pypiserver:</p><pre>pip install pypiserver</pre><p><strong>Create a Directory for Your Packages</strong></p><p>Decide where you want to store your private packages. For example:</p><pre>mkdir ~/private_packages</pre><p><strong>Add security using htpasswd</strong></p><p>Create a user and choose a beautiful password for your private PyPi Server</p><pre>htpasswd -sc ~/private_packages/htpasswd.txt admin</pre><p><strong>Start the Server</strong></p><p>Run the following command to start pypiserver:</p><pre>pypi-server run -p 8060 ~/private-packages -P ~/private-packages/htpasswd.txt --hash-algo=sha256</pre><p>This will start the server on <a href="http://localhost:8080`">http://localhost:8060</a>. You can now upload and serve packages from this directory.</p><h4>Step 6: Deploy Your Package to pypiserver</h4><p>Let’s back to my_private_packageproject directory, and add this on your private PyPi Server (let name it as “treasure_chest”) to the pyproject.toml:</p><pre>[[tool.poetry.source]]<br>name = &quot;treasure_chest&quot;<br>url = &quot;http://localhost:8060/simple/&quot;<br>priority = &quot;supplemental&quot;</pre><p>To upload packages to a server with Poetry, you must first configure it.</p><pre>poetry config repositories.treasure_chest http://localhost:8060/<br>poetry config http-basic.treasure_chest admin &quot;&lt;your_beautiful_password&gt;&quot;</pre><p>Then, yeah this time for upload your packages using this command:</p><pre>poetry publish --repository treasure_chest</pre><p>This will upload your package on dist/to your private PyPi Server, and you will see your packages on <a href="http://localhost:8080`">http://localhost:8060</a>/simple/.</p><h4>Step 7: Install Your Private Package</h4><p>To install your private package from pypiserver, use pip with the--extra-index-url option:</p><pre>pip install --extra-index-url http://localhost:8060 my_private_package</pre><p>Or.. you can install it using poetry, with add your private PyPi server configuration on your pyproject.toml like in the package directory earlier</p><pre>[[tool.poetry.source]]<br>name = &quot;treasure_chest&quot;<br>url = &quot;http://localhost:8060/simple/&quot;<br>priority = &quot;supplemental&quot;</pre><p>Then running this command</p><pre>poetry add --source treasure_chest my_private_package</pre><p>If you see Successfully installed my_private_package, congratulations — you’ve officially entered the realm of private package ninjas.</p><h4>Wrapping Up</h4><p>And there you have it! You’ve created a private Python package using Poetry and deployed it on <strong>pypiserver</strong>. Whether you’re building an empire of proprietary modules or just trying to impress your developer friends, you now have the tools to do it.</p><p>Remember, with great power comes great responsibility. Use your private PyPI server wisely, and don’t forget to share this tutorial with your favorite Python buddies. Or don’t — it’s your secret package lair, after all.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e943f6199110" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>