Skip to content

Commit

Permalink
Merge branch 'docs'
Browse files Browse the repository at this point in the history
  • Loading branch information
anmolakhilesh committed Jul 19, 2018
2 parents 3bbbbeb + 85d7e77 commit 23cb94f
Show file tree
Hide file tree
Showing 6 changed files with 568 additions and 36 deletions.
Binary file added source/black-formatter.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
77 changes: 64 additions & 13 deletions source/code_management.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,38 +3,89 @@ Source code management

git
------------
Git is a version control system for tracking changes in computer files or a folder and coordinating work on those files among multiple people.
`Git <https://git-scm.com/>`_ is a version control system for tracking changes in computer files or a folder and coordinating work on those files among multiple people.

Git/Version Control System is the basic tool in software development.

.. Version control system is a must for software development.
The main purpose of Git is to manage software development projects and its files, as they are changing over time. It stores the information in a repository.


The main purpose of Git is to manage software development projects and its files, as they are changing over time.
It is the most-widely used web-based hosting service.



github
---------
`GitHub <https://github.com/>`_ is a web-based hosting service for version control using Git.
It provides access control and several collaboration features such as bug tracking, feature requests, task management, and wikis for every project.
It provides access control and several collaboration features such as issue tracking, feature requests, documentation, and wikis for every project.

With git, we can collaborate with other developers, track all our work via commits, and revert to any previous version of our code even if we accidentally delete something.

GitHub projects can be public or private and every publicly shared code is freely open to everyone. We can have private projects as well, though, they require a paid GitHub plan.
Public repositories on Github are often used to share Open Source Software

It is the most-widely used web-based hosting service, and it has the largest number of open-source projects.




gitlab
-------
`GitLab <https://about.gitlab.com/>`_ is a web-based hosting service for version control using Git.
`GitLab <https://about.gitlab.com/>`_ is a web-based and self-based hosting service for version control using Git.
Gitlab is free and open-source.

Gitlab offers unlimited free public/private repositories, where as Github offers unlimited public repositories only(private repositories require a paid plan)

GitLab offers all the features of Github plus builtin CI/CD service (Continuous Integration & Continuous Delivery), and more authentication levels.



Countinous integeration



Countinous Integration
-------------------------
Continuous integration (CI) is a software development practice in which individual changes are immediately tested and reported on when they are added to a repository.

Each check-in is then verified by an automated build, allowing teams to detect problems early.
Continuous Integration (CI) is a development practice which automates the build and testing process of the code.
Continuous Integration automates the build and testing processes. The main objective of CI is to test code for every push made to the repository. We need to have a testing framework for the test in CI.

.. Continuous Integration (CI) is a development practice that requires developers to integrate code into a shared repository.
**Each push is verified by an automated build and tests, individual changes are immediately tested and reported on when they are added to a repository, allowing developers to detect problems early.**

CI encourages developers to integrate their code into a main branch of a shared repository.
Instead of building out features in isolation and integrating them at the end of a development cycle, code is integrated with the shared repository by each developer multiple times throughout the day.

gitlab
CI makes code integration a simple, fast process that is part of the everyday development workflow in order to reduce integration costs and respond to defects early.

.. To develop, test, and release software in a quick and consistent way, developers and organizations have created three related but distinct strategies to manage and automate these processes.
.. Countinous Delivery
.. -------------------------
.. Countinous Delivery comes after Continuous Integration, it automates the software release and deployment process.
gitlab-ci
=======
`Gitlab Continuous Integration(CI) <https://about.gitlab.com/features/gitlab-ci-cd/>`_
`Gitlab Continuous Integration(CI) <https://about.gitlab.com/features/gitlab-ci-cd/>`_ is a open-source CI service that is included in gitlab and can be used for all projects in gitlab.

To use GitLab CI, you first need to add a :code:`.gitlab-ci.yml` file to the root directory of your repository, as well as configure your GitLab project to use a Runner. Afterwards, every commit or push will trigger the CI pipeline that has three stages: build, test and deploy.

To set up `.gitlab-ci.yml` file follow this `official doc <https://docs.gitlab.com/ee/ci/quick_start/>`_


circleci
===========
`Circleci Continuous Integration <https://circleci.com/>`_
`Circleci <https://circleci.com/>`_ is a cloud-based continuous integration server.
It supports containers, OSX, Linux and can run within a private cloud or our own data center.
that supports any language that builds on Linux or macOS.

It is available in both cloud-based and self-hosted.

