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_summer_school_2025-0.0.3.tar.gz (15.1 kB view details)

Uploaded Source

Built Distribution

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

File details

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

File metadata

File hashes

Hashes for lowrankdensity_summer_school_2025-0.0.3.tar.gz
Algorithm Hash digest
SHA256 601d29600f83c671019ff744580eb48da45dc6853368766974c04fb049b5d8d8
MD5 b3297353afa4cbac77498255a371f8ec
BLAKE2b-256 81b6203e17d1a2ae5b557677be1f65839d70a5ad3a91329653feb5c40834b7de

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for lowrankdensity_summer_school_2025-0.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 5cc0c214f339a223a18206c0166e825dc790f52702bb6d5ffe2e0c2da9cd370f
MD5 9c2973466a0c159d26262bafc60bfabc
BLAKE2b-256 2198436775255bd2e0e7e9b6bef21cdd72a110282f071e3b9dd6190f21cd168d

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