Changes

Jump to navigation Jump to search
2,069 bytes added ,  09:01, 30 October 2018
Line 720: Line 720:     
== Publish Python Package ==
 
== Publish Python Package ==
This would make your package available with:
+
Upload a package to pypi. This would make your package available with:
 
  pip install mypackage
 
  pip install mypackage
 
+
=== With setup.py ===
<nowiki>see: https://packaging.python.org/distributing/
+
nano ~/.pypirc
# TODO: Check pbr package
+
<nowiki>[distutils]
 
  −
 
  −
[~/pypirc]
  −
[distutils]
   
index-servers =
 
index-servers =
 
   pypi
 
   pypi
Line 734: Line 730:     
[pypi]
 
[pypi]
repository=https://pypi.python.org/pypi
+
repository=https://upload.pypi.org/legacy/
 
username=your_username
 
username=your_username
 
password=your_password
 
password=your_password
Line 741: Line 737:  
repository=https://testpypi.python.org/pypi
 
repository=https://testpypi.python.org/pypi
 
username=your_username
 
username=your_username
password=your_password
+
password=your_password</nowiki>
 +
Adjust .pypirc permissions
 +
chmod 600 ~/.pypirc
 +
In your project, create a setup.py
 +
<source lang="python">import os
 +
from setuptools import setup, find_packages
 +
 
 +
# from distutils.core import setup
 +
 
 +
# allow setup.py to be run from any path
 +
os.chdir(os.path.normpath(os.path.join(os.path.abspath(__file__), os.pardir)))
 +
 
 +
 
 +
def here(name):
 +
    return os.path.join(
 +
        os.path.dirname(os.path.abspath(__file__)),
 +
        name)
 +
 
    +
def read(name, mode='rb', encoding='utf8'):
 +
    os.system('pandoc --from=markdown --to=rst --output=README.rst README.md')
 +
    if os.path.exists('README.rst'):
 +
        long_description = open('README.rst').read()
 +
    else:
 +
        try:
 +
            with open(here(name), mode) as fp:
 +
                long_description = fp.read()
 +
        except IOError:
 +
            return 'Error generating long description: {} File not found'.format(here(name))
 +
    return long_description
   −
$ chmod 600 ~/.pypirc
+
# Development Status :: 1 - Planning
 +
# Development Status :: 2 - Pre-Alpha
 +
# Development Status :: 3 - Alpha
 +
# Development Status :: 4 - Beta
 +
# Development Status :: 5 - Production/Stable
 +
# Development Status :: 6 - Mature
 +
# Development Status :: 7 - Inactive
      −
[setup.py]
+
license_classifiers = {
 +
    'MIT license': 'License :: OSI Approved :: MIT License',
 +
    'BSD license': 'License :: OSI Approved :: BSD License',
 +
    'ISC license': 'License :: OSI Approved :: ISC License (ISCL)',
 +
    'Apache Software License 2.0': 'License :: OSI Approved :: Apache Software License',
 +
    'GNU General Public License v3': 'License :: OSI Approved :: GNU General Public License v3 (GPLv3)'
 +
}
   −
from distutils.core import setup
   
setup(
 
setup(
  name = 'mypackage',
+
    name='CheKnife',
  packages = ['mypackage'], # this must be the same as the name above
+
    version='v0.0.6b2',
  version = '0.1',
+
    packages=find_packages(),
  description = 'A random test lib',
+
    url='https://git.herrerosolis.com/Misc/CheKnife',
  author = 'Peter Downs',
+
    download_url='https://git.herrerosolis.com/Misc/CheKnife/-/archive/v0.0.6b2/CheKnife-v0.0.6b2.tar.gz',
  author_email = 'peterldowns@gmail.com',
+
    license='MIT license',
  url = 'https://github.com/peterldowns/mypackage', # use the URL to the github repo
+
    author='Rafael Herrero Solis',
  download_url = 'https://github.com/peterldowns/mypackage/tarball/0.1', # I'll explain this in a second
+
    author_email='rafahsolis@hotmail.com',
  keywords = ['testing', 'logging', 'example'], # arbitrary keywords
+
    keywords=['CheKnife', 'Swiss', 'Army', 'Knife', 'Swiss Army Knife'],
  classifiers = [],
+
    description='Python Utilities',
)
+
    long_description=read('README.md'),
 +
    test_suite='nose.collector',
 +
    tests_require=['nose', 'six'],
 +
    install_requires=[
 +
        'six>=1.10.0',
 +
        'future>=0.16.0',
 +
        'pycryptodome>=3.6.1',
 +
        'configparser>=3.5.0'
 +
    ],
 +
    classifiers=[
 +
        'License :: OSI Approved :: MIT License',
 +
        'Development Status :: 3 - Alpha',
 +
        'License :: OSI Approved :: Apache Software License',
 +
        'Programming Language :: Python :: 3.6',
 +
    ],
 +
)</source>
   −
[setup.cfg]
+
nano setup.cfg
[metadata]
+
<nowiki>[metadata]
description-file = README.md
+
description-file = README.md</nowiki>
   −
[LICENSE.txt]
+
nano LICENSE
The MIT License
+
<nowiki>The MIT License
    
SPDX short identifier: MIT
 
SPDX short identifier: MIT
Line 778: Line 828:  
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
 
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.
+
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.</nowiki>
 
+
Test and upload
 +
<source lang="bash">python setup.py register -r pypitest
 +
python setup.py sdist upload -r pypitest
 +
python setup.py register -r pypi
 +
python setup.py sdist upload -r pypi</source>
    +
=== With twine ===
 +
https://packaging.python.org/tutorials/packaging-projects/
   −
$ python setup.py register -r pypitest
  −
$ python setup.py sdist upload -r pypitest
  −
$ python setup.py register -r pypi
  −
$ python setup.py sdist upload -r pypi
  −
</nowiki>
   
== Change PyPi ==
 
== Change PyPi ==
 
=== Using PyPi Local Repository ===
 
=== Using PyPi Local Repository ===

Navigation menu