Test project to see how packaging works on PyPI.
Project description
test_project_python
NOTE: substitute the alias you set for python
on your local machine for any commands below that call python
. Common aliases include python
, python3
, py3
, python3.x
, or py3.x
(where x
corresponds to the python minor release version of your installation).
This project contains a dummy python project to
- test how packaging works for python
- using the
setuptools
module- see the comments in the
setup.py
file for more references and information
- see the comments in the
- when uploading to https://test.pypi.org/ and/or https://pypi.org/
- references describing basic packaging information:
- references describing more advanced packaging capabilities:
- packaging.python.org landing page: Python Packaging User Guide
- maintained by Python Packaging Authority
- using the
Project Structure
Note that some of the files below are configuration/build/binary files auto-generated after running commands to set up the package locally, and are NOT included in the repo:
- the
python setup.py sdist
commands createsdist/test-project-python-0.0.2.tar.gz
test_project_python.egg-info
(and nested contents)
- the
python setup.py bdist_wheel
command createsbuild/bdist.OPERATINGSYSTEMNAME-moreoperatingsysteminfo
dist/test_project_python-0.0.2-py3-none-any.whl
build/lib/
(and nested contents)test_project_python.egg-info
(and nested contents)
- the
python -m pip install .
command createsbuild/bdist.OPERATINGSYSTEMNAME-moreoperatingsysteminfo
build/lib/
(and nested contents)test_project_python.egg-info
(and nested contents)
Also note that running python files as modules locally creates a __pycache__
directory and .pyc
file nested inside the __pycache__
directory (which were manually excluded from the structure below) for that corresponding module!
- note that this
- only happens when running
python3 -m path.to.module.name
- does NOT happen when running
python3 path/to/module/name.py
- only happens when running
(structure taken from the output of the tree
command run from the test-project/python
directory)
.
├── README.md
├── build
│ ├── bdist.OPERATINGSYSTEMNAME-moreoperatingsysteminfo
│ └── lib
│ ├── package_a
│ │ ├── __init__.py
│ │ ├── module_a.py
│ │ ├── module_b.py
│ │ ├── module_c.py
│ │ ├── module_d.py
│ │ ├── module_e.py
│ │ ├── subpackage_a
│ │ │ ├── __init__.py # this __init__.py module MUST exist for setuptools to *automatically* detect subpackage_a
│ │ │ ├── a.py
│ │ │ ├── b.py
│ │ │ ├── c.py
│ │ │ ├── d.py
│ │ │ └── e.py
│ │ ├── subpackage_b
│ │ │ ├── __init__.py # this __init__.py module MUST exist for setuptools to *automatically* detect subpackage_b
│ │ │ ├── a.py
│ │ │ ├── b.py
│ │ │ ├── c.py
│ │ │ ├── d.py
│ │ │ └── e.py
│ │ └── subpackage_c
│ │ ├── __init__.py # this __init__.py module MUST exist for setuptools to *automatically* detect subpackage_c
│ │ ├── a.py
│ │ ├── b.py
│ │ ├── c.py
│ │ ├── d.py
│ │ └── e.py
│ ├── package_b
│ │ ├── __init__.py
│ │ ├── module_a.py
│ │ ├── module_b.py
│ │ ├── module_c.py
│ │ ├── module_d.py
│ │ ├── module_e.py
│ │ ├── subpackage_a
│ │ │ ├── __init__.py # this __init__.py module MUST exist for setuptools to *automatically* detect subpackage_a
│ │ │ ├── a.py
│ │ │ ├── b.py
│ │ │ ├── c.py
│ │ │ ├── d.py
│ │ │ └── e.py
│ │ ├── subpackage_b
│ │ │ ├── __init__.py # this __init__.py module MUST exist for setuptools to *automatically* detect subpackage_b
│ │ │ ├── a.py
│ │ │ ├── b.py
│ │ │ ├── c.py
│ │ │ ├── d.py
│ │ │ └── e.py
│ │ └── subpackage_c
│ │ ├── __init__.py # this __init__.py module MUST exist for setuptools to *automatically* detect subpackage_c
│ │ ├── a.py
│ │ ├── b.py
│ │ ├── c.py
│ │ ├── d.py
│ │ └── e.py
│ ├── package_c
│ │ ├── __init__.py
│ │ ├── module_a.py
│ │ ├── module_b.py
│ │ ├── module_c.py
│ │ ├── module_d.py
│ │ ├── module_e.py
│ │ ├── subpackage_a
│ │ │ ├── __init__.py # this __init__.py module MUST exist for setuptools to *automatically* detect subpackage_a
│ │ │ ├── a.py
│ │ │ ├── b.py
│ │ │ ├── c.py
│ │ │ ├── d.py
│ │ │ └── e.py
│ │ ├── subpackage_b
│ │ │ ├── __init__.py # this __init__.py module MUST exist for setuptools to *automatically* detect subpackage_b
│ │ │ ├── a.py
│ │ │ ├── b.py
│ │ │ ├── c.py
│ │ │ ├── d.py
│ │ │ └── e.py
│ │ └── subpackage_c
│ │ ├── __init__.py # this __init__.py module MUST exist for setuptools to *automatically* detect subpackage_c
│ │ ├── a.py
│ │ ├── b.py
│ │ ├── c.py
│ │ ├── d.py
│ │ └── e.py
│ └── test_project_python
│ ├── __init__.py
│ └── __main__.py
│ └── make_nested_py_modules.py
├── dist
│ ├── test-project-python-0.0.2.tar.gz
│ └── test_project-python-0.0.2-py3-none-any.whl
├── make_nested_py_modules.sh
├── package_a
│ ├── __init__.py
│ ├── module_a.py
│ ├── module_b.py
│ ├── module_c.py
│ ├── module_d.py
│ ├── module_e.py
│ ├── subpackage_a
│ │ ├── __init__.py # this __init__.py module MUST exist for setuptools to *automatically* detect subpackage_a
│ │ ├── a.py
│ │ ├── b.py
│ │ ├── c.py
│ │ ├── d.py
│ │ └── e.py
│ ├── subpackage_b
│ │ ├── __init__.py # this __init__.py module MUST exist for setuptools to *automatically* detect subpackage_b
│ │ ├── a.py
│ │ ├── b.py
│ │ ├── c.py
│ │ ├── d.py
│ │ └── e.py
│ └── subpackage_c
│ ├── __init__.py # this __init__.py module MUST exist for setuptools to *automatically* detect subpackage_c
│ ├── a.py
│ ├── b.py
│ ├── c.py
│ ├── d.py
│ └── e.py
├── package_b
│ ├── __init__.py
│ ├── module_a.py
│ ├── module_b.py
│ ├── module_c.py
│ ├── module_d.py
│ ├── module_e.py
│ ├── subpackage_a
│ │ ├── __init__.py # this __init__.py module MUST exist for setuptools to *automatically* detect subpackage_a
│ │ ├── a.py
│ │ ├── b.py
│ │ ├── c.py
│ │ ├── d.py
│ │ └── e.py
│ ├── subpackage_b
│ │ ├── __init__.py # this __init__.py module MUST exist for setuptools to *automatically* detect subpackage_b
│ │ ├── a.py
│ │ ├── b.py
│ │ ├── c.py
│ │ ├── d.py
│ │ └── e.py
│ └── subpackage_c
│ ├── __init__.py # this __init__.py module MUST exist for setuptools to *automatically* detect subpackage_c
│ ├── a.py
│ ├── b.py
│ ├── c.py
│ ├── d.py
│ └── e.py
├── package_c
│ ├── __init__.py
│ ├── module_a.py
│ ├── module_b.py
│ ├── module_c.py
│ ├── module_d.py
│ ├── module_e.py
│ ├── subpackage_a
│ │ ├── __init__.py # this __init__.py module MUST exist for setuptools to *automatically* detect subpackage_a
│ │ ├── a.py
│ │ ├── b.py
│ │ ├── c.py
│ │ ├── d.py
│ │ └── e.py
│ ├── subpackage_b
│ │ ├── __init__.py # this __init__.py module MUST exist for setuptools to *automatically* detect subpackage_b
│ │ ├── a.py
│ │ ├── b.py
│ │ ├── c.py
│ │ ├── d.py
│ │ └── e.py
│ └── subpackage_c
│ ├── __init__.py # this __init__.py module MUST exist for setuptools to *automatically* detect subpackage_c
│ ├── a.py
│ ├── b.py
│ ├── c.py
│ ├── d.py
│ └── e.py
├── setup.py
└── test_project_python
│ ├── __init__.py
│ ├── __main__.py
│ ├── make_nested_py_modules_examples.py
│ ├── make_nested_py_modules.py
└── test_project_python.egg-info
├── PKG-INFO
├── SOURCES.txt
├── dependency_links.txt
├── entry_points.txt
└── top_level.txt
Examples
### install/upgrade the test_project_python package ###
python -m pip install --upgrade test_project_python
### run modules defined in the test_project_python package ###
python -m test_project_python.make_nested_py_modules
# now take a look at the directories and modules created by this command
python -m test_project_python.make_nested_py_modules_examples
# now take a look at the directories and modules created by this command
### run commands defined in entry_points['console_scripts'] located in the setup.py module ###
command_name
command_name_for_function_in__main__
Building a python package for distribution
# update the package version to the new MAJOR.MINOR.PATCH everywhere in the project
# run the following commands from the root of your python project (and make sure your setup.py module is here)
#
# in the test_project_python project, this is from the
# /path/to/test-project/python directory (the setup.py module is here)
# https://stackoverflow.com/questions/34928001/distutils-ignores-changes-to-setup-py-when-building-an-extension
python setup.py clean --all # avoid using cached information
rm -r build/ # python setup.py clean --all **should** remove all contents of build/, but just in case
rm -r project_name.egg-info # **should** be updated automatically with both the setup.py and pip install command below, but just in case
rm -r package_* example_* # remove script generated packages (test_project_python specific, another projects will have a different cleaning process)
python -m test_project_python.make_nested_py_modules # build script generated packages (test_project_python specific, another projects will have a different build process)
python setup.py sdist bdist_wheel # build packages for distribution
python -m pip install . # install the package locally
# run the sequence again (so run the 7 commands sequentially twice) just in case something somehow remains cached
# sign the package with your gpg key (optional)
# NOTE that your command may be `gpg2` instead of `gpg` (depends on how you installed this)
# also NOTE that the dashes or underscores in the dist/projectname.tar.gz is dependent on how
# you named things in your setup.py module; specifically dependent on the `name` argument
# you provide to the setuptools.setup function (if you use underscores for the `name` value, the
# file will be dist/project_name.tar.gz, whereas if you use dashes for the `name` value, the
# file will be dist/project-name.tar.gz)
gpg --detach-sign -a dist/project_name-MAJOR.MINOR.PATCH-py3-none-any.whl
gpg --detach-sign -a dist/project-name-MAJOR.MINOR.PATCH.tar.gz
### upload to PyPI ###
# upload to https://test.pypi.org/
twine upload --repository-url https://test.pypi.org/legacy/ dist/project_name-MAJOR.MINOR.PATCH-py3-none-any.whl dist/project_name-MAJOR.MINOR.PATCH-py3-none-any.whl.asc dist/project-name-MAJOR.MINOR.PATCH.tar.gz dist/project-name-MAJOR.MINOR.PATCH.tar.gz.asc
# upload to https://pypi.org/
twine upload dist/project_name-MAJOR.MINOR.PATCH-py3-none-any.whl dist/project_name-MAJOR.MINOR.PATCH-py3-none-any.whl.asc dist/project-name-MAJOR.MINOR.PATCH.tar.gz dist/project-name-MAJOR.MINOR.PATCH.tar.gz.asc
Releases
See the latest release from the releases page
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for test-project-python-0.0.2.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | eca7d70a779c71ac9c2abee91f985fec646f4170e6b0f4e097a9d41e30d2b6c1 |
|
MD5 | 9f16998e63bed2fab21f0e82139183ef |
|
BLAKE2b-256 | 4f0aab753f0ec3ce4aa1ea66a25ca4ab838184609d44ae3974140d88ceb2f258 |
Hashes for test_project_python-0.0.2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f46497efbe9a0323d976f7386f7a88365b38c180bc4572192d2211df4d3206ce |
|
MD5 | 0b3d8d59d6b40daabbf3fc87ec9b9ae1 |
|
BLAKE2b-256 | 4bde7597856d9cbe5fdb45f963ad7ffdbc592b3df48a5ab2ccd071be15a6536c |