From 4cd99244fb0cb5e9b4468c9ad63c2d31415b33ec Mon Sep 17 00:00:00 2001 From: RobiNino Date: Wed, 18 Sep 2024 19:21:22 +0300 Subject: [PATCH 1/2] twine support --- .../package-managers-integration.md | 206 +++++++++++------- 1 file changed, 132 insertions(+), 74 deletions(-) diff --git a/jfrog-applications/jfrog-cli/cli-for-jfrog-artifactory/package-managers-integration.md b/jfrog-applications/jfrog-cli/cli-for-jfrog-artifactory/package-managers-integration.md index 32c6212..063e484 100644 --- a/jfrog-applications/jfrog-cli/cli-for-jfrog-artifactory/package-managers-integration.md +++ b/jfrog-applications/jfrog-cli/cli-for-jfrog-artifactory/package-managers-integration.md @@ -693,136 +693,194 @@ jf gp v1.2.3 --build-name my-build-name --build-number 1 ## Building Python Packages -JFrog CLI provides full support for building Python packages using the **pip** and **pipenv** and **poetry** package installers. This allows resolving python dependencies from Artifactory, while (for **pip** and **pipenv**) recording the downloaded packages. The downloaded packages are stored as dependencies in the build-info stored in Artifactory. +### Pip, Pipenv and Twine +JFrog CLI provides full support for building Python packages using the **pip** and **pipenv** package managers, and deploying distributions using **twine**. This allows resolving python dependencies from Artifactory, using for **pip** and **pipenv**, while recording the downloaded packages. +After the installing and packaging the project, the distributions and wheels can be deployed to Artifactory using **twine**, while recording the uploaded packages. +The downloaded packages are stored as dependencies in the build-info stored in Artifactory, while the uploaded ones are stored as artifacts. -Once the packages are installed, the Python project can be then built and packaged using the pip, pipenv or poetry clients. Once built, the produced artifacts can be uploaded to Artifactory using JFrog CLI's upload command and registered as artifacts in the build-info. - -### Example projects +#### Example projects To help you get started, you can use [the sample projects on GitHub](https://github.com/jfrog/project-examples/tree/master/python-example). -### Setting Python repository +#### Setting Python repository Before you can use JFrog CLI to build your Python projects with Artifactory, you first need to set the repository for the project. Here's how you set the repositories. 1. 'cd' into the root of the Python project. -2. Run the **jf pip-config**, **jf pipenv-config** or **jf poetry-config** commands, depending on whether you're using the pip, pipenv or poetry clients. +2. Run the **jf pip-config** or **jf pipenv-config** commands, depending on whether you're using the **pip** or **pipenv** clients. -#### Commands Params +##### Commands Params -| | | -|---------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| -| Command-name | pip-config / pipenv-config / poetry-config | -| Abbreviation | pipc / pipec / poc | -| **Command options:** | | -| `--global` |

[Default false]
Set to true, if you'd like the configuration to be global (for all projects on the machine). Specific projects can override the global configuration.

| +| | | +|-----------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| Command-name | pip-config / pipenv-config | +| Abbreviation | pipc / pipec | +| **Command options:** | | +| `--global` |

[Default false]
Set to true, if you'd like the configuration to be global (for all projects on the machine). Specific projects can override the global configuration.

| | `--server-id-resolve` |

[Optional]
Artifactory server ID for resolution. The server should configured using the 'jf c add' command.

| -| `--repo-resolve` |

[Optional]
Repository for dependencies resolution.

| +| `--repo-resolve` |

[Optional]
Repository for dependencies resolution.

| +| `--server-id-deploy` |

[Optional]
Artifactory server ID for deployment. The server should configured using the 'jf c add' command.

| +| `--repo-deploy` |

[Optional]
Repository for artifacts deployment.

