diff --git a/python-example/pip-example/README.md b/python-example/pip-example/README.md index 131e939eca..d386bc0001 100644 --- a/python-example/pip-example/README.md +++ b/python-example/pip-example/README.md @@ -6,7 +6,7 @@ This example demonstrates how to build a Python Pip project with Artifactory, wh ## Before Running the Example ### Set Up the Environment 1. Make sure **Python** is installed and the **python** command is in your PATH. -2. Install **pip**. You can use the [Pip Documentation](https://pip.pypa.io/en/stable/installing/) and also [Installing packages using pip and virtual environments](https://packaging.python.org/guides/installing-using-pip-and-virtual-environments/) +2. Install **pip**. You can use the [Pip Documentation](https://pip.pypa.io/en/stable/installation/) and also [Installing packages using pip and virtual environments](https://packaging.python.org/guides/installing-using-pip-and-virtual-environments/) 3. Create three Pypi repositories in Artifactory - a local, remote and a virtual repository. You can use the [PyPi Repositories Documentation](https://www.jfrog.com/confluence/display/RTF/PyPI+Repositories). * The remote repository should proxy *https://files.pythonhosted.org* (the default when creating a Pypi remote repository). * Name the virtual repository *pypi*. @@ -74,4 +74,4 @@ Validate package successfully installed: > pip show jfrog-python-example ``` -Learn about [Building Python Packages with JFrog CLI](https://www.jfrog.com/confluence/display/CLI/CLI+for+JFrog+Artifactory#CLIforJFrogArtifactory-BuildingPythonPackages). +Learn about [Building Python Packages with JFrog CLI](https://docs.jfrog-applications.jfrog.io/jfrog-applications/jfrog-cli/cli-for-jfrog-artifactory/package-managers-integration#building-python-packages). diff --git a/python-example/pipenv-example/README.md b/python-example/pipenv-example/README.md index e4e9b1d84a..a5ab2559f4 100644 --- a/python-example/pipenv-example/README.md +++ b/python-example/pipenv-example/README.md @@ -56,4 +56,4 @@ Publish the build info to Artifactory: Install published package by installing it from Artifactory using pip: > jf pipenv install jfrog-pipenv-example -Learn about [Building Python Packages with JFrog CLI](https://www.jfrog.com/confluence/display/CLI/CLI+for+JFrog+Artifactory#CLIforJFrogArtifactory-BuildingPythonPackages). +Learn about [Building Python Packages with JFrog CLI](https://docs.jfrog-applications.jfrog.io/jfrog-applications/jfrog-cli/cli-for-jfrog-artifactory/package-managers-integration#building-python-packages). diff --git a/python-example/twine-example/README.md b/python-example/twine-example/README.md new file mode 100644 index 0000000000..fa48d00495 --- /dev/null +++ b/python-example/twine-example/README.md @@ -0,0 +1,68 @@ +# Pip Example + +## Overview +This example demonstrates how to build a Python Pip project with Artifactory, deploying it using Twine, while collecting build-info. + +## Before Running the Example +### Set Up the Environment +1. Make sure **Python** is installed and the **python** command is in your PATH. +2. Install **pip**. You can use the [Pip Documentation](https://pip.pypa.io/en/stable/installation/) and also [Installing packages using pip and virtual environments](https://packaging.python.org/guides/installing-using-pip-and-virtual-environments/) +3. Install **twine** by running `pip install twine`. +4. Create three Pypi repositories in Artifactory - a local, remote and a virtual repository. You can use the [PyPi Repositories Documentation](https://www.jfrog.com/confluence/display/RTF/PyPI+Repositories). +* The remote repository should proxy *https://files.pythonhosted.org* (the default when creating a Pypi remote repository). +* Name the virtual repository *pypi*. +* The virtual repository should include the remote repository. +* The virtual repository should have the local repository set as the *Default Deployment Repository*. +5. Make sure version 2.68.0 or above of [JFrog CLI](https://jfrog.com/getcli/) is installed. + +### Validate the Setup +In your terminal, validate that the following commands work. +```console +Output Python version: +> python --version + +Output pip version: +> pip --version + +Verify twine is installed: +> twine --version + +Verify that virtual-environment is activated: +> echo $VIRTUAL_ENV + +Output JFrog CLI version: +> jf --version +``` + +## Running the Example +'cd' to the root project directory + +```console +Configure Artifactory: +> jf c add --url= [credentials flags] + +Configure the project's resolution repository. You shoud set the virtual repository you created. +> jf pip-config --repo-resolve= --repo-deploy= + +Install project dependencies with pip from Artifactory: + +Using toml: +> jf pip install . +> python -m build --sdist --wheel + +Using Setup.py: +> jf pip install . --build-name=my-pip-build --build-number=1 --module=jfrog-python-example +Package the project, create distribution archives (tar.gz and whl): +> python setup.py sdist bdist_wheel + +Upload the packages to the pypi repository in Artifactory: +> jf twine upload "dist/*" --build-name=my-pip-build --build-number=1 + +Collect environment variables and add them to the build info: +> jf rt bce my-pip-build 1 + +Publish the build info to Artifactory: +> jf rt bp my-pip-build 1 +``` + +Learn about [Building Python Packages with JFrog CLI](https://docs.jfrog-applications.jfrog.io/jfrog-applications/jfrog-cli/cli-for-jfrog-artifactory/package-managers-integration#building-python-packages). diff --git a/python-example/twine-example/pyproject.toml b/python-example/twine-example/pyproject.toml new file mode 100644 index 0000000000..792971df43 --- /dev/null +++ b/python-example/twine-example/pyproject.toml @@ -0,0 +1,15 @@ +[build-system] +requires = ["setuptools>=42", "wheel"] +build-backend = "setuptools.build_meta" + +[project] +name = "jfrog-python-example" +version = "1.0" +description = "Project example for building Python project with JFrog products" +authors = [ + { name="JFrog", email="jfrog@jfrog.com" } +] +dependencies = [ + "PyYAML>3.11", + "nltk" +] diff --git a/python-example/twine-example/pythonExample/__init__.py b/python-example/twine-example/pythonExample/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/python-example/twine-example/pythonExample/pythonProj.py b/python-example/twine-example/pythonExample/pythonProj.py new file mode 100644 index 0000000000..0dd812afdd --- /dev/null +++ b/python-example/twine-example/pythonExample/pythonProj.py @@ -0,0 +1,10 @@ +#!/usr/bin/python + +# Function definition is here +def printme( str ): + # This prints a passed string into this function + print (str) + return; + +# Now you can call printme function +printme("Hello from JFROG");