Medium multiply
A small demo library for a Medium publication about publishing libraries.
Installation
pip install projectname
if we upload the package to PyPI. Otherwise, we can install it from a local directory:
pip install -e .
The flag -e stands for editable, which means that if we make changes to the code, we don’t need to reinstall the package. This is for the dev process. For prod, we can just install the package without the -e flag.
Essence
The current Python logic is still valid. To create a Python library, we need to be aware of some additional knowledge.
- Create an empty file called
setup.py. This is one of the most important files when creating a Python library! Additionally, we needpyproject.tomlfile to specify how we build the library. And we use thebuildlibrary andpython -m buildto build the library. - Create an empty file called
README.md. This is the place where you can write markdown to describe the contents of your library for other users. - Create a folder called
mypythonlib, or whatever you want your Python library to be called when you pip install it. (The name should be unique on pip if you want to publish it later.) How to check the uniqueness? Just search for the name on pip. If it’s not there, you’re good to go. - Create an empty file inside mypythonlib that is called
__init__.py. Basically, any folder that has an__init__.pyfile in it, will be included in the library when we build it. Most of the time, you can leave the__init__.pyfiles empty. Upon import, the code within__init__.pygets executed, so it should contain only the minimal amount of code that is needed to be able to run your project. For now, we will leave them as is. - Create functional code in the folder where
__init__.pyis located. - Finally, create a folder tests in your root folder. Inside, create an empty init.py file. Add some empty file as you want. If we wish to compile the code into a library, we have to make sure the code is robust. And the test is necessary. If you want to use the test, just install
pytestandpytest-runner. Then, runpython setup.py pytestto run the all the tests in the tests folder.
After build, I have a dist folder, and we have a package with .whl and .tar.gz files. We can install the package with pip install mypythonlib-0.0.1-py3-none-any.whl or pip install mypythonlib-0.0.1.tar.gz.
Metadata
Release files for nexatestlib 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| nexatestlib-0.1.0.tar.gz | 2.9 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| nexatestlib-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 5.6 kB
Release files / nexatestlib-0.1.0.tar.gz
| Download URL | nexatestlib-0.1.0.tar.gz |
|---|---|
| Size | 2.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
69994b705fc98b536b4a56815dbe7bba7ca8dc71657378504ba2e353ed2597c3
|
|
BLAKE2b-256 checksum How to use checksums |
c9887b00a06865da8c70b8630cb4ac6dc78f14327247032f875c4032cadb56ad
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.10.12
|
Release files / nexatestlib-0.1.0-py3-none-any.whl
| Download URL | nexatestlib-0.1.0-py3-none-any.whl |
|---|---|
| Size | 2.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
7d364491612c06cd34377d687f8b6e923c7dbeccae122097c318c2bd22567628
|
|
BLAKE2b-256 checksum How to use checksums |
3e941fe4df0272faa8ae2ebbaa2da5ee90eaaf116404512d1145908c207d3155
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.10.12
|