| -#### Examples -##### Example 1 +##### Examples +###### Example 1 -Set repositories for this Python project when using the pip client. +Set repositories for this Python project when using the pip client (for pipenv: `jf pipec`). ``` jf pipc ``` -##### Example 2 +###### Example 2 -Set repositories for all Python projects using the pip client on this machine. +Set repositories for all Python projects using the pip client on this machine (for pipenv: `jf pipec --global`). ``` jf pipc --global ``` -##### Example 3 +#### Installing Python packages -Set repositories for this Python project when using the pipenv client. +The **jf pip install** and **jf pipenv install** commands use the **pip** and **pipenv** clients respectively, to install the project dependencies from Artifactory. The **jf pip install** and **jf pipenv install** commands can also record these packages as build dependencies as part of the build-info published to Artifactory. -``` -jf pipec -``` +> **Note**: Before running the **pip install** and **pipenv install** commands on a project for the first time, the project should be configured using the **jf pip-config** or **jf pipenv-config** commands respectively. -##### Example 4 +**Recording all dependencies** -Set repositories for all Python projects using the poetry client on this machine. +JFrog CLI records the installed packages as build-info dependencies. The recorded dependencies are packages installed during the **jf pip install** and **jf pipenv install** command execution. When running the command inside a Python environment, which already has some of the packages installed, the installed packages will not be included as part of the build-info, because they were not originally installed by JFrog CLI. A warning message will be added to the log in this case. -``` -jf poc --global -``` +**How to include all packages in the build-info?** -##### Example 5 +The details of all the installed packages are always cached by the **jf pip install** and **jf pipenv install** command in the **.jfrog/projects/deps.cache.json** file, located under the root of the project. JFrog CLI uses this cache for including previously installed packages in the build-info.\ +If the Python environment had some packages installed prior to the first execution of the `install` command, those previously installed packages will be missing from the cache and therefore will not be included in the build-info. -Set repositories for this Python project when using the poetry client. +Running the `install` command with both the **no-cache-dir** and **force-reinstall** pip options, should re-download and install these packages, and they will therefore be included in the build-info and added to the cache. It is also recommended to run the command from inside a [virtual environment](https://packaging.python.org/guides/installing-using-pip-and-virtual-environments/). + +##### Commands Params + +| | | +|----------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| Command-name | pip / pipenv | +| Abbreviation | | +| **Command options:** | | +| `--build-name` |

[Optional]
Build name. For more details, please refer to Build Integration.

| +| `--build-number` |

[Optional]
Build number. For more details, please refer to Build Integration.

| +| `--project` |

[Optional]
JFrog project key.

| +| `--module` |

[Optional]
Optional module name for the build-info.

| +| Command argument | The command accepts the same arguments and options as the pip / pipenv clients. | + +##### Examples +###### Example 1 + +The following command triggers pip install, while recording the build dependencies as part of build name **my-build** and build number **1** . ``` -jf poc +jf pip install . --build-name my-build --build-number 1 ``` -##### Example 6 +###### Example 2 -Set repositories for all Python projects using the pipenv client on this machine. +The following command triggers pipenv install, while recording the build dependencies as part of build name **my-build** and build number **1** . ``` -jf pipec --global +jf pipenv install . --build-name my-build --build-number 1 ``` -### Installing Python packages +#### Publishing Python packages using Twine +The **jf twine upload** command uses the **twine**, to publish the project distributions to Artifactory. The **jf twine upload** command can also record these packages as build artifacts as part of the build-info published to Artifactory. -The **jf pip install**, **jf pipenv install** and **jf poetry install** commands use the **pip**, **pipenv** and **poetry** clients respectively, to install the project dependencies from Artifactory. The **jf pip install** and **jf pipenv install** commands can also record these packages as build dependencies as part of the build-info published to Artifactory. +> **Note**: Before running the **twine upload** command on a project for the first time, the project should be configured using the **jf pip-config** or **jf pipenv-config** commands, with deployer configuration. -> **Note**: Before running the **pip install**, **pipenv install** and **poetry install** commands on a project for the first time, the project should be configured using the **jf pip-config** ,**jf pipenv-config** or **jf poetry-config** commands respectively. +##### Commands Params -**Recording all dependencies** - currently available for pip and pipenv. +| | | +|----------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| Command-name | twine | +| Abbreviation | | +| **Command options:** | | +| `--build-name` |

