# 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
```
twine upload dist/*
```
### References
https://packaging.python.org/tutorials/packaging-projects/
Raw data
{
"_id": null,
"home_page": "https://github.com/pypa/sampleproject",
"name": "tes-gan",
"maintainer": "",
"docs_url": null,
"requires_python": ">=3.6",
"maintainer_email": "",
"keywords": "",
"author": "tes_gan",
"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```\ntwine upload 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.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": "91ff281cbf4e2eb45653f0864726c793b43aceef7c1b8298bb68b7943278ce27",
"md5": "8116c00524e4ab5a4a77d6e3c7e9b884",
"sha256": "72df68f9ad9410b2f2e0a8e6db10d43f751f4fbfa8ba1412f06d70565723332e"
},
"downloads": -1,
"filename": "tes_gan-0.0.1-py3-none-any.whl",
"has_sig": false,
"md5_digest": "8116c00524e4ab5a4a77d6e3c7e9b884",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.6",
"size": 21880,
"upload_time": "2023-11-09T11:10:24",
"upload_time_iso_8601": "2023-11-09T11:10:24.523278Z",
"url": "https://files.pythonhosted.org/packages/91/ff/281cbf4e2eb45653f0864726c793b43aceef7c1b8298bb68b7943278ce27/tes_gan-0.0.1-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-11-09 11:10:24",
"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": "tes-gan"
}