| Name | pck-brendan JSON |
| Version |
0.0.1
JSON |
| download |
| home_page | |
| Summary | A small example package |
| upload_time | 2023-11-06 04:08:57 |
| maintainer | |
| docs_url | None |
| author | |
| requires_python | >=3.7 |
| license | |
| keywords |
|
| VCS |
 |
| bugtrack_url |
|
| requirements |
No requirements were recorded.
|
| Travis-CI |
No Travis.
|
| coveralls test coverage |
No coveralls.
|
# Overview
The goal of this activity is to introduce you to python's packaging system called **PyPi** (Python Package Index). **PyPi** maintains a directory service for contributed packages that is accessible by **pip** whenever the tool is used to install a new package.
# Instructions
Begin by creating a folder for your package under **src**. Because the name of your package has to be unique, add your name as a suffix for your package name.
```
src/pck_<your_name>
```
Next, create the following file structure for your package.
```
src
|__pck_<your_name>
|__ __init__.py
|__ mod.py
test.py
README.md
pyproject.toml
```
Leave **__init__.py** blank. **__init__.py** is required to import the directory as a package, and can be empty.
Add the following code in **mod.py**, which will be the single module in your package.
```
def add_one(number):
return number + 1
```
Add the following code in **test.py**. It will not be a proper test, just a validation that the package can be properly imported and used.
```
from pck_<your_name> import mod
print(mod.add_one(5))
```
After the validation, add the following in **pyproject.toml**, making sure to update <your_name>.
```
[build-system]
requires = ["hatchling"]
build-backend = "hatchling.build"
[project]
name = "pck_<your_name>"
version = "0.0.1"
authors = [
{ name="Example Author", email="author@example.com" },
]
description = "A small example package"
readme = "README.md"
requires-python = ">=3.7"
classifiers = [
"Programming Language :: Python :: 3",
"License :: OSI Approved :: MIT License",
"Operating System :: OS Independent",
]
[project.urls]
"Homepage" = "https://github.com/pypa/sampleproject"
"Bug Tracker" = "https://github.com/pypa/sampleproject/issues"
```
Write something about your project in **README.md** (it cannot be left blank).
```
This is a test project to learn something new. Added it here instead of creating a new read me.
```
Next, try to build your project (from **src**) using:
```
python3 -m build
```
If you get an error saying "No module named build" it means that you need to install build using pip3.
After the build, a **dist** folder will be created.
Next, it is time to publish your package so others can use. You need an account in [https://pypi.org/](https://pypi.org/). Then, go to [https://pypi.org/manage/account/](https://pypi.org/manage/account/) and scroll down so you can click on the "Add API token" button. Give your token a name and select "Entire account (all projects)" as the scope. Copy the token and use it to run the following:
```
python3 -m twine upload -u __token__ -p <replace with your token> dist/*
```
You can repeat this process multiple times if needed. For example, you may want to update your package. To do that, update the version of your package in **pyproject.toml**. Next, remove the **dist** folder and rebuild. Finally, upload the new version.
To test the installation and use of your package from PyPi, create a virtual environment and copy **test.py** and see if you can run it.
# More Information
**PyPi** user guide is available [here](https://packaging.python.org/en/latest/tutorials/packaging-projects/).
Raw data
{
"_id": null,
"home_page": "",
"name": "pck-brendan",
"maintainer": "",
"docs_url": null,
"requires_python": ">=3.7",
"maintainer_email": "",
"keywords": "",
"author": "",
"author_email": "Example Author <author@example.com>",
"download_url": "https://files.pythonhosted.org/packages/c6/12/3dde90e1dc2b4e5002b476f3cfdb5f201c56862ed86ba65d5e71de12fbf3/pck_brendan-0.0.1.tar.gz",
"platform": null,
"description": "# Overview\n\nThe goal of this activity is to introduce you to python's packaging system called **PyPi** (Python Package Index). **PyPi** maintains a directory service for contributed packages that is accessible by **pip** whenever the tool is used to install a new package. \n\n# Instructions\n\nBegin by creating a folder for your package under **src**. Because the name of your package has to be unique, add your name as a suffix for your package name. \n\n```\nsrc/pck_<your_name>\n```\n\nNext, create the following file structure for your package. \n\n```\nsrc\n|__pck_<your_name>\n |__ __init__.py\n |__ mod.py\ntest.py\nREADME.md\npyproject.toml\n```\n\nLeave **__init__.py** blank. **__init__.py** is required to import the directory as a package, and can be empty.\n\nAdd the following code in **mod.py**, which will be the single module in your package. \n\n```\ndef add_one(number):\n return number + 1\n```\n\nAdd the following code in **test.py**. It will not be a proper test, just a validation that the package can be properly imported and used. \n\n```\nfrom pck_<your_name> import mod\n\nprint(mod.add_one(5))\n```\n\nAfter the validation, add the following in **pyproject.toml**, making sure to update <your_name>. \n\n```\n[build-system]\nrequires = [\"hatchling\"]\nbuild-backend = \"hatchling.build\"\n\n[project]\nname = \"pck_<your_name>\"\nversion = \"0.0.1\"\nauthors = [\n { name=\"Example Author\", email=\"author@example.com\" },\n]\ndescription = \"A small example package\"\nreadme = \"README.md\"\nrequires-python = \">=3.7\"\nclassifiers = [\n \"Programming Language :: Python :: 3\",\n \"License :: OSI Approved :: MIT License\",\n \"Operating System :: OS Independent\",\n]\n\n[project.urls]\n\"Homepage\" = \"https://github.com/pypa/sampleproject\"\n\"Bug Tracker\" = \"https://github.com/pypa/sampleproject/issues\"\n```\n\nWrite something about your project in **README.md** (it cannot be left blank). \n```\nThis is a test project to learn something new. Added it here instead of creating a new read me.\n```\n\nNext, try to build your project (from **src**) using: \n\n```\npython3 -m build\n```\n\nIf you get an error saying \"No module named build\" it means that you need to install build using pip3. \n\nAfter the build, a **dist** folder will be created.\n\nNext, it is time to publish your package so others can use. You need an account in [https://pypi.org/](https://pypi.org/). Then, go to [https://pypi.org/manage/account/](https://pypi.org/manage/account/) and scroll down so you can click on the \"Add API token\" button. Give your token a name and select \"Entire account (all projects)\" as the scope. Copy the token and use it to run the following: \n\n```\npython3 -m twine upload -u __token__ -p <replace with your token> dist/*\n```\n\nYou can repeat this process multiple times if needed. For example, you may want to update your package. To do that, update the version of your package in **pyproject.toml**. Next, remove the **dist** folder and rebuild. Finally, upload the new version. \n\nTo test the installation and use of your package from PyPi, create a virtual environment and copy **test.py** and see if you can run it. \n\n# More Information\n\n**PyPi** user guide is available [here](https://packaging.python.org/en/latest/tutorials/packaging-projects/). ",
"bugtrack_url": null,
"license": "",
"summary": "A small example package",
"version": "0.0.1",
"project_urls": {
"Bug Tracker": "https://github.com/pypa/sampleproject/issues",
"Homepage": "https://github.com/pypa/sampleproject"
},
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "f3bd79d0972e37b31eef18322ba7a5035d122eb171fda93ceba39186b7555101",
"md5": "0846981be624169ebe6c542819184e06",
"sha256": "99f6b601101555eeb568688c8700506fd88b96914b204a3765c510e4672f79c4"
},
"downloads": -1,
"filename": "pck_brendan-0.0.1-py3-none-any.whl",
"has_sig": false,
"md5_digest": "0846981be624169ebe6c542819184e06",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.7",
"size": 2707,
"upload_time": "2023-11-06T04:08:56",
"upload_time_iso_8601": "2023-11-06T04:08:56.695621Z",
"url": "https://files.pythonhosted.org/packages/f3/bd/79d0972e37b31eef18322ba7a5035d122eb171fda93ceba39186b7555101/pck_brendan-0.0.1-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "c6123dde90e1dc2b4e5002b476f3cfdb5f201c56862ed86ba65d5e71de12fbf3",
"md5": "7a079cb11ff42ca4794f1f4b23123abd",
"sha256": "5efd7fa3ea4712d6a6cbb8a2e91c4afb959d453e16bac06ae581316f365162f6"
},
"downloads": -1,
"filename": "pck_brendan-0.0.1.tar.gz",
"has_sig": false,
"md5_digest": "7a079cb11ff42ca4794f1f4b23123abd",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.7",
"size": 2177,
"upload_time": "2023-11-06T04:08:57",
"upload_time_iso_8601": "2023-11-06T04:08:57.975695Z",
"url": "https://files.pythonhosted.org/packages/c6/12/3dde90e1dc2b4e5002b476f3cfdb5f201c56862ed86ba65d5e71de12fbf3/pck_brendan-0.0.1.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-11-06 04:08:57",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "pypa",
"github_project": "sampleproject",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"tox": true,
"lcname": "pck-brendan"
}