Skip to main content

Generates next version number for your pyton package. If your package is a PYPI package it checks the latest version from PYPI and creates next version depending on your choices. Alternatively you may use local option which reads local __version__.py or any other file name you provide and creates the next version.Creates version file and reads from the same path. It also provides useful functions to show your package's version at run time.

Project description

Python package Downloads Python 3.8 Python 3.9 Python 3.10

verser

from verser import next_version, Project, next_version_pypi, next_version_local

functions

next_version (general function both for pypi and local)

first checks PYPI if not then checks local

> default parameters :
> pypi = True
> part = 'patch' => increments patch part of your version. Options : major/minor/patch/pre/build
> write = True => if True writes a new version file on your local path 'your_package_name/__version__.py'
> first makes a request to PYPI server to get information about your package
> then increments it depending on your choices
> If it is not a PYPI package or if pypi parameter is false checks local version file to increment

Usage example:

from verser import Project,  next_version
from pathlib import Path

project = Project(package_name="evdspy",
                  default_version=default_vers,
                  version_file_path=Path() / "evdspy" / "__version__.py")
    
new_version = next_version(project, write=True, part='patch')

typically in your setup.py file you may use this variable like below

#file: setup.py
...
from verser import Project,  next_version
from pathlib import Path

project = Project(package_name="evdspy",
                  default_version=default_vers,
                  version_file_path=Path() / "evdspy" / "__version__.py")
    
new_version = next_version(project, write=True, part='patch')

# the setup
setup(
    name=f"{package_name}",
    version=new_version,
    description=f"{description}",
...

next_version_pypi (only for pypi packages)

new_version = next_version_pypi('rich')
print(new_version)
# results :  12.6.1 

new_version = next_version_pypi('rich' , part = 'minor')
print(new_version)
# results :  12.7.0 

next_version_local

it only checks local version.py file inside the root of your project creates one if does not exist

new_version =  next_version_local( 
    package_name = 'some_cool_project_not_published' , 
    increment_choice = True,  => if selected False it will not increment current version 
    part = "minor"              => it will increment minoır part of your package version 
    write = True ,              => since write is True it will rewrite current version to the version file 
)
print(new_version)
    # defaults 
#   --------next_version_pypi-------
#   increment_choice = True ,   => if selected False it will not increment current version 
#   part='patch'                 => it will ignore this parameter
#   write = True ,              => since write is True it will rewrite current version to the version file 

Some examples

new_version = next_version_pypi('rich' , part='major')
new_version = next_version_pypi('rich' , part='patch')
new_version = next_version_pypi('rich' , part='major')
new_version = next_version_pypi('rich' , part='pre' , write=True )
new_version = next_version_pypi('rich' , part='build' , write=False )



new_version =  next_version_local( 
        package_name = 'some_cool_package' , 
        increment_choice = True 
        part = "minor"              
        write = True ,             
    )

new_version =  next_version_local( 
        package_name = 'some_cool_package' , 
        increment_choice = False  
        part = "patch"              
        write = True ,             
    )

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 Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

verser-0.1.7-py2.py3-none-any.whl (40.0 kB view hashes)

Uploaded Python 2 Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page