Skip to content

Commit

Permalink
Move requirements extras to setup.cfg
Browse files Browse the repository at this point in the history
Made cli dependencies optional. Install them using
using `pip install jira[cli]`

fixes pycontribs#361

Change-Id: I73ff68d0fbfd8fcd947b516e04ef6fa489d9da9d
Signed-off-by: Sorin Sbarnea <[email protected]>
  • Loading branch information
ssbarnea committed Mar 1, 2018
1 parent db07494 commit 37d76a1
Show file tree
Hide file tree
Showing 8 changed files with 76 additions and 124 deletions.
77 changes: 28 additions & 49 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,24 +1,20 @@
all: info clean flake8 test docs upload release
all: info clean lint test docs upload release
.PHONY: all docs upload info req

PACKAGE_NAME := $(shell python setup.py --name)
PACKAGE_VERSION := $(shell python setup.py --version)
PYTHON_PATH := $(shell which python)
PLATFORM := $(shell uname -s | awk '{print tolower($0)}')
PLATFORM := $(shell uname -s | awk '{print tolower($$0)}')
DIR := $(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))
PYTHON_VERSION := $(shell python3 -c "import sys; print('py%s%s' % sys.version_info[0:2] + ('-conda' if 'conda' in sys.version or 'Continuum' in sys.version else ''))")
PYENV_HOME := $(DIR)/.tox/$(PYTHON_VERSION)-$(PLATFORM)/
ifneq (,$(findstring conda,$(PYTHON_VERSION)))
CONDA:=1
endif

PREFIX=""
ifndef GIT_BRANCH
GIT_BRANCH=$(shell git branch | sed -n '/\* /s///p')
endif

info:
@echo "INFO: Building $(PACKAGE_NAME):$(PACKAGE_VERSION) on $(GIT_BRANCH) branch"
@echo "INFO: Python $(PYTHON_VERSION) from $(PYENV_HOME) [$(CONDA)]"
@echo "INFO: Python $(PYTHON_VERSION) from '$(PREFIX)' [$(CONDA)]"

clean:
@find . -name "*.pyc" -delete
Expand All @@ -28,66 +24,49 @@ package:
python setup.py sdist bdist_wheel build_sphinx

req:
@$(PYENV_HOME)/bin/requires.io update-site -t ac3bbcca32ae03237a6aae2b02eb9411045489bb -r $(PACKAGE_NAME)
@$(PREFIX)requires.io update-site -t ac3bbcca32ae03237a6aae2b02eb9411045489bb -r $(PACKAGE_NAME)

install: prepare
$(PYENV_HOME)/bin/pip install .
$(PREFIX)pip install .

install-sdk:
# https://developer.atlassian.com/docs/getting-started/set-up-the-atlassian-plugin-sdk-and-build-a-project/install-the-atlassian-sdk-on-a-linux-or-mac-system#InstalltheAtlassianSDKonaLinuxorMacsystem-Homebrew
which atlas-run-standalone || brew tap atlassian/tap && brew install atlassian/tap/atlassian-plugin-sdk

uninstall:
$(PYENV_HOME)/bin/pip uninstall -y $(PACKAGE_NAME)

venv: $(PYENV_HOME)/bin/activate

# virtual environment depends on requriements files
$(PYENV_HOME)/bin/activate: requirements*.txt
@echo "INFO: (Re)creating virtual environment..."
ifdef CONDA
test -e $(PYENV_HOME)/bin/activate || conda create -y --prefix $(PYENV_HOME) pip
else
test -e $(PYENV_HOME)/bin/activate || virtualenv --python=$(PYTHON_PATH) --system-site-packages $(PYENV_HOME)
endif
$(PYENV_HOME)/bin/pip install -q -r requirements.txt -r requirements-opt.txt -r requirements-dev.txt
touch $(PYENV_HOME)/bin/activate

