To upload authenticated PyPI packages to JFrog Artifactory:
Create the
.pypirc
file using the following code, and add your access token from JFrog Artifactory for the usernamepypiadmin.
.[distutils] index-servers = private-repository [private-repository] repository = https://soleng.jfrog.io/artifactory/api/pypi/demo-pypi-local username = pypiadmin password = eyJ2ZXIiOiIyIiwidHlwIjoiSldUIiwiYWxnIjoiUlMyNTYiLCJraWQiOiJsYkpadzNJUU13WXBBSWNRa01RRjN0dlA2Yml5M3dWcXdrQ0txUkxLaXhRIn0.eyJleHQiOiJ7XCJyZXZvY2FibGVcIjpcInRydWVcIn0iLCJzdWIiOiJqZmFjQDAxZTlycTMza3ljMHQxMWtwangybmcwemo1XC91c2Vyc1wvcHlwaWFkbWluIiwic2NwIjoiYXBwbGllZC1wZXJtaXNzaW9uc1wvYWRtaW4iLCJhdWQiOiIqQCoiLCJpc3MiOiJqZmZlQDAwMCIsImV4cCI6MTY4OTY5ODA5MywiaWF0IjoxNjU4MTYyMDkzLCJqdGkiOiJiZWY1YWY5Ni0zNTkyLTRiOTQtYWYyNS1kZmIxY2U1ZGU4YzIifQ.NI5OXpw0NHs7Asd3f_sY3tMyzM-2_07c3WyWEpbJrDPxO8eKoLRp10vGEF8Jo3HyRQ0H7Ybzf2-Cn8wf9yFMo4UGlgxGfm7_yc24xWVLCINjg0B2A5YRSvAetwdT2wgVPvEMUqCPSCU4_SGgGg606lIDxxImRfgZWwFn-wHfU8b8dCV7EV4dXGvH7iVb33W2JguE9KIQFP7lKkQlaErO6pGFNuPfOx1JbJllHh0oRpAPzvykda2i6Q2q3ZCObJZ9Rp8NqZYQfEm42YtIaOvAlE5fGepZgDjzHaaLcztJDHoR-BWjMiDfP0LRThHASo7F52t8p3vsZHW5NEov_trFrQ
Copy the
.pypirc
file to your Users folder.For macOS users, create the file under
%USERPROFILE%
For Windows users, create the file under
c:\users\<name>
Validate that the
setup.py
file contains all of the following fields. It should be automatically created, but if it is not, add the file to your root folder with the following content.#!/usr/bin/env python from setuptools import setup setup( name='demo-python-example', version='1.0', description='Project example for building Python project with JFrog products', author='JFrog', author_email='jfrog@jfrog.com', packages=['helloworld'], install_requires=['PyYAML>3.11', 'nltk'], )
Create a PyPI package.
py setup.py sdist bdist_wheel
The following displays an example output.
C:\Users\johnk\helloworld>py setup.py sdist bdist_wheel running sdist running egg_info writing demo_python_example.egg-info\PKG-INFO writing dependency_links to demo_python_example.egg-info\dependency_links.txt writing requirements to demo_python_example.egg-info\requires.txt writing top-level names to demo_python_example.egg-info\top_level.txt reading manifest file 'demo_python_example.egg-info\SOURCES.txt' writing manifest file 'demo_python_example.egg-info\SOURCES.txt' warning: sdist: standard file not found: should have one of README, README.rst, README.txt, README.md running check creating demo-python-example-1.0 creating demo-python-example-1.0\demo_python_example.egg-info creating demo-python-example-1.0\helloworld copying files to demo-python-example-1.0... copying setup.py -> demo-python-example-1.0 copying demo_python_example.egg-info\PKG-INFO -> demo-python-example-1.0\demo_python_example.egg-info copying demo_python_example.egg-info\SOURCES.txt -> demo-python-example-1.0\demo_python_example.egg-info copying demo_python_example.egg-info\dependency_links.txt -> demo-python-example-1.0\demo_python_example.egg-info copying demo_python_example.egg-info\requires.txt -> demo-python-example-1.0\demo_python_example.egg-info copying demo_python_example.egg-info\top_level.txt -> demo-python-example-1.0\demo_python_example.egg-info copying helloworld\app.py -> demo-python-example-1.0\helloworld Writing demo-python-example-1.0\setup.cfg Creating tar archive removing 'demo-python-example-1.0' (and everything under it) running bdist_wheel running build running build_py C:\Users\johnk\installs\lib\site-packages\setuptools\command\install.py:34: SetuptoolsDeprecationWarning: setup.py install is deprecated. Use build and pip and other standards-based tools. warnings.warn( installing to build\bdist.win-amd64\wheel running install running install_lib creating build\bdist.win-amd64\wheel creating build\bdist.win-amd64\wheel\helloworld copying build\lib\helloworld\app.py -> build\bdist.win-amd64\wheel\.\helloworld running install_egg_info Copying demo_python_example.egg-info to build\bdist.win-amd64\wheel\.\demo_python_example-1.0-py3.10.egg-info running install_scripts creating build\bdist.win-amd64\wheel\demo_python_example-1.0.dist-info\WHEEL creating 'dist\demo_python_example-1.0-py3-none-any.whl' and adding 'build\bdist.win-amd64\wheel' to it adding 'helloworld/app.py' adding 'demo_python_example-1.0.dist-info/METADATA' adding 'demo_python_example-1.0.dist-info/WHEEL' adding 'demo_python_example-1.0.dist-info/top_level.txt' adding 'demo_python_example-1.0.dist-info/RECORD' removing build\bdist.win-amd64\wheel C:\Users\johnk\helloworld>
Upload the package to JFrog Artifactory.
py setup.py sdist upload -r private-repository
The following displays an example output.
C:\Users\johnk\helloworld>py setup.py sdist bdist_wheel running sdist running egg_info writing demo_python_example.egg-info\PKG-INFO writing dependency_links to demo_python_example.egg-info\dependency_links.txt writing requirements to demo_python_example.egg-info\requires.txt writing top-level names to demo_python_example.egg-info\top_level.txt reading manifest file 'demo_python_example.egg-info\SOURCES.txt' writing manifest file 'demo_python_example.egg-info\SOURCES.txt' warning: sdist: standard file not found: should have one of README, README.rst, README.txt, README.md running check creating demo-python-example-1.0 creating demo-python-example-1.0\demo_python_example.egg-info creating demo-python-example-1.0\helloworld copying files to demo-python-example-1.0... copying setup.py -> demo-python-example-1.0 copying demo_python_example.egg-info\PKG-INFO -> demo-python-example-1.0\demo_python_example.egg-info copying demo_python_example.egg-info\SOURCES.txt -> demo-python-example-1.0\demo_python_example.egg-info copying demo_python_example.egg-info\dependency_links.txt -> demo-python-example-1.0\demo_python_example.egg-info copying demo_python_example.egg-info\requires.txt -> demo-python-example-1.0\demo_python_example.egg-info copying demo_python_example.egg-info\top_level.txt -> demo-python-example-1.0\demo_python_example.egg-info copying helloworld\app.py -> demo-python-example-1.0\helloworld Writing demo-python-example-1.0\setup.cfg Creating tar archive removing 'demo-python-example-1.0' (and everything under it) running bdist_wheel running build running build_py C:\Users\johnk\installs\lib\site-packages\setuptools\command\install.py:34: SetuptoolsDeprecationWarning: setup.py install is deprecated. Use build and pip and other standards-based tools. warnings.warn( installing to build\bdist.win-amd64\wheel running install running install_lib creating build\bdist.win-amd64\wheel creating build\bdist.win-amd64\wheel\helloworld copying build\lib\helloworld\app.py -> build\bdist.win-amd64\wheel\.\helloworld running install_egg_info Copying demo_python_example.egg-info to build\bdist.win-amd64\wheel\.\demo_python_example-1.0-py3.10.egg-info running install_scripts creating build\bdist.win-amd64\wheel\demo_python_example-1.0.dist-info\WHEEL creating 'dist\demo_python_example-1.0-py3-none-any.whl' and adding 'build\bdist.win-amd64\wheel' to it adding 'helloworld/app.py' adding 'demo_python_example-1.0.dist-info/METADATA' adding 'demo_python_example-1.0.dist-info/WHEEL' adding 'demo_python_example-1.0.dist-info/top_level.txt' adding 'demo_python_example-1.0.dist-info/RECORD' removing build\bdist.win-amd64\wheel C:\Users\johnk\helloworld>
Your package was uploaded successfully to the JFrog Platform. Check it out by navigating to Application > Artifactory > Artifacts and searching for the package.