Skip to main content

This package does amazing things.

Project description

Learn how to develop your own Python Package 📦 - Hi! PARIS Summer School 2023

In this practical research tips session hosted by the Hi! PARIS Engineering Team, you will learn how to build, test and publish Python packages.

This repository contains the code of the python package that was built during the session, as well as the terminal commands used during demos.

This package uses scripts from the LowRankDensity python package developed by the Hi! PARIS Engineering Team.
You can find the LowRankDensity package here: https://github.com/hi-paris/Lowrankdensity


Demo 1: Build your package locally 💻

1. Create a virtual environment with venv

Virtual environments allow you to create isolated environments for different projects, ensuring that each project has its own set of dependencies/libraries.

python -m venv <venv-name>

This command will create a virtual environment folder in the directory you are currently in.

2. Activate the virtual environment

Now that you have created the virtual environment, you need to activate it using the following command.

path\to\venv\<venv-name>\Scripts\activate

3. Install the build library

Build is a Python packaging build frontend library. It will generate the distribution packages of our package.

pip install build

4. Build your project

Run the following command in your terminal to build the distribution packages. This command will generate a dist folder with .whl and .gz files.

pyproject-build

5. Install your package locally

Use pip install to install the package on your computer from the .whl file.

pip install ./dist/<whl-file>

Additional ressources:


Demo 2: Test your package with pytest 🧪

1. Install test and code coverage packages

pip install pytest, pytest-cov

These packages should be installed in your virtual environment. You can check which packages are already installed using pip list.

2. Run tests on your package with pytest

pytest

Pytest will directly identify your package’s test files if they follow pytest’s naming convention.

3. Run code coverage with pytest-cov

pytest --cov

Additional ressources:


Demo 3: Git commands and Github ⌨️

1. Create a public repository on github

https://github.com/

2. Clone the github repository to a folder

Git clone: Download the existing source code from a remote repository

git clone <HTTPS-key>

3. Push modifications to your repository with git commands

Github workflow:

  1. Git status: Check the status of your modifications. With this git command, you can track which file/folder you’ve modified in the repository.
git status
  1. Git add: Add changes to the staging area.
git add . # add all modifications to the stagging area
git add <file-directory> # chose a file/folder to add the stagging area
  1. Git commit: Commit the modifications from a staging area to your local repository. Add a message with git commit to inform other contributors what has been modified on the repository.
git commit -m "message"
  1. Git push: Push the commited modifications to the remote repository. This will update the github repository with the modifications you’ve made on your local repository.
git push

If there are many contributors on your projects, you can also create branches to facilitate collaborative development. Branches create seperate versions of the main repository. Each contributor can create their own branch, work on their specific task, and later merge their changes back into the main branch.

git branch <name_branch> # create a branch
git merge main # merge modifications from remote branch to the main repository

Additional ressources:


Demo 4: Github actions + Package publishing ♻️

Github actions can be triggered by many types of git commands. We used git push in the demo. Everytime a contributor pushes new code onto the remote repository, github actions will build and test the package on different operating systems.

1. Create an account on PyPi

PyPi is a repository of software for the Python programming language.

https://pypi.org/

2. Install twine

Twine allows you to publish Python packages to PyPI and other repositories.

pip install twine

3. Publish your package to PyPi with twine

twine upload dist/*

The package’s will be published using the information in the setup.cfg file under [metadata]. In this demo, we published a package named lowrankdensity_demo in it’s 0.0.2 version.

Additional ressources:

git-demo

Project details


Download files

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

Source Distribution

lowrankdensity_demo_ss_2025-0.0.3.tar.gz (15.0 kB view details)

Uploaded Source

Built Distribution

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

lowrankdensity_demo_ss_2025-0.0.3-py3-none-any.whl (11.5 kB view details)

Uploaded Python 3

File details

Details for the file lowrankdensity_demo_ss_2025-0.0.3.tar.gz.

File metadata

File hashes

Hashes for lowrankdensity_demo_ss_2025-0.0.3.tar.gz
Algorithm Hash digest
SHA256 15fe205359903d1f32a78a0187f09437031945d092b327fe8788bf11f261592d
MD5 5791b14815e4a913335ef32f1c30aad0
BLAKE2b-256 16d7dfb895416825fd863ae3e36042ff8ea21548b6f2bdfa72b73b8648c2b31d

See more details on using hashes here.

File details

Details for the file lowrankdensity_demo_ss_2025-0.0.3-py3-none-any.whl.

File metadata

File hashes

Hashes for lowrankdensity_demo_ss_2025-0.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 35eb2613024215f994f9ba331b9e08ee5e68b808ef02f2860697bcccb05477d8
MD5 9e352ba93578bbe44acbfae0d6ec7583
BLAKE2b-256 7874dbc7dead8769bc8e8532c6457c924e85e080b9e25333bef89a93fe70ef29

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