Skip to main content

It's a MVP of Python packaging

Project description

Installation

Distribution

Run python setup.py sdist to generate the source distribution, where egg and dist directories would be created.

To create the wheel distribution, package "wheel" is necessary. Then run python setup.py bdist_wheel to generate distribution files. Check build to verify if all modules and files needed for the distribution are included.

Both distributions have egg and dist directory. Though files inside egg are the same, distribution via sdist is a tar file, while that via bdist_wheel is a wheel file. Moreover, the wheel one includes build directory.

Note that previous generated distribution would exist, so manual removal may be needed.

Local

To quickly test whether the configuration of "setup.py" is correct, simply run pip install -e . under this root project directory.

To install extra needed packages specified, run pip install ".[extra]" (double quote is recommended in case some other shells like zsh fail to recognize).

Remote

Upload

Normally, file "$HOME/.pypirc" would be used to define the configuration. Below is the usual format:

[distutils]
  index-servers =
    default-repo
    testing-repo

[default-repo]
  repository = https://upload.pypi.org/legacy/
  username = {username}
  password = {password}

[testing-repo]
  repository = https://test.pypi.org/legacy/
  username = {username}
  password = {password}

Be cautious that "[distutils]" is mandatory for uploading to repository.

Looks like the API token mechanism in both official "pypi" repo are not working as expected, the password should use the actual password since API token doesn't work.

When the configuration is done, command python setup.py bdist_wheel upload -r default-repo would build the distribution and upload to the specified repo directly.

However, it's recommended to apply twine to take of the uploading. After the distribution is generated, run python -m twine upload --repository {repo} dist/* to upload. For this way, the process of distribution generation and uploading are separate, which is more manageable.

Download

Similar to the uploading, file "$HOME/.pip/pip.conf" is the one for downloading configuration:

[global]
  index-url =
    https://pypi.org/simple/

[install]
  index-url = https://test.pypi.org/simple/
  extra-index-url =
    {repo_1}
    {repo_2}

When it comes to download a package from a repo, it's worth to mention that there is certain config precedence (command line > environment variable > configuration in ""). In that case, pip install would look for the configuration following the precedence to download and install the package specified.

So be aware of there is no environment variables like PIP_INDEX_URL or PIP_EXTRA_INDEX_URL if you want the configuration file to take effect.

As long as the package is uploaded and the downloading configuration is properly set, then simply run pip install "{package[extra]}" would do the work. Otherwise, run pip install --index-url {repo} {package} to ensure the repo is correct.

Demo

Run codes below for demo to see if the package is function:

import caller as demo
from caller import Fruit

demo.entry.main()

fruit = Fruit()
fruit.printing()

Reference

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

packagingxx-0.0.1-py3-none-any.whl (4.1 kB view details)

Uploaded Python 3

File details

Details for the file packagingxx-0.0.1-py3-none-any.whl.

File metadata

  • Download URL: packagingxx-0.0.1-py3-none-any.whl
  • Upload date:
  • Size: 4.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.25.0 setuptools/50.3.2 requests-toolbelt/0.9.1 tqdm/4.51.0 CPython/3.8.5

File hashes

Hashes for packagingxx-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 b05d2c4c2c88b391fae35e39ea57d712f04bd7c6fffe79717c499d395408ee65
MD5 ef827ca780e6232959f69115d84230dd
BLAKE2b-256 5e66596ec119b75cf4d83399869f03dd99ddc1434882ec551e4a46561b6a83a3

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page