[Optional]
Build name. For more details, please refer to Build Integration.

| +| `--build-number` |

[Optional]
Build number. For more details, please refer to Build Integration.

| +| `--project` |

[Optional]
JFrog project key.

| +| `--module` |

[Optional]
Optional module name for the build-info.

| +| Command argument | The command accepts the same arguments and options as the twine client. | -JFrog CLI records the installed packages as build-info dependencies. The recorded dependencies are packages installed during the **jf pip install** and **jf pipenv install** command execution. When running the command inside a Python environment, which already has some of the packages installed, the installed packages will not be included as part of the build-info, because they were not originally installed by JFrog CLI. A warning message will be added to the log in this case. +##### Examples +###### Example 1 -**How to include all packages in the build-info?** +The following command triggers twine upload, while recording the build artifacts as part of build name **my-build** and build number **1** . -The details of all the installed packages are always cached by the **jf pip install** and **jf pipenv install** command in the **.jfrog/projects/deps.cache.json** file, located under the root of the project. JFrog CLI uses this cache for including previously installed packages in the build-info.\ -If the Python environment had some packages installed prior to the first execution of the `install` command, those previously installed packages will be missing from the cache and therefore will not be included in the build-info. +``` +jf twine upload "dist/*" --build-name my-build --build-number 1 +``` -Running the `install` command with both the **no-cache-dir** and **force-reinstall** pip options, should re-download and install these packages, and they will therefore be included in the build-info and added to the cache. It is also recommended to run the command from inside a [virtual environment](https://packaging.python.org/guides/installing-using-pip-and-virtual-environments/). +## Poetry +JFrog CLI provides partial support for building Python packages using the **poetry** package manager. This allows resolving python dependencies from Artifactory, but currently does NOT record downloaded packages as dependencies in the build-info. -#### Commands Params +#### Setting Python repository -| | | -|------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| -| Command-name | pip / pipenv / poetry | -| Abbreviation | | -| **Command options:** | | -| `--build-name` |

[Optional]
Build name. For more details, please refer to Build Integration.

| -| `--build-number` |

[Optional]
Build number. For more details, please refer to Build Integration.

| -| `--project` |

[Optional]
JFrog project key.

| -| `--module` |

[Optional]
Optional module name for the build-info.

| -| Command argument | The command accepts the same arguments and options as the pip / pipenv / poetry clients. | +Before you can use JFrog CLI to build your Python projects with Artifactory, you first need to set the repository for the project. -#### Examples -##### Example 1 +Here's how you set the repositories. -The following command triggers pip install, while recording the build dependencies as part of build name **my-build** and build number **1** . +1. 'cd' into the root of the Python project. +2. Run the **jf poetry-config** command as follows. + +##### Commands Params + +| | | +|-----------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| Command-name | poetry-config | +| Abbreviation | poc | +| **Command options:** | | +| `--global` |

[Default false]
Set to true, if you'd like the configuration to be global (for all projects on the machine). Specific projects can override the global configuration.

| +| `--server-id-resolve` |

[Optional]
Artifactory server ID for resolution. The server should configured using the 'jf c add' command.

| +| `--repo-resolve` |

[Optional]
Repository for dependencies resolution.

| + +##### Examples +###### Example 1 + +Set repositories for this Python project when using the poetry client. ``` -jf pip install . --build-name my-build --build-number 1 +jf poc ``` -##### Example 2 +###### Example 2 -The following command triggers pipenv install, while recording the build dependencies as part of build name **my-build** and build number **1** . +Set repositories for all Python projects using the poetry client on this machine. ``` -jf pipenv install . --build-name my-build --build-number 1 +jf poc --global ``` -##### Example 3 +#### Installing Python packages + +The **jf poetry install** commands use the **poetry** client to install the project dependencies from Artifactory. + +> **Note**: Before running the **poetry install** command on a project for the first time, the project should be configured using the **jf poetry-config** command. + +##### Commands Params -The following are command triggers poetry install, while recording the build dependencies as part of build name **my-build** and build number **1** . +| | | +|----------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| Command-name | poetry | +| Abbreviation | | +| **Command options:** | | +| `--build-name` |

