Coder Social home page Coder Social logo

ranboardom's Introduction

Publishing a python package to TestPypi

This project serves as an example for building a python package and uploading to TestPyPi. See instructions below for a step-by-step guide on how to achieve this.

Package installation

After creating your own environment, use

pip install ranboardom

Package usage

import ranboardom as rb

rb.board()

Which outputs something like this without any function arguments:

[['e' '"' '*' '<' '*']
 ['*' '*' 'h' '*' '*']
 ['*' '*' 'o' '*' '*']
 ['7' '$' '*' '*' '*']
 ['*' 'w' '*' '*' '*']]

Guide for building and publishing this python package

  1. create a separate venv for poetry under the root_directory/venv for example

python -m venv venv/packaging

  1. activate environment

source venv/packaging/bin/activate

  1. install poetry, which will be used to build our code into a python package called ranboardom

pip install -U pip setuptools pip install poetry

  1. check installed version of poetry

poetry --version

  1. install the dependencies listed in pyproject.toml

poetry install

  1. test if the package was installed under the current environment

python -c "import ranboardom as rb; rb.board(10, 10, 'o')"

  1. to build the package use the following command in the root directory:

poetry build

  1. this creates a folder called dist/ with the wheel and sdist, either can be used to install the package using

cd dist pip install ranboardom-0.1.0-py3-none-any.whl

  1. we need to add TestPyPI to the list of repositories poetry knows abouy (only needed when publishing dummy or test releases)

poetry config repositories.test-pypi https://test.pypi.org/legacy/

  1. publish the built package to TestPyPi (this requries a token, which can be generated following this guide)

poetry publish -r test-pypi -u __token__ -p TOKEN_COMES_HERE

The repository is uploaded under here

  1. installing the package should be possible from any device and environment (to tell pip to search also on test pypi, we need the following flags):
pip install --index-url https://test.pypi.org/simple/ \
--extra-index-url https://pypi.org/simple \
ranboardom

--extra-index-url is used to let pip know that not all dependencies are located under test pypi, but rather look for them under pypi

Useful references

Complete guide for packaging your code is available here

ranboardom's People

Contributors

aron-bram avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.