Package: pynamer
Utility to find an available package name in the PyPI repository and optionally 'register' it.As a pseudo replacement for pip search, pynamer will quickly ascertain if a project name is 'available' in PyPI.Contentstl;drIntroductionQuick StartPrerequisitesInstallationBasic UsageUsageSpecifying multiple namesUsing an input fileSaving the results to a fileDisplay GitHub statisticsRegister the name with PyPIVerbose outputRegenerate the PyPI simple Repository IndexThe odditiesLimitationsDocumentationRead the DocsAPIWikiPlanned Future improvementsIntroductionProject RationaleSome of you may have reached the point where you want to publish a package in the PyPI python repository.
The first step of which is to choose a unique name. Here lies the problem.A recent look at the PyPI repository revealed there were over 453,769 projects, so many names have already been taken.pip leaps to the rescue with its search utility... or does it?pipsearchzaphodERROR:XMLRPCrequestfailed[code:-32500]RuntimeError:PyPInolongersupports'pip search'(orXML-RPCsearch).
Pleaseusehttps://pypi.org/search(viaabrowser)instead.
Seehttps://warehouse.pypa.io/api-reference/xml-rpc.html#deprecated-methodsformoreinformation.A quick search will show the internet replete with articles explaining the situation:The Register: Why Python's pip search isn't workingPython.org discussion: Pip search is still brokenOK so I go to the PyPI website and do a search for 'zaphod' as suggested by pip and 7 results are displayed none of which have the package name 'zaphod'Fantastic! I now think unbelievably that I have a unique name for a project that I can use.
So, I go ahead and code my new project, along with all the test files, documentation and meta data.
I diligently debug and commit and push to git and github so I have a history.Finally the project is good enough to release and publish as an installable package on PyPI.Here goes....~$python-mtwineupload--config-file.pypircdist/*
Uploadingdistributionstohttps://upload.pypi.org/legacy/
Uploadingzaphod-0.0.0-py3-none-any.whl100%----------------------------------------3.8/3.8kB•00:00•?
WARNINGErrorduringupload.Retrywiththe--verboseoptionformoredetails.
ERRORHTTPError:403Forbiddenfromhttps://upload.pypi.org/legacy/Theuser'stephenking'isn't allowed to upload to project 'zaphod'.Seehttps://pypi.org/help/#project-nameformoreinformation.AARGH!What just happened?Yes unbelievably the project already exists and yes unbelievably PyPI's own search
did not find the project.Enter Pynamer. Pynamer does not rely on a single method of finding a PyPI package:TLDRPynamer uses the following methods to ascertain whether a package already exists on PyPI:A simple request to the project url on PyPI.Uses the PyPI "simple" repository - a text-based listing of all the packages available on PyPI.Uses PyPI's own search 'API' and scrapes the results.Pynamer provides a way to optionally 'register' a name on PyPI by building a minimalistic package and uploadingQuick StartPrerequisitesPython >= 3.9.The following are optional but required for 'registering' a project name on PyPIAn account on PyPI (and generate a PyPI API token).A.pypircfile containing your PyPI API token.orConfigureTwine environment variables.Your .pypirc file should contain the following and be on your PATH:[distutils]
index-servers =
    pypi

[pypi]
repository = https://upload.pypi.org/legacy/
username = __token__
password = your_API_token_hereInstallationPynamer can be installed into any python environment using pip:~$pipinstallpynamerHowever, optimal installation can be achieved usingpipx:~$pipxinstallpynamerBasic UsageA package name that is not available~$pynamerpynballA package name that is available~$pynamerallitnilHoly smoke batman! You've managed to identify a unique name.Yes, even though the odds were against you (given there are over 450,000+ registered projects), you did it!Even though the name has nothing in common with your project, or may not even be a real word... you did it!Congratulations!UsageDisplay the help menu with the-hargument~$pynamer-husage:pynamer[-h][-r][-v][-g][-m][-s][-w][-fFILENAME][-oFILENAME][--version][projects...]Determineifprojectnameisavailableonpypiwiththeoptionto'register'itforfutureuseifavailable

positionalarguments:projectsOptional-oneormoreprojectnames

optionalarguments:-h,--helpshowthishelpmessageandexit-r,--registerregisterthenameonPyPiifthenameisavailable-v,--verbosedisplayinformationaboutsimilarprojects-g,--generategenerateanewPyPIindexfile-m,--metainputnewmetadatawhenregistering(Authorandemailaddress)-s,--statsdisplayGitHubstatsifavailable-w,--webbrowseropentheprojectonPyPIinawebbrowser-fFILENAMEfilecontainingalistofprojectnamestoanalyze-oFILENAMEfiletosavethetestresults--versiondisplayversionnumberSpecifying multiple namesYou can specify as many names as you like from the command line e.g.~$pynamerganymedeeuropacallistoUsing an input fileYou can use the-fargument to specify a file containing the a names of projects to analyze.
You specify a space separated sequence of as many names as you like on as many lines as you like. e.g.'projects' fileganymede europa
IO callistoThen specify the-fargument~$pynamer-fprojectsYou can use the input file with names from the command line. The names will be aggregated. e.g.~$pynamerersapandialedametis-fprojectsSaving the results to a fileYou can specify a file to write the result to by using the-oargument. e.g.~$pynamerersapandialeda-oresultsThis will write a file e.g.resultsResult from pynamer PyPI utility 2023-05-02
-------------------------------------------
test 1 - Basic url lookup on PyPI
test 2 - Search of PyPIs simple index
test 3 - Search using an request to PyPIs search 'API'.

Project name    Test1      Test2        Test 3          Conclusion
-------------------------------------------------------------------
ersa            Found       Found       Found           Not Available
pandia          Not Found   Not Found   Found           Not Available
leda            Not Found   Not Found   Not Found       AvailableAgain you can use a combination of names from the command line and input file.Display GitHub statisticsYou can optionally display some of the most pertinent GitHub statistics if available by using the-sargument.
The statistics will be displayed in the the details section of test 1. e.g.~$pynamerblack-sRegister the package name with PyPIYou can optionally 'register' the name on PyPI by using the-rargument.
If the project name is found to be available and you have a valid 'pypirc' file is found, a minimalistic project will be built and uploaded
to PyPI.The first time you use the 'registration' procedure you will be prompted to enter your name and email address. These are required.
You can also optionally choose to change the version and description.This information will be retained and you will not be prompted to enter this information again. However, you can regenerate
this meta data by using the-margument along with the-rargument. You can just enter on the options you dont want to change.~$pynameragrajag-rVerbose outputWith the-vargument you can display the first page of all other project matched by PyPIs search API - ordered by relevance.
The algorithm that PyPI uses to select these in unknown but seems to be a mixture of names and other
projects written by the same author.~$pynamerpynamer-vRegenerate the PyPI simple Repository IndexAs one of its tests Pynamer makes use of a list of package names scraped from its simple index site.The PyPI Simple Index is a plain text file that lists the names of all the packages available on PyPI.It is a simplified version of the PyPI index that makes it easier for users to browse and download packages.The PyPI Simple Index is used by a variety of tools and libraries to download and install packages from PyPI. For example, the pip package manager, which is used to install and manage Python packages, uses the PyPI Simple Index to find packages.
The Index is updated every few hours.Using the-gargument can be used to regenerate the local file contents.~$pynamer-gSee planned future improvementsThe OdditiesThe reason I wrote this application in the first place...~$pynamerzaphodEven worse ...~$pynamerzemLimitationsThere will be occasions where all the tests pass, the name appears to be available but the upload to PyPI still fails.
This can be several reasons for this:You are trying to use an internally "reserved" keyword for PyPI.The name you are using is too similar to an existing project name and you get the following error message:...
Errorduringupload.Retrywiththe--verboseoptionformoredetails.
HTTPError:400BadRequestfromhttps://test.pypi.org/legacy/
Thename'yourpackage'istoosimilartoanexistingproject.Seehttps://test.pypi.org/help/#project-nameformoreinformation-Using a name similar to to an existing package name is a security issue.Malicious players will try to create project names that are frequently mistyped for large popular projects, thereby facilitating installation of a malicious project.
e.g. replacing "L" / "l" with the number 1 or "o" / "O" with 0. The Software utilized by PyPI can be found on GitHub:warehouse.Using the Docker ImagePull the latest image from the Hub.~$dockerpullsraking/pynamerRun the image.~$dockerrun-itsraking/pynamer/bin/bashUse the command line as normal in the container.root@4d315992ca28:/app#pynamer
usage:pynamer[-h][-r][-v][-g][-m][-s][-w][-fFILENAME][-oFILENAME][--version][projects...]Determineifprojectnameisavailableonpypiwiththeoptionto'register'itforfutureuseifavailable
...DocumentationRead the DocsCreditsChangelogAPI ReferenceWikiPlanned Future improvementsImprove performance of the regeneration of the PyPI simple Repository Index, so this can be run in the background automatically.MetaAuthor: Stephen King (sking.github@gmail.com)Distributed under the MIT license. Seefor more information.Created with Cookiecutter template:version 1.2.2Digital object identifier: