# Make sure you have upgraded version of pip
Windows
```
py -m pip install --upgrade pip
```
Linux/MAC OS
```
python3 -m pip install --upgrade pip
```
## Create a project with the following structure
```
packaging_tutorial/
├── LICENSE
├── pyproject.toml
├── README.md
├── setup.cfg
├── src/
│ └── example_package/
│ ├── __init__.py
│ └── example.py
└── tests/
touch LICENSE
touch pyproject.toml
touch setup.cfg
mkdir src/mypackage
touch src/mypackage/__init__.py
touch src/mypackage/main.py
mkdir tests
```
## pyproject.toml
This file tells tools like pip and build how to create your project
```
[build-system]
requires = [
"setuptools>=42",
"wheel"
]
build-backend = "setuptools.build_meta"
```
build-system.requires gives a list of packages that are needed to build your package. Listing something here will only make it available during the build, not after it is installed.
build-system.build-backend is the name of Python object that will be used to perform the build. If you were to use a different build system, such as flit or poetry, those would go here, and the configuration details would be completely different than the setuptools configuration described below.
# Setup.cfg setup
Using setup.cfg is a best practice, but you could have a dynamic setup file using setup.py
```
[metadata]
name = example-pkg-YOUR-USERNAME-HERE
version = 0.0.1
author = Example Author
author_email = author@example.com
description = A small example package
long_description = file: README.md
long_description_content_type = text/markdown
url = https://github.com/pypa/sampleproject
project_urls =
Bug Tracker = https://github.com/pypa/sampleproject/issues
classifiers =
Programming Language :: Python :: 3
License :: OSI Approved :: MIT License
Operating System :: OS Independent
[options]
package_dir =
= src
packages = find:
python_requires = >=3.6
[options.packages.find]
where = src
```
# Running the build
### Make sure your build tool is up to date
Windows
```
py -m pip install --upgrade build
```
Linux/MAC OS
```
python3 -m pip install --upgrade build
```
### Create the build
```
py -m build
```
### Upload to pypi
```
python3.9 -m twine upload --repository cobapypi dist/*
```
### References
https://packaging.python.org/tutorials/packaging-projects/
Raw data
{
"_id": null,
"home_page": "https://github.com/pypa/sampleproject",
"name": "dhea-dheo",
"maintainer": "",
"docs_url": null,
"requires_python": ">=3.6",
"maintainer_email": "",
"keywords": "",
"author": "dhea-dheo",
"author_email": "dki.hadihermawan@gmail.com",
"download_url": "",
"platform": null,
"description": "\n# Make sure you have upgraded version of pip\nWindows\n```\npy -m pip install --upgrade pip\n```\n\nLinux/MAC OS\n```\npython3 -m pip install --upgrade pip\n```\n\n## Create a project with the following structure\n```\npackaging_tutorial/\n\u251c\u2500\u2500 LICENSE\n\u251c\u2500\u2500 pyproject.toml\n\u251c\u2500\u2500 README.md\n\u251c\u2500\u2500 setup.cfg\n\u251c\u2500\u2500 src/\n\u2502 \u2514\u2500\u2500 example_package/\n\u2502 \u251c\u2500\u2500 __init__.py\n\u2502 \u2514\u2500\u2500 example.py\n\u2514\u2500\u2500 tests/\ntouch LICENSE\ntouch pyproject.toml\ntouch setup.cfg\nmkdir src/mypackage\ntouch src/mypackage/__init__.py\ntouch src/mypackage/main.py\nmkdir tests\n```\n\n## pyproject.toml \n\nThis file tells tools like pip and build how to create your project\n\n```\n[build-system]\nrequires = [\n \"setuptools>=42\",\n \"wheel\"\n]\nbuild-backend = \"setuptools.build_meta\"\n```\nbuild-system.requires gives a list of packages that are needed to build your package. Listing something here will only make it available during the build, not after it is installed.\n\nbuild-system.build-backend is the name of Python object that will be used to perform the build. If you were to use a different build system, such as flit or poetry, those would go here, and the configuration details would be completely different than the setuptools configuration described below.\n\n\n# Setup.cfg setup\nUsing setup.cfg is a best practice, but you could have a dynamic setup file using setup.py\n\n```\n[metadata]\nname = example-pkg-YOUR-USERNAME-HERE\nversion = 0.0.1\nauthor = Example Author\nauthor_email = author@example.com\ndescription = A small example package\nlong_description = file: README.md\nlong_description_content_type = text/markdown\nurl = https://github.com/pypa/sampleproject\nproject_urls =\n Bug Tracker = https://github.com/pypa/sampleproject/issues\nclassifiers =\n Programming Language :: Python :: 3\n License :: OSI Approved :: MIT License\n Operating System :: OS Independent\n\n[options]\npackage_dir =\n = src\npackages = find:\npython_requires = >=3.6\n\n[options.packages.find]\nwhere = src\n\n```\n# Running the build\n### Make sure your build tool is up to date\nWindows\n```\npy -m pip install --upgrade build\n```\nLinux/MAC OS\n```\npython3 -m pip install --upgrade build\n```\n\n\n### Create the build\n```\npy -m build\n```\n\n### Upload to pypi\n```\npython3.9 -m twine upload --repository cobapypi dist/*\n```\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n### References\nhttps://packaging.python.org/tutorials/packaging-projects/\n",
"bugtrack_url": null,
"license": "",
"summary": "A small example package",
"version": "0.0.2",
"project_urls": {
"Bug Tracker": "https://github.com/pypa/sampleproject/issues",
"Homepage": "https://github.com/pypa/sampleproject"
},
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "b28f1e72a39cbe650b1aab840b3be348767b470024b931ee32dde060385b3359",
"md5": "69928239e7e414c4c2212ce484fc0317",
"sha256": "fd9d581363925fb5ec988983d405d6bbf3cee6cc864eb12e30785d8d81d4fb46"
},
"downloads": -1,
"filename": "dhea_dheo-0.0.2-py3-none-any.whl",
"has_sig": false,
"md5_digest": "69928239e7e414c4c2212ce484fc0317",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.6",
"size": 2706,
"upload_time": "2023-10-29T19:00:05",
"upload_time_iso_8601": "2023-10-29T19:00:05.813035Z",
"url": "https://files.pythonhosted.org/packages/b2/8f/1e72a39cbe650b1aab840b3be348767b470024b931ee32dde060385b3359/dhea_dheo-0.0.2-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-10-29 19:00:05",
"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": "dhea-dheo"
}