prepare: venv
pyenv install -s 2.7.13
pyenv install -s 3.4.5
pyenv install -s 3.5.2
pyenv install -s 3.6.0
pyenv local 2.7.13 3.4.5 3.5.2 3.6.0
$(PREFIX)pip uninstall -y $(PACKAGE_NAME)

prepare:
@pyenv install -s 2.7.13
@pyenv install -s 3.4.5
@pyenv install -s 3.5.2
@pyenv install -s 3.6.0
@pyenv local 2.7.13 3.4.5 3.5.2 3.6.0
@echo "INFO: === Prearing to run for package:$(PACKAGE_NAME) platform:$(PLATFORM) py:$(PYTHON_VERSION) dir:$(DIR) ==="
if [ -f ${HOME}/testspace/testspace ]; then ${HOME}/testspace/testspace config url ${TESTSPACE_TOKEN}@pycontribs.testspace.com/jira/tests ; fi;
#if [ -f ${HOME}/testspace/testspace ]; then ${HOME}/testspace/testspace config url ${TESTSPACE_TOKEN}@pycontribs.testspace.com/jira/tests ; fi;

testspace:
${HOME}/testspace/testspace publish build/results.xml

flake8: venv
@echo "INFO: flake8"
$(PYENV_HOME)/bin/python -m flake8
$(PYENV_HOME)/bin/python -m flake8 --install-hook 2>/dev/null || true
lint:
@echo "INFO: linting...."
$(PREFIX)python -m flake8
@$(PREFIX)python -m flake8 --install-hook 2>/dev/null || true

test: prepare flake8
test: prepare lint
@echo "INFO: test"
$(PYENV_HOME)/bin/python setup.py build test build_sphinx sdist bdist_wheel check --restructuredtext --strict

test-cli:
$(PYENV_HOME)/bin/ipython -c "import jira; j = jira.JIRA('https://pycontribs.atlassian.net'); j.server_info()" -i
$(PREFIX)python setup.py build test build_sphinx sdist bdist_wheel check --restructuredtext --strict

test-all:
@echo "INFO: test-all (extended/matrix tests)"
# tox should not run inside virtualenv because it does create and use multiple virtualenvs
pip install -q tox tox-pyenv
python -m tox --skip-missing-interpreters true

python -m tox

docs:
@echo "INFO: Building the docs"
$(PYENV_HOME)/bin/pip install sphinx
$(PYENV_HOME)/bin/python setup.py build_sphinx
$(PREFIX)pip install sphinx
$(PREFIX)python setup.py build_sphinx
@mkdir -p docs/build/docset
@mkdir -p docs/build/html/docset
# cannot put doc2dash into requirements.txt file because is using pinned requirements
Expand All @@ -114,11 +93,11 @@ endif
upload:
ifeq ($(GIT_BRANCH),develop)
@echo "INFO: Upload package to testpypi.python.org"
$(PYENV_HOME)/bin/python setup.py check --restructuredtext --strict
$(PYENV_HOME)/bin/python setup.py sdist bdist_wheel upload -r https://testpypi.python.org/pypi
$(PREFIX)python setup.py check --restructuredtext --strict
$(PREFIX)python setup.py sdist bdist_wheel upload -r https://testpypi.python.org/pypi
endif
ifeq ($(GIT_BRANCH),master)
@echo "INFO: Upload package to pypi.python.org"
$(PYENV_HOME)/bin/python setup.py check --restructuredtext --strict
$(PYENV_HOME)/bin/python setup.py sdist bdist_wheel upload
$(PREFIX)python setup.py check --restructuredtext --strict
$(PREFIX)python setup.py sdist bdist_wheel upload
endif
4 changes: 4 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,10 @@ You can also try ``pip install --user --upgrade jira`` which will install or
upgrade jira to your user directory. Or maybe you ARE using a virtualenv_
right?