Setting up CircleCI:
+ Sign-in to circleci.com and link your project.
+ After that activate the service hook to that repo in the profile page of cirlceci .
+ Add circle.yml to the project

To set up `.circle-ci.yml` file follow this `official doc <https://circleci.com/docs/enterprise/quick-start/>`_ and
for python apps - `config circleci for python apps <https://circleci.com/docs/2.0/language-python/>`_
4 changes: 2 additions & 2 deletions source/documentation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ When to use `markdown` and `reStructuredText`
+ It you want to a write a documentation consisting of many in-line programs and tables then it is better to use `reStructuredText`.


.. So, which one to use ? Generally it is:
.. - For small documentation use `markdown` otherwise use `reStructuredText`.
So, which one to use ?
Generally it is - For small documentation use `markdown` otherwise use `reStructuredText`.
.. -
Expand Down
222 changes: 212 additions & 10 deletions source/environment_management.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,30 +4,179 @@ Environment Management
virtualenv and virtualenvwrapper
++++++++++++++++++++++++++++++++++++++++

.. virtualenv
.. =========
virtualenv
=========

`virtualenv <https://virtualenv.pypa.io/en/stable/>`_ is a tool for creating isolated python environments without affecting other projects.
`virtualenv <https://virtualenv.pypa.io/en/stable/>`_ is a popular tool for creating isolated python environments without affecting other projects.

It is really helpful if you are having more than one project at a time, so that there won't be any version clashes among the packages of the projects.
It is really helpful if you are having more than one project at a time, so that there won't be any version clashes among the packages of the projects.
Example , if you want to work with more python2.7 for one project and python3.5 for another project, virtualenv solves the purpose.

It creates an environment that has its own isolated installation directories, that doesn’t share libraries with other virtualenv environments.


We have to install it globally:
:code:`[sudo] pip install virtualenv`

Once we have virtualenv installed, we have to create the a directory for our virtualenv
:code:`mkdir ~/virtualenvironment`


virtualenvwrapper
=========

`virtualenvwrapper <http://virtualenvwrapper.readthedocs.io/en/latest/>`_ is an just like an extension to `virtualenv` which simplifies the commands to use and manage.


To install it:
:code:`[sudo] pip install virtualenvwrapper`

After installing, Add these lines to your shell startup file (:code:`.bashrc`, :code:`.profile`, etc.)

.. code-block:: shell
export WORKON_HOME=$HOME/.virtualenvs
export PROJECT_HOME=$HOME/Devel
source /usr/local/bin/virtualenvwrapper.sh
After editing the file, reload the startup file (e.g., run :code:`source ~/.bashrc`).

We tell the startup file to set the location where the virtual environments should live, the location of your development project directories, and the location of the script installed with this package:

Next, we can create the virtualenv with command :code:`mkvirtualenv`
This command creates the virtualenv and automatically loads it for us.

.. code-block:: shell
$ mkvirtualenv testEnv
New python executable in /Users/anmol/.virtualenvs/testEnv/bin/python2.7
Also creating executable in /Users/anmol/.virtualenvs/testEnv/bin/python
Installing setuptools, pip, wheel...done.
virtualenvwrapper.user_scripts creating /Users/anmol/.virtualenvs/testEnv/bin/predeactivate
virtualenvwrapper.user_scripts creating /Users/anmol/.virtualenvs/testEnv/bin/postdeactivate
virtualenvwrapper.user_scripts creating /Users/anmol/.virtualenvs/testEnv/bin/preactivate
virtualenvwrapper.user_scripts creating /Users/anmol/.virtualenvs/testEnv/bin/postactivate
virtualenvwrapper.user_scripts creating /Users/anmol/.virtualenvs/testEnv/bin/get_env_details
(testEnv) $
To come out of the virtualenv use command :code:`deactivate`

If you want to create a virtualenv with a different version of python like python3(which should be globally installed) then specify the python version using :code:`-p python3`

.. To create the virtualenv with different version of python, use this command :code:`mkvirtualenv testEnv -p python3`
My system created the virtualenv with my default python which is python2.7.
If you also have python3 installed in your system and you want to create the virtualenv with python3 then create the virtualenv with this command :code:`mkvirtualenv testEnv -p python3`

