-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Deprecate upload and register commands #1410
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Deprecate ``upload`` and ``register`` commands. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -48,8 +48,6 @@ Feature Highlights: | |
* Command aliases - create project-specific, per-user, or site-wide shortcut | ||
names for commonly used commands and options | ||
|
||
* PyPI upload support - upload your source distributions and eggs to PyPI | ||
|
||
* Deploy your project in "development mode", such that it's available on | ||
``sys.path``, yet can still be edited directly from its source checkout. | ||
|
||
|
@@ -107,11 +105,10 @@ As you can see, it doesn't take much to use setuptools in a project. | |
Run that script in your project folder, alongside the Python packages | ||
you have developed. | ||
|
||
Invoke that script to produce eggs, upload to | ||
PyPI, and automatically include all packages in the directory where the | ||
setup.py lives. See the `Command Reference`_ section below to see what | ||
commands you can give to this setup script. For example, | ||
to produce a source distribution, simply invoke:: | ||
Invoke that script to produce distributions and automatically include all | ||
packages in the directory where the setup.py lives. See the `Command | ||
Reference`_ section below to see what commands you can give to this setup | ||
script. For example, to produce a source distribution, simply invoke:: | ||
|
||
python setup.py sdist | ||
|
||
|
@@ -138,7 +135,7 @@ dependencies, and perhaps some data files and scripts:: | |
'hello': ['*.msg'], | ||
}, | ||
|
||
# metadata for upload to PyPI | ||
# metadata to display on PyPI | ||
author="Me", | ||
author_email="[email protected]", | ||
description="This is an Example Package", | ||
|
@@ -618,9 +615,8 @@ using ``setup.py develop``.) | |
Dependencies that aren't in PyPI | ||
-------------------------------- | ||
|
||
If your project depends on packages that aren't registered in PyPI, you may | ||
still be able to depend on them, as long as they are available for download | ||
as: | ||
If your project depends on packages that don't exist on PyPI, you may still be | ||
able to depend on them, as long as they are available for download as: | ||
|
||
- an egg, in the standard distutils ``sdist`` format, | ||
- a single ``.py`` file, or | ||
|
@@ -1192,15 +1188,6 @@ Whenever you install an updated version of setuptools, you should also update | |
your projects' ``ez_setup.py`` files, so that a matching version gets installed | ||
on the target machine(s). | ||
|
||
By the way, setuptools supports the new PyPI "upload" command, so you can use | ||
``setup.py sdist upload`` or ``setup.py bdist_egg upload`` to upload your | ||
source or egg distributions respectively. Your project's current version must | ||
be registered with PyPI first, of course; you can use ``setup.py register`` to | ||
do that. Or you can do it all in one step, e.g. ``setup.py register sdist | ||
bdist_egg upload`` will register the package, build source and egg | ||
distributions, and then upload them both to PyPI, where they'll be easily | ||
found by other projects that depend on them. | ||
|
||
(By the way, if you need to distribute a specific version of ``setuptools``, | ||
you can specify the exact version and base download URL as parameters to the | ||
``use_setuptools()`` function. See the function's docstring for details.) | ||
|
@@ -1517,22 +1504,11 @@ you use any option at all. | |
Making your package available for EasyInstall | ||
--------------------------------------------- | ||
|
||
If you use the ``register`` command (``setup.py register``) to register your | ||
package with PyPI, that's most of the battle right there. (See the | ||
`docs for the register command`_ for more details.) | ||
|
||
.. _docs for the register command: http://docs.python.org/dist/package-index.html | ||
|
||
If you also use the `upload`_ command to upload actual distributions of your | ||
package, that's even better, because EasyInstall will be able to find and | ||
download them directly from your project's PyPI page. | ||
|
||
However, there may be reasons why you don't want to upload distributions to | ||
There may be reasons why you don't want to upload distributions to | ||
PyPI, and just want your existing distributions (or perhaps a Subversion | ||
checkout) to be used instead. | ||
|
||
So here's what you need to do before running the ``register`` command. There | ||
are three ``setup()`` arguments that affect EasyInstall: | ||
There are three ``setup()`` arguments that affect EasyInstall: | ||
|
||
``url`` and ``download_url`` | ||
These become links on your project's PyPI page. EasyInstall will examine | ||
|
@@ -1590,13 +1566,12 @@ tagging the release, so the trunk will still produce development snapshots. | |
Alternately, if you are not branching for releases, you can override the | ||
default version options on the command line, using something like:: | ||
|
||
python setup.py egg_info -Db "" sdist bdist_egg register upload | ||
python setup.py egg_info -Db "" sdist bdist_egg | ||
|
||
The first part of this command (``egg_info -Db ""``) will override the | ||
configured tag information, before creating source and binary eggs, registering | ||
the project with PyPI, and uploading the files. Thus, these commands will use | ||
the plain version from your ``setup.py``, without adding the build designation | ||
string. | ||
configured tag information, before creating source and binary eggs. Thus, these | ||
commands will use the plain version from your ``setup.py``, without adding the | ||
build designation string. | ||
|
||
Of course, if you will be doing this a lot, you may wish to create a personal | ||
alias for this operation, e.g.:: | ||
|
@@ -1605,7 +1580,7 @@ alias for this operation, e.g.:: | |
|
||
You can then use it like this:: | ||
|
||
python setup.py release sdist bdist_egg register upload | ||
python setup.py release sdist bdist_egg | ||
|
||
Or of course you can create more elaborate aliases that do all of the above. | ||
See the sections below on the `egg_info`_ and `alias`_ commands for more ideas. | ||
|
@@ -1921,11 +1896,11 @@ This command performs two operations: it updates a project's ``.egg-info`` | |
metadata directory (used by the ``bdist_egg``, ``develop``, and ``test`` | ||
commands), and it allows you to temporarily change a project's version string, | ||
to support "daily builds" or "snapshot" releases. It is run automatically by | ||
the ``sdist``, ``bdist_egg``, ``develop``, ``register``, and ``test`` commands | ||
in order to update the project's metadata, but you can also specify it | ||
explicitly in order to temporarily change the project's version string while | ||
executing other commands. (It also generates the``.egg-info/SOURCES.txt`` | ||
manifest file, which is used when you are building source distributions.) | ||
the ``sdist``, ``bdist_egg``, ``develop``, and ``test`` commands in order to | ||
update the project's metadata, but you can also specify it explicitly in order | ||
to temporarily change the project's version string while executing other | ||
commands. (It also generates the``.egg-info/SOURCES.txt`` manifest file, which | ||
is used when you are building source distributions.) | ||
|
||
In addition to writing the core egg metadata defined by ``setuptools`` and | ||
required by ``pkg_resources``, this command can be extended to write other | ||
|
@@ -1999,10 +1974,10 @@ Creating a dated "nightly build" snapshot egg:: | |
|
||
python setup.py egg_info --tag-date --tag-build=DEV bdist_egg | ||
|
||
Creating and uploading a release with no version tags, even if some default | ||
tags are specified in ``setup.cfg``:: | ||
Creating a release with no version tags, even if some default tags are | ||
specified in ``setup.cfg``:: | ||
|
||
python setup.py egg_info -RDb "" sdist bdist_egg register upload | ||
python setup.py egg_info -RDb "" sdist bdist_egg | ||
|
||
(Notice that ``egg_info`` must always appear on the command line *before* any | ||
commands that you want the version changes to apply to.) | ||
|
@@ -2251,25 +2226,16 @@ available: | |
``upload`` - Upload source and/or egg distributions to PyPI | ||
=========================================================== | ||
|
||
.. warning:: | ||
**upload** is deprecated in favor of using `twine | ||
<https://pypi.org/p/twine>`_ | ||
|
||
The ``upload`` command is implemented and `documented | ||
<https://docs.python.org/3.1/distutils/uploading.html>`_ | ||
in distutils. | ||
|
||
Setuptools augments the ``upload`` command with support | ||
for `keyring <https://pypi.org/project/keyring/>`_, | ||
allowing the password to be stored in a secure | ||
location and not in plaintext in the .pypirc file. To use | ||
keyring, first install keyring and set the password for | ||
the relevant repository, e.g.:: | ||
|
||
python -m keyring set <repository> <username> | ||
Password for '<username>' in '<repository>': ******** | ||
|
||
Then, in .pypirc, set the repository configuration as normal, | ||
but omit the password. Thereafter, uploads will use the | ||
password from the keyring. | ||
|
||
New in 20.1: Added keyring support. | ||
New in 40.0: Deprecated the upload command. | ||
|
||
|
||
----------------------------------------- | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,18 @@ | ||
from distutils import log | ||
import distutils.command.register as orig | ||
|
||
|
||
class register(orig.register): | ||
__doc__ = orig.register.__doc__ | ||
|
||
def run(self): | ||
# Make sure that we are using valid current name/version info | ||
self.run_command('egg_info') | ||
orig.register.run(self) | ||
try: | ||
# Make sure that we are using valid current name/version info | ||
self.run_command('egg_info') | ||
orig.register.run(self) | ||
finally: | ||
self.announce( | ||
"WARNING: Registering is deprecated, use twine to " | ||
"upload instead (https://pypi.org/p/twine/)", | ||
log.WARN | ||
) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import mock | ||
from distutils import log | ||
|
||
import pytest | ||
|
||
from setuptools.command.register import register | ||
from setuptools.dist import Distribution | ||
|
||
|
||
class TestRegisterTest: | ||
def test_warns_deprecation(self): | ||
dist = Distribution() | ||
|
||
cmd = register(dist) | ||
cmd.run_command = mock.Mock() | ||
cmd.send_metadata = mock.Mock() | ||
cmd.announce = mock.Mock() | ||
|
||
cmd.run() | ||
|
||
cmd.announce.assert_called_once_with( | ||
"WARNING: Registering is deprecated, use twine to upload instead " | ||
"(https://pypi.org/p/twine/)", | ||
log.WARN | ||
) | ||
|
||
def test_warns_deprecation_when_raising(self): | ||
dist = Distribution() | ||
|
||
cmd = register(dist) | ||
cmd.run_command = mock.Mock() | ||
cmd.send_metadata = mock.Mock() | ||
cmd.send_metadata.side_effect = Exception | ||
cmd.announce = mock.Mock() | ||
|
||
with pytest.raises(Exception): | ||
cmd.run() | ||
|
||
cmd.announce.assert_called_once_with( | ||
"WARNING: Registering is deprecated, use twine to upload instead " | ||
"(https://pypi.org/p/twine/)", | ||
log.WARN | ||
) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import mock | ||
from distutils import log | ||
|
||
import pytest | ||
|
||
from setuptools.command.upload import upload | ||
from setuptools.dist import Distribution | ||
|
||
|
||
class TestUploadTest: | ||
def test_warns_deprecation(self): | ||
dist = Distribution() | ||
dist.dist_files = [(mock.Mock(), mock.Mock(), mock.Mock())] | ||
|
||
cmd = upload(dist) | ||
cmd.upload_file = mock.Mock() | ||
cmd.announce = mock.Mock() | ||
|
||
cmd.run() | ||
|
||
cmd.announce.assert_called_once_with( | ||
"WARNING: Uploading via this command is deprecated, use twine to " | ||
"upload instead (https://pypi.org/p/twine/)", | ||
log.WARN | ||
) | ||
|
||
def test_warns_deprecation_when_raising(self): | ||
dist = Distribution() | ||
dist.dist_files = [(mock.Mock(), mock.Mock(), mock.Mock())] | ||
|
||
cmd = upload(dist) | ||
cmd.upload_file = mock.Mock() | ||
cmd.upload_file.side_effect = Exception | ||
cmd.announce = mock.Mock() | ||
|
||
with pytest.raises(Exception): | ||
cmd.run() | ||
|
||
cmd.announce.assert_called_once_with( | ||
"WARNING: Uploading via this command is deprecated, use twine to " | ||
"upload instead (https://pypi.org/p/twine/)", | ||
log.WARN | ||
) |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@pganssle Since there was a
40.0
release last night, we'll need to tweak this line before releasing. I took a guess at what version this would land in, but seeing as it's a minor change, this should probably be40.1
.