By default only the basic library dependencies are installed, so if you want
to use the ``cli`` tool or other optional dependencies do perform a full
installation using ``pip install jira[opt,cli,testing]``

.. _virtualenv: http://www.virtualenv.org/en/latest/index.html


Expand Down
3 changes: 0 additions & 3 deletions requirements-all.txt

This file was deleted.

27 changes: 0 additions & 27 deletions requirements-dev.txt

This file was deleted.

12 changes: 3 additions & 9 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,14 +1,8 @@
# The order of packages is significant, because pip processes them in the order
# of appearance. Changing the order has an impact on the overall integration
# process, which may cause wedges in the gate later.
pbr

ordereddict; python_version < '3.1'
argparse; python_version < '3.2'
argparse; python_version<'3.2'
defusedxml
ordereddict; python_version<'3.1'
requests-oauthlib>=0.6.1
requests>=2.10.0
requests_toolbelt
setuptools>=20.10.1
six>=1.10.0
defusedxml
ipython>=4.0.0
34 changes: 33 additions & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ classifier =
Programming Language :: Python :: 3.6
Topic :: Software Development :: Libraries :: Python Modules
Topic :: Internet :: WWW/HTTP

keywords =
api
atlassian
Expand All @@ -36,6 +35,39 @@ keywords =
packages =
jira

#[options.extras_require]
[extras]
cli =
ipython>=4.0.0
opt =
filemagic>=1.6
PyJWT
requests_jwt
requests_kerberos
testing =
coveralls>=1.1
docutils>=0.12
flaky
hacking>=0.13
MarkupSafe>=0.23
oauthlib
py >= 1.4
pytest-cache
pytest-cov
pytest-instafail
pytest-xdist>=1.14
pytest>=2.9.1
requires.io
sphinx>=1.3.5
sphinx_rtd_theme
tenacity
tox-pyenv
tox>=2.3.1
unittest2:python_version<'3.1'
wheel>=0.24.0
xmlrunner>=1.7.7
yanc>=0.3.3

[entry_points]
console_scripts =
jirashell = jira.jirashell:main
Expand Down
26 changes: 2 additions & 24 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
#!/usr/bin/env python

import setuptools
from setuptools.command.test import test as TestCommand
import sys

# In python < 2.7.4, a lazy loading of package `pbr` will break
# setuptools if some other modules registered functions in `atexit`.
Expand All @@ -13,26 +11,6 @@
pass


class PyTest(TestCommand):

def initialize_options(self):
TestCommand.initialize_options(self)
self.pytest_args = []

def finalize_options(self):
TestCommand.finalize_options(self)
self.test_args = []
self.test_suite = True

def run_tests(self):
# import here, cause outside the eggs aren't loaded
import pytest
errno = pytest.main(self.pytest_args)
sys.exit(errno)


setuptools.setup(
setup_requires=['pbr>=1.9', 'setuptools>=17.1', 'pytest-runner'],
pbr=True,
cmdclass={'test': PyTest},
test_suite='tests')
setup_requires=['pbr>=3.0.0', 'setuptools>=17.1', 'pytest-runner'],
pbr=True)
17 changes: 6 additions & 11 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -6,30 +6,25 @@ skip_missing_interpreters = true
[testenv:docs]
basepython=python
changedir=docs
deps=
-rrequirements.txt
-rrequirements-dev.txt
commands=
sphinx-build -W -b html -d {envtmpdir}/doctrees . {envtmpdir}/html

[testenv]
usedevelop = True
deps = -rrequirements.txt
extras =
cli
opt
testing
sitepackages=False
platform =
win: windows
linux: linux
darwin: darwin

deps=
-rrequirements.txt
-rrequirements-dev.txt
-rrequirements-opt.txt

commands=
python -m pip check
python -m flake8
python -m pytest
setenv =
PYTHONPATH =
passenv =
CI_JIRA_*

Expand Down

0 comments on commit 37d76a1

Please sign in to comment.