.. code-block:: shell
$ mkvirtualenv testEnv -p python3
Running virtualenv with interpreter /usr/local/bin/python3
Using base prefix '/usr/local/Cellar/python3/3.6.4_2/Frameworks/Python.framework/Versions/3.6'
New python executable in /Users/anmol/.virtualenvs/testEnv/bin/python3
Installing setuptools, pip, wheel...done.
(testEnv) $ python -V
Python 3.6.4
(testEnv) $
It creates an environment that has its own installation directories, that doesn’t share libraries with other virtualenv environments.
`virtualenvwrapper <http://virtualenvwrapper.readthedocs.io/en/latest/>`_ is an just like an extension to `virtualenv` which simplifies the commands to manage the virtualenv.
pipenv
++++++++

`Pipenv <https://docs.pipenv.org/>`_ is a tool for creating a separate/isolated working environment which manges the dependency versions.
`Pipenv <https://docs.pipenv.org/>`_ is a tool for creating a separate/isolated working environment which manages the dependency versions. It creates virtualenv for every project in the project folder.


To install it:
:code:`[sudo] pip install pipenv`

Next, to create a pipenv for a project, go to the project directory and type

.. code-block:: shell
$ pipenv install <package> // like pipenv install requests
.. code-block:: shell
$ pipenv install -r requirements.txt // if our dependencies are listed in a file
$ pipenv --python python3 install <package> // with different version of python like python3
after creating a pipenv, 2 files will be created **Pipfile** and **Pipfile.lock** which lists all our packages and these files get updated whenever we install/update/delete any package.
If we want to add a package for only development/testing then use :code:`pipenv install -d `
To activate this project's virtualenv, run :code:`pipenv shell`
And to run a command inside the virtualenv with :code:`pipenv run` . example :code:`pipenv run python hello.py`
And to exit the virtualenv run :code:`exit`
pip, requirement.txt and pipfile
++++++++++++++++++++++++++++++++++++++++
`pip <https://pip.pypa.io/en/stable/>`_ is a package management system used to install and manage software packages written in Python.
`Pip <https://pip.pypa.io/en/stable/>`_ is a package management system used to install and manage software packages written in Python.
To check pip version:
:code:`pip -V`
To get pip:
:code:`python get-pip.py`
List all packages installed :
:code:`pip freeze`
To install/unistall a package using pip:
.. code-block:: shell
`requirement.txt` is a text file which stores the list of all the pip packages with versions which are required to run the project.
pip install <pacakge> // install
pip install <pacakge>==1.2.2 // install a specific version
pip uninstall <pacakge> // uninstall
**Requirement.txt** is a text file which stores the list of all the pip packages with versions which are required to run the project.
To create a requirements.txt file do :code:`pip freeze > requirements.txt`
A sample requirements.txt file
.. code-block:: shell
Django==2.0.3
djangorestframework==3.7.7
django-rest-swagger==2.1.2
coreapi==2.3.3
**Pipfile** is just a replacement to the requirement.txt file. pipfile is generated when using `pipenv`.
Pipfile lists all the packages by separating the development/testing packages from the main packages used and also mentions the python version it uses.
A sample Pipfile
.. code-block:: shell
[[source]]
url = "https://pypi.python.org/simple"
verify_ssl = true
name = "pypi"
[packages]
coverage = "*"
requests = "*"
[dev-packages]
pylint = "*"
[requires]
python_version = "3.6"
`pipfile` is just a replacement to the requirement.txt file. pipfile is generated when using `pipenv`.
poetry
++++++++
Expand All @@ -37,5 +186,58 @@ Poetry can be installed using pip, but the recommended way to install is
:code:`curl -sSL https://raw.githubusercontent.com/sdispater/poetry/master/get-poetry.py | python`
To use poetry run this command:
:code:`poetry init`
This command will help you create a :code:`pyproject.toml` file interactively by prompting you to provide basic information about your package.
A sample pyproject.toml
.. code-block:: shell
[tool.poetry]
name = "base-ing"
version = "0.1.0"
description = ""
authors = ["anmol <anmol@agiliq.com>"]
[tool.poetry.dependencies]
python = "*"
[tool.poetry.dev-dependencies]
To add a package :
:code:`poetry add <package>`
To add a package as a development-dependency:
:code:`poetry add <package> --dev`
To run a command in poetry
:code:`poetry run python hello.py`
A comparision of the tools
++++++++++++++++++++++++++++++++++++++++
Python/pip Standard
=========
Both pipenv and virtualenvwrapper are officially recommended and are considered as standards.
Easy of use.
=========
Pipenv and virtualenvwrapper both are easy to use.
.. Poetry is
For beginners I suggest, start with virtualenv and then virtualenvwrapper.

0 comments on commit 23cb94f

Please sign in to comment.