Resolution

How to Use Include and Exclude Patterns on PyPi Repositories

AuthorFullName__c
Adi Vizgan
articleNumber
000004444
ft:sourceType
Salesforce
FirstPublishedDate
2019-03-25T10:02:40Z
lastModifiedDate
2024-03-10T07:46:53Z
VersionNumber
7
Here’s an example: Let’s say you uploaded a package to your local PyPi repository, named hello1234, version 0.0.1. In the remote PyPi repository, there’s a version 0.0.2 of this package. If you perform the pip install hello1234 command, you should find that Artifactory will go to the remote repository and fetch version 0.0.2:

User-added image

Now take a look in the cache and you should see that the metadata file is located in a folder named .pypi and is called hello1234.html. What you’d want to do next is to place the following exclude pattern in the remote repository: .pypi/hello1234.*. This will block the metadata file from being downloaded and clear the cache. When pip install hello1234 command is performed again, you should see that version 0.0.1 has been fetched from the local repository:
User-added image

NOTE: Regardless of their names, all metadata files are saved with lowercase letters. Accordingly, include/exclude patterns must always be in lowercase. For example, to exclude the package named HAL (written with all uppercase letters in the remote repository), you will need to set your exclude pattern as .pypi/hal.*. And upon executing this command, keep your fingers crossed that the result that comes back isn’t a message reading, "I’m sorry, Dave, I’m afraid I can’t do that." ☺