ARTIFACTORY: How to deploy a PyPI package to the Artifactory’s local repository?

Yuvarajan Johnpaul
2022-05-01 12:05

This article describes the steps to configure your Python client to publish packages to the JFrog Artifactory's PyPI repository.

What's needed for a Python package to be published?

Step-1:

First, you need to add Artifactory as an index server for your user. This can be done through the $HOME/.pypirc file configured at the client-side.

To configure the .pypirc file with the Artifactory's repository information, please refer to the Set Me UP section available with the PyPI repositories you have created in Artifactory.

User-added image

Upon clicking on the "Set Me Up" option, it will display the instructions to update the .pypirc file.
 

User-added image

Step-2:

a setup.py file (which includes the package information), For more details on how to prepare a setup.py file, please refer to the article here.

Here’s a sample setup file for referenceimport setuptools
setuptools.setup(
name="hello-pkg-yuvi",
version="1.1.2",
author="Yuvarajan Johnpaul",
author_email="yuva***@jfrog.com",
description="Package for testing uploads [PyPI]",
packages=setuptools.find_packages(),
classifiers=[
"Programming Language :: Python :: 3",
"License :: OSI Approved :: MIT License",
"Operating System :: OS Independent",
],
python_requires='>=3.6',
)

Once the setup.py and the $HOME/.pypirc files are ready, execute the following command to upload the package to the local repository.$ python setup.py sdist upload -r local