Updating App Version

Hi There, i’m a new beginner trying to create my first app. I can’t find the place to update my App Version. I’ve tried updating from hooks.py, and try executing in patches.txt a line, execute:app_version = “0.0.2”, and changed in setup.py.

I’ve tried running bench migrate and bench update as well and both does not update the version number.

update hooks.py and setup.py

Hi @rmehta i’ve updated both files previously too but the app version does not update itself. Am I missing out something?

I realised that the version updates under installer, but not when i click on “About Us”

Can’t figure, did you do bench migrate

Yes I did bench migrate as well. nothing seem to update the app version under “About Us”

it comes from app.__version__ property

Ask @pdvyas why!

Same Problem.

I updated version in 3 files

  1. hooks.py
  2. setup.py
  3. __version__.py

did bench update and bench migrate

I can see the version updated in Application Installer.
Version doesn’t change under “About” Dialog.

From the bench’s release code,

def set_filename_version(filename, version_number, pattern):
	changed = []

	def inject_version(match):
		before, old, after = match.groups()
		changed.append(True)
		return before + version_number + after

	with open(filename) as f:
		contents = re.sub(r"^(\s*%s\s*=\s*['\\\"])(.+?)(['\"])(?sm)" % pattern,
				inject_version, f.read())

	if not changed:
		raise Exception('Could not find %s in %s', pattern, filename)

	with open(filename, 'w') as f:
		f.write(contents)

def set_setuppy_version(repo, version):
	set_filename_version(os.path.join(repo, 'setup.py'), version, 'version')

def set_versionpy_version(repo, version):
	set_filename_version(os.path.join(repo, os.path.basename(repo),'__version__.py'), version, '__version__')

def set_hooks_version(repo, version):
	set_filename_version(os.path.join(repo, os.path.basename(repo),'hooks.py'), version, 'app_version')

def set_version(repo, version):
	set_setuppy_version(repo, version)
	set_versionpy_version(repo, version)
	set_hooks_version(repo, version)

Does it make sense to have a bench set-app-version command? (and ofcourse disallow it for frappe and erpnext because the release script does the develop → master dance)

1 Like

@pdvyas It makes sense, if it makes the version management easy.

I have been developing my app since long time, never cared to bump version.

Initially I was doing all the development on master branch, following erpnext and frappe I also develop on develop branch and merge it into master later.

I’d like to manage versions when apps are on store (manage versions in sync with frappe erpnext conventions)

One more un-updated version: When I generate docs for the current version of app the version on button remains 0.0.0 Civil Contracting: Developer Docs

Awesome! @revant_one is on a roll :smile:

1 Like

I tried the bench release command.

It works after changes in two lines in bench,
https://github.com/frappe/bench/pull/213

Add name of custom app in the list in commands/utils.py

@click.command('release')
@click.argument('app', type=click.Choice(['frappe', 'erpnext', 'erpnext_shopify', 'paypal_integration', 'schools', 'custom_app']))

Change of github username in release.py

create_github_release('revant', repo, tag_name, message)

It created a github release automatically!

no change in v0.0.1

I tried following in bench console:

 In [1] frappe.get_attr("erpnext" + ".__version__")
 Out[1]: u'x.xx.xx'
 In [2] frappe.get_attr("civil_contracting" + ".__version__")

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
/home/revant/frappe-bench/apps/frappe/frappe/commands.pyc in <module>()
----> 1 frappe.get_attr("civil_contracting" + ".__version__")

/home/revant/frappe-bench/apps/frappe/frappe/__init__.pyc in get_attr(method_string)
    787 	modulename = '.'.join(method_string.split('.')[:-1])
    788 	methodname = method_string.split('.')[-1]
--> 789 	return getattr(get_module(modulename), methodname)
    790 
    791 def call(fn, *args, **kwargs):

AttributeError: 'module' object has no attribute '__version__'

I have a version py file in my app https://github.com/revant/civil_contracting/blob/master/civil_contracting/__version__.py

I noticed a line in erpnext/__init __.py

from erpnext.__version__ import __version__

I added such line in my app which results into error:

Traceback (most recent call last):
  File "/usr/lib/python2.7/runpy.py", line 174, in _run_module_as_main
    "__main__", fname, loader, pkg_name)
  File "/usr/lib/python2.7/runpy.py", line 72, in _run_code
    exec code in run_globals
  File "/home/revant/frappe-bench/apps/frappe/frappe/utils/bench_helper.py", line 79, in <module>
    main()
  File "/home/revant/frappe-bench/apps/frappe/frappe/utils/bench_helper.py", line 16, in main
    click.Group(commands=commands)(prog_name='bench')
  File "/home/revant/frappe-bench/env/local/lib/python2.7/site-packages/click/core.py", line 716, in __call__
    return self.main(*args, **kwargs)
  File "/home/revant/frappe-bench/env/local/lib/python2.7/site-packages/click/core.py", line 696, in main
    rv = self.invoke(ctx)
  File "/home/revant/frappe-bench/env/local/lib/python2.7/site-packages/click/core.py", line 1060, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/home/revant/frappe-bench/env/local/lib/python2.7/site-packages/click/core.py", line 1060, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/home/revant/frappe-bench/env/local/lib/python2.7/site-packages/click/core.py", line 889, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/home/revant/frappe-bench/env/local/lib/python2.7/site-packages/click/core.py", line 534, in invoke
    return callback(*args, **kwargs)
  File "/home/revant/frappe-bench/env/local/lib/python2.7/site-packages/click/decorators.py", line 17, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "/home/revant/frappe-bench/apps/frappe/frappe/commands.py", line 29, in _func
    ret = f(frappe._dict(ctx.obj), *args, **kwargs)
  File "/home/revant/frappe-bench/apps/frappe/frappe/commands.py", line 762, in console
    frappe.init(site=site)
  File "/home/revant/frappe-bench/apps/frappe/frappe/__init__.py", line 140, in init
    setup_module_map()
  File "/home/revant/frappe-bench/apps/frappe/frappe/__init__.py", line 741, in setup_module_map
    for module in get_module_list(app):
  File "/home/revant/frappe-bench/apps/frappe/frappe/__init__.py", line 641, in get_module_list
    return get_file_items(os.path.join(os.path.dirname(get_module(app_name).__file__), "modules.txt"))
  File "/home/revant/frappe-bench/apps/frappe/frappe/__init__.py", line 599, in get_module
    return importlib.import_module(modulename)
  File "/usr/lib/python2.7/importlib/__init__.py", line 37, in import_module
    __import__(name)
  File "/home/revant/frappe-bench/apps/civil_contracting/civil_contracting/__init__.py", line 1, in <module>
    from civil_contracting.__version__ import __version__
ImportError: cannot import name __version__

Even bench console doesn’t work because of this line. I commented the line in my app and tried following in bench console:

In [1]: from civil_contracting.__version__ import __version__

In [2]: __version__
Out[2]: u'1.3.0'

Updating App Version works perfectly now.
check these changes and make similar changes to custom apps.

https://github.com/frappe/erpnext/commit/227b238fb18c6695f3281fcd9615f92773dc89fe

1 Like

This topic was automatically closed 12 hours after the last reply. New replies are no longer allowed.