pypi
PyPI - the Python Package Index
Minimal packaging stucture http://python-packaging.readthedocs.io/en/latest/minimal.html
1 cd ~/vbhelloworld
2 python3.5 setup.py test # run tests
3
4 pip install . # install locally
5 pip uninstall vbhelloworld
6
7 #edit settings for pypi packages site
8 nano ~/.pypirc
9
10 # register user in https://testpypi.python.org
11 python3.5 setup.py register -r https://testpypi.python.org/pypi
12 # build source distribution
13 python3.5 setup.py sdist
14 # upload the source distribution to https://testpypi.python.org
15 python3.5 setup.py sdist upload -r https://testpypi.python.org/pypi
16 # uninstall local package
17 # install package from https://testpypi.python.org/
18 pip uninstall vbhelloworld
19 pip install -i https://testpypi.python.org/pypi vbhelloworld
1 python3 -m pip install --user --upgrade setuptools wheel
2 python3 -m pip install --user --upgrade twine
3 rm dist/*
4 python3 setup.py sdist bdist_wheel
5 ls dist/
6 twine upload --repository-url https://test.pypi.org/legacy/ dist/*
7 pip install -i https://testpypi.python.org/pypi vbhelloworld --user --no-cache-dir
8 pip uninstall vbhelloworld
~/.pypirc
[distutils] index-servers= pypitest [pypitest] repository = https://testpypi.python.org/pypi username = userx password = passx
Example project structure
LICENSE.txt
Copyright (c) 2016 The Python Packaging Authority (PyPA) Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
tests/__init__.py
MANIFEST.in
# Include the license file include LICENSE.txt # Include the data files recursive-include data *
data/helloworld.conf
banner: Hello World
setup.cfg
vbhelloworld/__init__.py
1 import sys
2 import yaml
3
4 def main():
5 """Entry point for the application script"""
6 filex=open("/etc/helloworld.conf")
7 conf= filex.read()
8 filex.close()
9 yamlConf = yaml.load(conf)
10
11 if len(sys.argv) > 1:
12 print("%s %s"%( yamlConf['banner'] , sys.argv[1]) )
13 else:
14 print("%s"%( yamlConf['banner'] ) )
15
16 def add(arg1,arg2):
17 """ Add two values arg1 and arg2 """
18 return arg1+arg2
README.rst
A hello world Python project ======================= A hello world project. ---- This is the README file for the project.
setup.py
1 """A setuptools based setup module.
2
3 See:
4 https://packaging.python.org/en/latest/distributing.html
5 https://github.com/pypa/sampleproject
6 """
7
8 # Always prefer setuptools over distutils
9 from setuptools import setup, find_packages
10 # To use a consistent encoding
11 from codecs import open
12 from os import path
13
14 here = path.abspath(path.dirname(__file__))
15
16 # Get the long description from the README file
17 with open(path.join(here, 'README.rst'), encoding='utf-8') as f:
18 long_description = f.read()
19
20 setup(
21 name='vbhelloworld',
22
23 # Versions should comply with PEP440. For a discussion on single-sourcing
24 # the version across setup.py and the project code, see
25 # https://packaging.python.org/en/latest/single_source_version.html
26 version='1.0.0',
27
28 description='A hello world Python project',
29 long_description=long_description,
30
31 # The project's main homepage.
32 url='https://github.com/userx/vbhelloworld',
33
34 # Author details
35 author='UserX',
36 author_email='userx@gmail.com',
37
38 # Choose your license
39 license='MIT',
40
41 # See https://pypi.python.org/pypi?%3Aaction=list_classifiers
42 classifiers=[
43 # How mature is this project? Common values are
44 # 3 - Alpha
45 # 4 - Beta
46 # 5 - Production/Stable
47 'Development Status :: 3 - Alpha',
48
49 # Indicate who your project is intended for
50 'Intended Audience :: Developers',
51 'Topic :: Software Development :: Build Tools',
52
53 # Pick your license as you wish (should match "license" above)
54 'License :: OSI Approved :: MIT License',
55
56 # Specify the Python versions you support here. In particular, ensure
57 # that you indicate whether you support Python 2, Python 3 or both.
58 'Programming Language :: Python :: 2',
59 'Programming Language :: Python :: 2.6',
60 'Programming Language :: Python :: 2.7',
61 'Programming Language :: Python :: 3',
62 'Programming Language :: Python :: 3.3',
63 'Programming Language :: Python :: 3.4',
64 'Programming Language :: Python :: 3.5',
65 ],
66
67 # What does your project relate to?
68 keywords='vbhelloworld setuptools development',
69
70 # You can just specify the packages manually here if your project is
71 # simple. Or you can use find_packages().
72 packages=find_packages(exclude=['contrib', 'docs', 'tests']),
73
74 # Alternatively, if you want to distribute just a my_module.py, uncomment
75 # this:
76 # py_modules=["my_module"],
77
78 # List run-time dependencies here. These will be installed by pip when
79 # your project is installed. For an analysis of "install_requires" vs pip's
80 # requirements files see:
81 # https://packaging.python.org/en/latest/requirements.html
82 install_requires=['pyyaml'],
83
84 # List additional groups of dependencies here (e.g. development
85 # dependencies). You can install these using the following syntax,
86 # for example:
87 # $ pip install -e .[dev,test]
88 extras_require={
89 'dev': ['check-manifest'],
90 'test': ['coverage'],
91 },
92
93 # If there are data files included in your packages that need to be
94 # installed, specify them here. If using Python 2.6 or less, then these
95 # have to be included in MANIFEST.in as well.
96 #package_data={
97 # 'sample': ['package_data.dat'],
98 #},
99
100 # Although 'package_data' is the preferred approach, in some case you may
101 # need to place data files outside of your packages. See:
102 # http://docs.python.org/3.4/distutils/setupscript.html#installing-additional-files # noqa
103 # In this case, 'data_file' will be installed into '<sys.prefix>/my_data'
104 data_files=[('/etc', ['data/helloworld.conf'])],
105
106 # To provide executable scripts, use entry points in preference to the
107 # "scripts" keyword. Entry points provide cross-platform support and allow
108 # pip to create the appropriate form of executable for the target platform.
109 entry_points={
110 'console_scripts': [
111 'helloworld=vbhelloworld:main',
112 ],
113 },
114 )
sdist tar.gz content
- cd dist
- tar tvzf vbhelloworld-1.0.0.tar.gz
data/ data/helloworld.conf vbhelloworld/ vbhelloworld/__init__.py vbhelloworld.egg-info/ vbhelloworld.egg-info/PKG-INFO vbhelloworld.egg-info/SOURCES.txt vbhelloworld.egg-info/dependency_links.txt vbhelloworld.egg-info/entry_points.txt vbhelloworld.egg-info/requires.txt vbhelloworld.egg-info/top_level.txt LICENSE.txt MANIFEST.in README.rst setup.cfg setup.py PKG-INFO
Submit to prod repository and install
python3.4 setup.py register -r https://pypi.python.org/pypi
- python3.4 setup.py sdist
python3.4 setup.py sdist upload -r https://pypi.python.org/pypi
- pip uninstall vbhelloworld
- pip install --user vbhelloworld