From d92cd4312d4559b70295ba58e73fbbe1efdb09d9 Mon Sep 17 00:00:00 2001 From: David THENON Date: Mon, 1 Oct 2018 02:00:43 +0200 Subject: [PATCH] Improved packaging. Close #32. We moved every package informations into 'setup.cfg' and now 'setup.py' is only an entrypoint for setuptools. tox and pytest configurations has been moved also into 'setup.cfg'. Makefile has been updated and python-venv has been dropped in profit of virtualenv to ease development. --- .flake8 | 2 - .gitignore | 42 +++++++++++++------- LICENCE.txt | 2 +- Makefile | 61 ++++++++++++++++------------- boussole/__init__.py | 25 +++++++++++- docs/changelog.rst | 9 +++++ docs/development.rst | 10 ++--- requirements/dev.txt | 4 -- requirements/tests.txt | 3 -- setup.cfg | 88 ++++++++++++++++++++++++++++++++++++++++-- tox.ini | 11 ------ 11 files changed, 185 insertions(+), 72 deletions(-) delete mode 100644 .flake8 delete mode 100644 requirements/dev.txt delete mode 100644 requirements/tests.txt delete mode 100644 tox.ini diff --git a/.flake8 b/.flake8 deleted file mode 100644 index e9041b2..0000000 --- a/.flake8 +++ /dev/null @@ -1,2 +0,0 @@ -[flake8] -#format = \e[31mERROR:\e[0m %(path)s:%(row)d:%(col)d: \e[31m%(code)s\e[0m %(text)s \ No newline at end of file diff --git a/.gitignore b/.gitignore index e1d0b78..1cf57b1 100644 --- a/.gitignore +++ b/.gitignore @@ -1,27 +1,41 @@ +# virtualenv +.venv + +# Packaging +build +dist +*.egg-info + # Byte-compiled / optimized / DLL files __pycache__/ *.py[cod] -*$py.class -# virtualenv -/venv +# Site media +/data/ -# Distribution / packaging -.installed.cfg -dist/ -*.egg-info +# Settings +local.py # Unit test / coverage reports htmlcov/ -.tox/ .coverage -.coverage.* .cache +.pytest_cache nosetests.xml coverage.xml -*,cover -.hypothesis/ -.pytest_cache -# Various -boussole/dev_inspector.py +# Temp files +*~ +.~lock* + +# Swap files +*.sw[po] + +# SASS +.sass-cache + +# Exported strings & generated translation templates +*.pot + +# Tests +.tox diff --git a/LICENCE.txt b/LICENCE.txt index 90cb092..269abd2 100644 --- a/LICENCE.txt +++ b/LICENCE.txt @@ -19,4 +19,4 @@ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR -OTHER DEALINGS IN THE SOFTWARE. \ No newline at end of file +OTHER DEALINGS IN THE SOFTWARE. diff --git a/Makefile b/Makefile index 0c97559..e099f46 100644 --- a/Makefile +++ b/Makefile @@ -1,48 +1,57 @@ -PYTHON=python3 - -PIP=venv/bin/python -m pip -FLAKE=venv/bin/flake8 -PYTEST=venv/bin/py.test - -.PHONY: help clean delpyc tests flake quality +PYTHON_INTERPRETER=python3 +VENV_PATH=.venv +PIP=$(VENV_PATH)/bin/pip +FLAKE=$(VENV_PATH)/bin/flake8 +PYTEST=$(VENV_PATH)/bin/pytest help: @echo "Please use \`make ' where is one of" @echo - @echo " clean -- to clean local repository from all stuff created during development" - @echo " delpyc -- to remove all *.pyc files, this is recursive from the current directory" - @echo " flake -- to launch Flake8 checking on boussole code (not the tests)" - @echo " tests -- to launch tests using py.test" - @echo " quality -- to launch Flake8 checking and tests with py.test" - @echo " release -- to release new package on Pypi (WARNING)" + @echo " install -- to install this project with virtualenv and Pip" + @echo "" + @echo " clean -- to clean EVERYTHING" + @echo " clean-install -- to clean installation" + @echo " clean-pycache -- to remove all __pycache__, this is recursive from current directory" + @echo "" + @echo " flake -- to launch Flake8 checking" + @echo " tests -- to launch tests using Pytest" + @echo " quality -- to launch Flake8 checking and Pytest" @echo -delpyc: +clean-pycache: + find . -type d -name "__pycache__"|xargs rm -Rf find . -name "*\.pyc"|xargs rm -f + rm -Rf .pytest_cache +.PHONY: clean-pycache + +clean-install: + rm -Rf $(VENV_PATH) + rm -Rf .tox + rm -Rf boussole.egg-info +.PHONY: clean-install -clean: delpyc - rm -Rf venv dist .tox boussole.egg-info .cache tests/__pycache__/ +clean: clean-install clean-pycache +.PHONY: clean venv: - $(PYTHON) -m venv venv + virtualenv -p $(PYTHON_INTERPRETER) $(VENV_PATH) # This is required for those ones using ubuntu<16.04 $(PIP) install --upgrade pip $(PIP) install --upgrade setuptools +.PHONY: venv install: venv - $(PIP) install -e . - -install-dev: install - $(PIP) install -r requirements/dev.txt + mkdir -p data + $(PIP) install -e .[dev] +.PHONY: install flake: $(FLAKE) --show-source boussole +.PHONY: flake tests: - $(PYTEST) -vv tests + $(PYTEST) -vv --exitfirst tests/ +.PHONY: tests quality: tests flake - -release: - python setup.py sdist - python setup.py sdist upload +.PHONY: quality diff --git a/boussole/__init__.py b/boussole/__init__.py index f3efb4c..e9cf905 100644 --- a/boussole/__init__.py +++ b/boussole/__init__.py @@ -1,2 +1,25 @@ +# -*- coding: utf-8 -*- """Commandline interface to build Sass projects using libsass-python""" -__version__ = '1.3.0' +from __future__ import absolute_import, unicode_literals + +import os +from setuptools.config import read_configuration + +import pkg_resources + +PROJECT_DIR = os.path.join(os.path.dirname(__file__), "..") + + +def _extract_version(package_name): + """ + Get package version from installed distribution or configuration file if not + installed + """ + try: + return pkg_resources.get_distribution(package_name).version + except pkg_resources.DistributionNotFound: + _conf = read_configuration(os.path.join(PROJECT_DIR, "setup.cfg")) + return _conf["metadata"]["version"] + + +__version__ = _extract_version("boussole") diff --git a/docs/changelog.rst b/docs/changelog.rst index 58217f5..9bc2700 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -5,6 +5,15 @@ Changelog ========= +Version 1.4.0 - 2018/10/01 +-------------------------- + +**Improved packaging** + +We moved every package informations into ``setup.cfg`` and now ``setup.py`` is only an entrypoint for setuptools. tox and pytest configurations has been moved also into ``setup.cfg``. + +Makefile has been updated and python-venv has been dropped in profit of virtualenv to ease development. + Version 1.3.0 - 2018/09/30 -------------------------- diff --git a/docs/development.rst b/docs/development.rst index 71cefb4..ddfa43f 100644 --- a/docs/development.rst +++ b/docs/development.rst @@ -20,22 +20,20 @@ Boussole is developed with: * Respecting flake and pip8 rules using `Flake8`_; * `Sphinx`_ for documentation with enabled `Napoleon`_ extension (using only the *Google style*); -Every requirement is available in file ``requirements/dev.txt``. - Install for development *********************** -First ensure you have `pip`_ and ``python-venv`` package installed then type: :: +First ensure you have `pip`_ and `virtualenv`_ package installed then type: :: git clone https://github.com/sveetch/boussole.git cd boussole - make install-dev + make install Boussole will be installed in editable mode from the last commit on master branch. When it's done, you will be able to check for boussole version, just type: :: - venv/bin/boussole version + .venv/bin/boussole version Unittests --------- @@ -67,4 +65,4 @@ When environnement is activated, you can use following command from ``docs/`` di make livehtml -And go on ``http://127.0.0.1:8002/``. \ No newline at end of file +And go on ``http://127.0.0.1:8002/``. diff --git a/requirements/dev.txt b/requirements/dev.txt deleted file mode 100644 index ec510aa..0000000 --- a/requirements/dev.txt +++ /dev/null @@ -1,4 +0,0 @@ - -r tests.txt -sphinx -sphinx-rtd-theme -sphinx-autobuild diff --git a/requirements/tests.txt b/requirements/tests.txt deleted file mode 100644 index c01db76..0000000 --- a/requirements/tests.txt +++ /dev/null @@ -1,3 +0,0 @@ -pytest>=3.3.0 -flake8 -#flake8-format-ansi diff --git a/setup.cfg b/setup.cfg index 84bed90..d6cb987 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,6 +1,86 @@ -[aliases] -test=pytest +;; +;; Boussole package +;; +[metadata] +name = boussole +version =1.4.0 +description = Commandline interface to build Sass projects using libsass-python +long_description = file:README.rst +long_description_content_type = text/x-rst +author = David Thenon +author_email = sveetch@gmail.com +url = https://github.com/sveetch/boussole +license = MIT +keywords = Scss, Sass, Libsass, watchdog +classifiers = + License :: OSI Approved :: MIT License + Operating System :: OS Independent + Development Status :: 5 - Production/Stable + Environment :: Console + Programming Language :: Python + Programming Language :: Python :: 2.7 + Programming Language :: Python :: 3.5 + Intended Audience :: Developers + Topic :: Internet + Topic :: Software Development :: Compilers + Topic :: Software Development :: Libraries :: Python Modules + +[options] +include_package_data = True +install_requires = + six + click>=5.1,<6.0 + pathtools + watchdog + libsass>=0.14.5 + pyaml + colorama + colorlog +packages = find: +zip_safe = True + +[options.extras_require] +dev = + flake8 + pytest + sphinx + sphinx-rtd-theme + sphinx-autobuild + +[options.packages.find] +where = . +exclude= + docs + tests + +[wheel] +universal = 1 + +;; +;; Third-party packages configuration +;; +[flake8] +max-line-length = 80 +exclude = + .git, + .venv, + build, + venv, + __pycache__, [tool:pytest] -testpaths = tests -python_files = *.py +addopts = -vv +python_files = + *.py +testpaths = + tests + +[tox:tox] +minversion = 3.4.0 +envlist = py27, py35 + +[testenv] + +commands = + pip install -e .[dev] + pytest -vv tests diff --git a/tox.ini b/tox.ini deleted file mode 100644 index f5bc2ba..0000000 --- a/tox.ini +++ /dev/null @@ -1,11 +0,0 @@ - -[tox] -envlist = py27, py35 - -[testenv] -# changedir = project_test -# Get the right django version following the current env - -commands = - pip install -r requirements/tests.txt - py.test -vv tests