Vous utilisez un fichier setup.py pour générer et envoyer votre module Python. Petite coquille lorsque vous souhaitez envoyer la dernière version à l'aide de la commande :
$ python setup.py sdist upload
running sdist
running check
warning: sdist: standard file not found: should have one of README, README.txt
reading manifest template 'MANIFEST.in'
writing manifest file 'MANIFEST'
...
Creating tar archive
running upload
Traceback (most recent call last):
File "setup.py", line 39, in <module>
url='https://github.com/BoboTiG/python-mss'
File "/usr/lib/python2.7/distutils/core.py", line 151, in setup
dist.run_commands()
File "/usr/lib/python2.7/distutils/dist.py", line 953, in run_commands
self.run_command(cmd)
File "/usr/lib/python2.7/distutils/dist.py", line 972, in run_command
cmd_obj.run()
File "/usr/lib/python2.7/distutils/command/upload.py", line 60, in run
self.upload_file(command, pyversion, filename)
File "/usr/lib/python2.7/distutils/command/upload.py", line 135, in upload_file
self.password)
TypeError: cannot concatenate 'str' and 'NoneType' objects
zsh: exit 1 python setup.py sdist upload
Avec Python 3.4, même combat :
$ python3 setup.py sdist upload
running sdist
running check
warning: sdist: standard file not found: should have one of README, README.txt
reading manifest template 'MANIFEST.in'
writing manifest file 'MANIFEST'
...
Creating tar archive
running upload
Traceback (most recent call last):
File "setup.py", line 39, in <module>
url='https://github.com/BoboTiG/python-mss'
File "/usr/lib/python3.4/distutils/core.py", line 148, in setup
dist.run_commands()
File "/usr/lib/python3.4/distutils/dist.py", line 955, in run_commands
self.run_command(cmd)
File "/usr/lib/python3.4/distutils/dist.py", line 974, in run_command
cmd_obj.run()
File "/usr/lib/python3.4/distutils/command/upload.py", line 65, in run
self.upload_file(command, pyversion, filename)
File "/usr/lib/python3.4/distutils/command/upload.py", line 139, in upload_file
user_pass = (self.username + ":" + self.password).encode('ascii')
TypeError: Can't convert 'NoneType' object to str implicitly
zsh: exit 1 python3 setup.py sdist upload
Le problème et sa solution
Le soucis vient de la concaténation du nom d'utilisateur et du mot de passe pour accéder à l'envoi sur pypi.python.org.
Afin de pallier cet inconvénient, créer, s'il n'existe pas encore, le fichier ~/.pypirc et y insérer le contenu suivant :
[distutils]
index-servers = pypi
[pypi]
username:$user
password:$password
La ligne importante est la dernière où nous précisons, en clair, le mot de passe. Très mauvaise habitude, mais pour dépanner, on dira que ça passe.