Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>It's strange that there isn't built-in support for setting a default, but here are two options which may help you work around it.</p> <p><strong>Option 1:</strong> Probably the simplest solution would be to leave your <strong>~/.pypirc</strong> script intact and create shell aliases for your internal and public uploads. This may give you more control over customizing things for your workflow.</p> <p>Given this <strong>.pypirc</strong> file: </p> <pre><code>[distutils] index-servers = pypi internal [pypi] repository: http://pypi.python.org/pypi username: brad password: &lt;pass&gt; [internal] repository: http://localhost:8080 username: brad password: &lt;pass&gt; </code></pre> <p>Create some shell aliases (place these definitions in your shell's rcfile, e.g. <strong>~/.bashrc</strong>):</p> <pre><code>alias ppup_internal='python setup.py bdist_egg sdist upload -r internal' alias ppup_public='python setup.py bdist_egg sdist upload' </code></pre> <p>Usage:</p> <pre><code>% ppup_internal ... running upload Submitting dist/foo-0.0.0.tar.gz to http://localhost:8080 Server response (200): OK </code></pre> <hr> <p><strong>Option 2:</strong> A hack: you can work around the default by patching the default repository name at the top of your setup.py scripts. </p> <pre><code>from distutils import config config.PyPIRCCommand.DEFAULT_REPOSITORY = 'internal' from setuptools import setup setup( name='foo', ... </code></pre> <p>Output:</p> <pre><code>% python setup.py sdist upload ... running upload Submitting dist/foo-0.0.0.tar.gz to http://localhost:8080 Server response (200): OK % python setup.py sdist upload -r pypi ... running upload Submitting dist/foo-0.0.0.tar.gz to http://pypi.python.org/pypi Server response (200): OK </code></pre> <hr> <p><strong>Background:</strong> If you define the <strong>[distutils]</strong> key in <strong>.pypirc</strong>, the upload command defaults to the <strong>pypi url</strong> when the <strong>-r [repo]</strong> argument is omitted. The relevant code is in <strong>distutils.config.PyPIRCCommand</strong>:</p> <pre><code>class PyPIRCCommand(Command): DEFAULT_REPOSITORY = 'http://pypi.python.org/pypi' def _read_pypirc(self): if os.path.exists(rc): self.announce('Using PyPI login from %s' % rc) repository = self.repository or self.DEFAULT_REPOSITORY realm = self.realm or self.DEFAULT_REALM </code></pre> <p>The old format of <strong>.pypirc</strong> expected a <strong>[server-login]</strong> section, which was far less flexible since it only defines a single target repository. This isn't a workable option since the <strong>[pypi]</strong> section below will be unusable:</p> <pre><code>[server-login] repository: http://localhost:8080 username: brad password: &lt;pass&gt; [pypi] repository: http://pypi.python.org/pypi username: brad password: &lt;pass&gt; </code></pre> <p>Now by default distutils will use this target:</p> <pre><code>% python setup.py sdist upload ... running upload Submitting dist/foo-0.0.0.tar.gz to http://localhost:8080 Server response (200): OK </code></pre> <p>But you can't access the any other repos: it silently defaults to the <strong>[server-login]</strong> properties:</p> <pre><code>% python setup.py sdist upload -r pypi ... running upload Submitting dist/foo-0.0.0.tar.gz to http://localhost:8080 Server response (200): OK </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload