Shub assigns a version number to your project every time you make a deploy to  Zyte Developer Tool Scrapy Cloud. The version assigned depends on whether you are using a VCS or not.


TL;DR

  • if you are not using a VCS: shub will use the version from setup.py ("1.0" by default).
  • if you are using Git or Mercurial: it will detect which VCS it is, and version your package as: <commit id (for git) or revision number (for hg)> -<branch name>
  • you can also override the version number via command line arguments or configuration file.


Projects with no VCS in place

If you're not using Git nor Mercurial to manage your project, by default shub will assign the current timestamp as the version for your first deploy. After that, a setup.py file will be created in your project folder having your package version set to 1.0. Then the project version will be 1.0 in your next deploy:



From that point on, you can manage your package versions via the setup.py file. It's just a matter of incrementing the version number when you want to deploy a new version:


from setuptools import setup, find_packages

setup(
    name         = 'project',
    version      = '1.1',
    packages     = find_packages(),
    entry_points = {'scrapy': ['settings = quotesbot.settings']},
)



Projects using a VCS

If you're using a version control system such as Git or Mercurial, then shub will detect it and generate the version name as a combination of the commit id and the current branch name, thus overriding the version defined on setup.py.


Let's say you are working on a branch called development. If you deploy your project to Scrapy Cloud, you'll get versions such as the ones shown below:


Here, 8f6dc03 and 4a4fe18 are git commit ids (in Mercurial it would use the the revision number).


Overriding the version number

You can always manually override the version number for your deploy, even if you are using GIt or Mercurial. You can do so via shub configuration file or command line arguments.


Via configuration file

You can set the version number for a given deploy inside your project's scrapinghub.yml file:


project: 12345
version: 1.2


Via command line

Alternatively, you can pass the version number to shub via command line arguments, like this:


$ shub deploy --version 1.2


This will override the settings from setup.py and from your VCS.