[Optional]
Build name. For more details, please refer to Build Integration.

| +| `--build-number` |

[Optional]
Build number. For more details, please refer to Build Integration.

| +| `--project` |

[Optional]
JFrog project key.

| +| `--module` |

[Optional]
Optional module name for the build-info.

| +| Command argument | The command accepts the same arguments and options as the poetry clients. | + +##### Examples +###### Example 1 + +The following command triggers poetry install, while resolving dependencies from Artifactory. ``` -jf poetry install . --build-name my-build --build-number 1 +jf poetry install . ``` ## Building NuGet Packages @@ -923,15 +981,15 @@ The **jf terraform-config** command will store the repository name inside the ** The following table lists the command options: -| | | -|--------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------| -| Command-name | terraform-config | -| Abbreviation | tfc | -| **Command options:** | | -| `--global` |

[Optional]
Set to true, if you'd like the configuration to be global (for all projects on the machine). Specific projects can override the global configuration.

| -| `--server-id-deploy` |

[Optional]
Artifactory server ID for deployment. The server should configured using the 'jf c add' command.

| -| `--repo-deploy` |

[Optional]
Repository for artifacts deployment.

| -| **Command arguments:** | The command accepts no arguments | +| | | +|------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| Command-name | terraform-config | +| Abbreviation | tfc | +| **Command options:** | | +| `--global` |

[Optional]
Set to true, if you'd like the configuration to be global (for all projects on the machine). Specific projects can override the global configuration.

| +| `--server-id-deploy` |

[Optional]
Artifactory server ID for deployment. The server should configured using the 'jf c add' command.

| +| `--repo-deploy` |

[Optional]
Repository for artifacts deployment.

| +| **Command arguments:** | The command accepts no arguments | #### Examples ##### Example 1 From b59347cfc96bde56cd676b34ba2f22d7c9cdfde1 Mon Sep 17 00:00:00 2001 From: RobiNino Date: Thu, 19 Sep 2024 08:58:06 +0300 Subject: [PATCH 2/2] CR comment --- .../cli-for-jfrog-artifactory/package-managers-integration.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/jfrog-applications/jfrog-cli/cli-for-jfrog-artifactory/package-managers-integration.md b/jfrog-applications/jfrog-cli/cli-for-jfrog-artifactory/package-managers-integration.md index 063e484..9a5decd 100644 --- a/jfrog-applications/jfrog-cli/cli-for-jfrog-artifactory/package-managers-integration.md +++ b/jfrog-applications/jfrog-cli/cli-for-jfrog-artifactory/package-managers-integration.md @@ -695,7 +695,7 @@ jf gp v1.2.3 --build-name my-build-name --build-number 1 ### Pip, Pipenv and Twine JFrog CLI provides full support for building Python packages using the **pip** and **pipenv** package managers, and deploying distributions using **twine**. This allows resolving python dependencies from Artifactory, using for **pip** and **pipenv**, while recording the downloaded packages. -After the installing and packaging the project, the distributions and wheels can be deployed to Artifactory using **twine**, while recording the uploaded packages. +After installing and packaging the project, the distributions and wheels can be deployed to Artifactory using **twine**, while recording the uploaded packages. The downloaded packages are stored as dependencies in the build-info stored in Artifactory, while the uploaded ones are stored as artifacts. #### Example projects @@ -804,7 +804,7 @@ The **jf twine upload** command uses the **twine**, to publish the project distr | `--build-number` |

[Optional]
Build number. For more details, please refer to Build Integration.

| | `--project` |

[Optional]
JFrog project key.

| | `--module` |

[Optional]
Optional module name for the build-info.

| -| Command argument | The command accepts the same arguments and options as the twine client. | +| Command argument | The command accepts the arguments and options supported by twine client, except for repository configuration and authentication options. | ##### Examples ###### Example 1