Skip to content

Commit

Permalink
Roll publish to PyPI into build_dist.py and update BUILD documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
rtomac committed Jun 1, 2012
1 parent 2daee1e commit 694eab5
Show file tree
Hide file tree
Showing 3 changed files with 88 additions and 57 deletions.
90 changes: 48 additions & 42 deletions BUILD.rst
Expand Up @@ -64,69 +64,53 @@ To run just the unit tests, run::
python test/run_unit_tests.py


Pushing Code to GitHub
----------------------

Assuming the remote has been setup and named `origin` (it is
setup and named `origin` automatically if you cloned the existing
GitHub repo), run::

git push origin master


Building a Distribution
-----------------------

To build a distribution, run::

python build_dist.py
python build_dist.py <python 2.6 path> <python 2.7 path>

This script will:

- Generate source distribution packages in .tar.gz and .zip formats
- Generate build distribution packages for Windows x86 and x64
- Generate Python eggs for Python 2.6 and 2.7
- Generate binary installers for Windows x86 and x64
- Generate a demo distribution package in .zip format.
- Re-generate keyword documentation in doc folder


Publishing to PyPi
-----------------------

To publish to PyPi use the following steps.

1. Update the version number in src/Selenium2Library/version.py is updated
2. Run the following commands to create the source and egg distributables::
python2.6 setup.py bdist_egg upload --sign
python2.7 setup.py bdist_egg upload --sign
python2.7 setup.py sdist upload --sign

3. Also from windows it is advisible to publish the windows binaries run::
Publishing a New Release
------------------------

C:\python2.6 setup.py bdist_wininst --taget-version=2.6 register upload
C:\python2.7 setup.py bdist_wininst --target-version=2.7 register upload
The above 2 commands can also include the --sign option if you have gnupgp setup
on your windows system.
Build the distribution, this time with the --release flag::

python build_dist.py --release <python 2.6 path> <python 2.7 path>

Building Keyword Documentation
------------------------------
In addition to building the distribution, this will:

The keyword documentation will get built automatically by build_dist.py,
but if you need to generate it apart from a distribution build, run::

python doc/generate.py
- Register the release/version with PyPI
- Upload the binaries to PyPI for the new release/version

After building and releasing to PyPI:

Building Readme Files
---------------------
- Upload dist packages to the `downloads section on GitHub`_
- Publish the keyword documentation (see `Pushing Keyword Documentation`_)

The readme files get distributed in reStructuredText format (.rst),
so there isn't any reason to build them except to verify how they
are parsed by the reStructuredText parser. To build them, run::
Note: To publish a release, you will need to:

python doc/generate_readmes.py


Pushing Code to GitHub
----------------------

Assuming the remote has been setup and named `origin` (it is
setup and named `origin` automatically if you cloned the existing
GitHub repo), run::

git push origin master
- Register an account on PyPI_ and be given rights to the package by a package owner
- Setup your `.pypirc file`_ (goes in the root of your home directory)


Pushing Keyword Documentation
Expand Down Expand Up @@ -154,3 +138,25 @@ Last, you probably want to switch back to the master branch::
git checkout master


Building Keyword Documentation
------------------------------

The keyword documentation will get built automatically by build_dist.py,
but if you need to generate it apart from a distribution build, run::

python doc/generate.py


Building Readme Files
---------------------

The readme files get distributed in reStructuredText format (.rst),
so there isn't any reason to build them except to verify how they
are parsed by the reStructuredText parser. To build them, run::

python doc/generate_readmes.py


.. _downloads section on GitHub: https://github.com/rtomac/robotframework-selenium2library/downloads
.. _PyPI: http://pypi.python.org
.. _.pypirc file: http://docs.python.org/distutils/packageindex.html#the-pypirc-file
8 changes: 4 additions & 4 deletions INSTALL.rst
Expand Up @@ -9,10 +9,10 @@ Selenium2Library supports all Python and Jython interpreters supported by the
Robot Framework and the `Selenium Python Bindings`_. The Selenium Python Bindings
are the most restrictive, and as of now require Python 2.6 or Python 2.7.

Selenium2Library depends on a handful of other Python libraries, including
Selenium2Library depends on a few other Python libraries, including
of course Robot Framework and Selenium. All dependencies are declared
in setup.py. If you use pip or easy_install to install this library, these
dependencies will be installed for you.
in setup.py. If you use pip or easy_install to install this library, the
dependencies will be installed for you (this is recommended).


Installing from PyPI (recommended)
Expand All @@ -37,7 +37,7 @@ newer. Install by running::

python setup.py install

Or, to automatically install all dependencies, run::
Or, if you'd like to automatically install dependencies, run::

python setup.py develop

Expand Down
47 changes: 36 additions & 11 deletions build_dist.py
@@ -1,7 +1,6 @@
#!/usr/bin/env python

import os, sys, shutil
import subprocess
import os, sys, shutil, subprocess, argparse

THIS_DIR = os.path.dirname(os.path.abspath(__file__))
DIST_DIR = os.path.join(THIS_DIR, "dist")
Expand All @@ -10,11 +9,17 @@
sys.path.append(os.path.join(THIS_DIR, "demo"))

def main():
parser = argparse.ArgumentParser(description="Builds a Se2Lib distribution")
parser.add_argument('py_26_path', action='store', help='Python 2.6 executbale file path')
parser.add_argument('py_27_path', action='store', help='Python 2.7 executbale file path')
parser.add_argument('--release', action='store_true')
args = parser.parse_args()

clear_dist_folder()
run_doc_gen()
run_sdist()
run_win_bdist()
run_register(args)
run_builds(args)
run_demo_packaging()
run_doc_gen()

def clear_dist_folder():
if os.path.exists(DIST_DIR):
Expand All @@ -23,20 +28,40 @@ def clear_dist_folder():

def run_doc_gen():
import generate
print
generate.main()

def run_sdist():
subprocess.call(["python", os.path.join(THIS_DIR, "setup.py"), "sdist", "--formats=gztar,zip"])
def run_register(args):
if args.release:
_run_setup(args.py_27_path, "register", [], False)

def run_win_bdist():
if os.name == 'nt':
subprocess.call(["python", os.path.join(THIS_DIR, "setup.py"), "bdist", "--formats=wininst", "--plat-name=win32"])
subprocess.call(["python", os.path.join(THIS_DIR, "setup.py"), "bdist", "--formats=wininst", "--plat-name=win-amd64"])
def run_builds(args):
print
_run_setup(args.py_27_path, "sdist", [ "--formats=gztar,zip" ], args.release)
_run_setup(args.py_26_path, "bdist_egg", [], args.release)
_run_setup(args.py_27_path, "bdist_egg", [], args.release)
_run_setup(args.py_27_path, "bdist_wininst", [ "--plat-name=win32" ], args.release)
_run_setup(args.py_27_path, "bdist_wininst", [ "--plat-name=win-amd64" ], args.release)

def run_demo_packaging():
import package
print
package.main()

def _run_setup(py_path, type, params, upload):
setup_args = [py_path, os.path.join(THIS_DIR, "setup.py")]
#setup_args.append("--quiet")
setup_args.append(type)
setup_args.extend(params)
if upload:
setup_args.append("upload")

print
print("Running: %s" % ' '.join(setup_args))
returncode = subprocess.call(setup_args)
if returncode != 0:
print("Error running setup.py")
sys.exit(1)

if __name__ == '__main__':
main()

0 comments on commit 694eab5

Please sign in to comment.