generate requirements.txt (for readthedocs) + setup doc system

This commit is contained in:
Gaetan Semet 2018-01-05 15:09:44 +01:00
parent b6a4346e27
commit feb98abcf1
10 changed files with 163 additions and 286 deletions

2
.gitignore vendored
View File

@ -68,3 +68,5 @@ build/
AUTHORS
ChangeLog
.venv

View File

@ -1,4 +1,4 @@
.PHONY: build
.PHONY: build dev
MODULE:=guake
INSTALL_ROOT:=/
@ -6,17 +6,22 @@ PREFIX:=$(INSTALL_ROOT)usr
SLUG:=fragment_name
all: dev style checks build dists test-unit docs
all: dev style checks dists test docs
dev:
dev: pipenv-install-dev requirements ln-venv
pipenv-install-dev:
pipenv install --dev
ln-venv:
# use that to configure a symbolic link to the virtualenv in .venv
rm -rf .venv
ln -s $$(pipenv --venv) .venv
install-local:
pipenv install
install-system: install-schemas install-locale
python3 setup.py install --root "$(INSTALL_ROOT)" --optimize=1
@ -35,35 +40,43 @@ install-schemas: generate-desktop
style: fiximports autopep8 yapf
fiximports:
@for fil in $$(find setup.py install.py install-lib.py guake -name "*.py"); do \
echo "Sorting imports from: $$fil"; \
pipenv run fiximports $$fil; \
done
autopep8:
pipenv run autopep8 --in-place --recursive setup.py $(MODULE)
yapf:
pipenv run yapf --style .yapf --recursive -i $(MODULE)
checks: update-po sdist flake8 pylint
checks: update-po requirements sdist flake8 pylint
flake8:
pipenv run python setup.py flake8
pylint:
pipenv run pylint --rcfile=.pylintrc --output-format=colorized $(MODULE)
dists: update-po requirements rm-dists sdist bdist wheels
build: dists
sdist:
pipenv run python setup.py sdist
rm-dists:
rm -rf build dist
bdist:
pipenv run python setup.py bdist
wheels:
pipenv run python setup.py bdist_wheel
run-local:
export GUAKE_DATA_DIR=$(shell pwd)/data ; pipenv run ./run-local.sh
@ -76,28 +89,12 @@ shell:
test:
pipenv run pytest $(MODULE)
test-coverage:
pipenv run py.test -v --cov $(MODULE) --cov-report term-missing
dists: update-po sdist bdist wheels
sdist:
pipenv run python setup.py sdist
bdist:
pipenv run python setup.py bdist
wheels:
pipenv run python setup.py bdist_wheel
docs:
cd doc && make html
cd doc && pipenv run make html
pypi-publish: build
@ -109,7 +106,12 @@ update:
pipenv install --dev
lock:
lock: pipenv-lock requirements
requirements:
pipenv run pipenv_to_requirements -f
pipenv-lock:
pipenv lock
@ -124,9 +126,11 @@ push: githook
git push origin --tags
clean:
pipenv --rm ; true
find . -name "*.pyc" -exec rm -f {} \;
clean: rm-dists
@pipenv --rm ; true
@find . -name "*.pyc" -exec rm -f {} \;
@rm -rf .venv .eggs *.egg-info *.pot
@echo "clean successful"
update-po:
@ -140,7 +144,6 @@ update-po:
mv "$$f.new" $$f; \
done;
generate-mo:
for f in $$(find po -iname "*.po"); do \
l="$${f%%.*}"; \
@ -152,6 +155,7 @@ generate-desktop:
msgfmt --desktop --template=guake/data/guake.template.desktop -d po -o guake/data/guake.desktop || (echo "Skipping .desktop files, is your gettext version < 0.19.1?" && cp guake/data/guake.template.desktop guake/data/guake.desktop)
msgfmt --desktop --template=guake/data/guake-prefs.template.desktop -d po -o guake/data/guake-prefs.desktop || (echo "Skipping .desktop files, is your gettext version < 0.19.1?" && cp guake/data/guake-prefs.template.desktop guake/data/guake-prefs.desktop)
reno:
pipenv run reno new $(SLUG)

View File

@ -23,6 +23,7 @@ pylint = "*"
pytest = "*"
yapf = "*"
reno = {extras = ["sphinx"]}
pipenv-to-requirements = "*"
[packages]

61
Pipfile.lock generated
View File

@ -1,7 +1,7 @@
{
"_meta": {
"hash": {
"sha256": "e002638de997883d9310023ec36014b68988a218ddc411abb8c0660716a33811"
"sha256": "13b51b50a0376931c509232453d237b27e4f33516008e540b16f91f7ca76e1f8"
},
"host-environment-markers": {
"implementation_name": "cpython",
@ -210,6 +210,26 @@
],
"version": "==1.7.1"
},
"pew": {
"hashes": [
"sha256:a5256586e169199cb2213225261b6bdd7b657c309dcf4a02b61994308b313d4d",
"sha256:b8312728526c9010295c88215c95a1b1731fdbd1a568f728e069932bd0545611"
],
"version": "==1.1.2"
},
"pipenv": {
"hashes": [
"sha256:e1fb0aa2571c9c5a1b403ac782e7da09719625ac51a1238b0e6c5d157c3c679a"
],
"version": "==9.0.1"
},
"pipenv-to-requirements": {
"hashes": [
"sha256:dbf10898cd1e5ba197529ba5d6a9a2e54ec15b6eb41fc0046f2c0deead78acfa",
"sha256:f7b64388f5616b7870999ff2121a599acfc888b0e5810a09278df2373fa02ca7"
],
"version": "==0.1.9"
},
"pluggy": {
"hashes": [
"sha256:7f8ae7f5bdf75671a718d2daf0a64b7885f74510bcd98b1a0bb420eb9a9d0cff"
@ -265,32 +285,6 @@
],
"version": "==1.6.3"
},
"pyyaml": {
"hashes": [
"sha256:3262c96a1ca437e7e4763e2843746588a965426550f3797a79fca9c6199c431f",
"sha256:16b20e970597e051997d90dc2cddc713a2876c47e3d92d59ee198700c5427736",
"sha256:e863072cdf4c72eebf179342c94e6989c67185842d9997960b3e69290b2fa269",
"sha256:bc6bced57f826ca7cb5125a10b23fd0f2fff3b7c4701d64c439a300ce665fff8",
"sha256:c01b880ec30b5a6e6aa67b09a2fe3fb30473008c85cd6a67359a1b15ed6d83a4",
"sha256:827dc04b8fa7d07c44de11fabbc888e627fa8293b695e0f99cb544fdfa1bf0d1",
"sha256:592766c6303207a20efc445587778322d7f73b161bd994f227adaa341ba212ab",
"sha256:5f84523c076ad14ff5e6c037fe1c89a7f73a3e04cf0377cb4d017014976433f3",
"sha256:0c507b7f74b3d2dd4d1322ec8a94794927305ab4cebbe89cc47fe5e81541e6e8",
"sha256:b4c423ab23291d3945ac61346feeb9a0dc4184999ede5e7c43e1ffb975130ae6",
"sha256:ca233c64c6e40eaa6c66ef97058cdc80e8d0157a443655baa1b2966e812807ca",
"sha256:4474f8ea030b5127225b8894d626bb66c01cda098d47a2b0d3429b6700af9fd8",
"sha256:326420cbb492172dec84b0f65c80942de6cedb5233c413dd824483989c000608",
"sha256:5ac82e411044fb129bae5cfbeb3ba626acb2af31a8d17d175004b70862a741a7"
],
"version": "==3.12"
},
"reno": {
"hashes": [
"sha256:afca3160a78845a44ef87bfdc52c70a514317d21cfaa1c065269e9e612c44e2a",
"sha256:fe0e8655579bed899b19384ffde5c6ebd9b537b066a3c9e957e8918ea3ae0633"
],
"version": "==2.6.0"
},
"pytz": {
"hashes": [
"sha256:80af0f3008046b9975242012a985f04c5df1f01eed4ec1633d56cc47a75a6a48",
@ -373,6 +367,19 @@
],
"version": "==1.22"
},
"virtualenv": {
"hashes": [
"sha256:39d88b533b422825d644087a21e78c45cf5af0ef7a99a1fc9fbb7b481e5c85b0",
"sha256:02f8102c2436bb03b3ee6dede1919d1dac8a427541652e5ec95171ec8adbc93a"
],
"version": "==15.1.0"
},
"virtualenv-clone": {
"hashes": [
"sha256:6b3be5cab59e455f08c9eda573d23006b7d6fb41fae974ddaa2b275c93cc4405"
],
"version": "==0.2.6"
},
"wrapt": {
"hashes": [
"sha256:d4d560d479f2c21e1b5443bbd15fe7ec4b37fe7e53d335d3b9b0a7b1226fe3c6"

7
dev.sh
View File

@ -1,7 +0,0 @@
#!/bin/bash
# This script is used by the main developer to quickly compile and install the current version
# of Guake sources. Nothing say it will work directly on your environment. Use with caution!
make dev
make run

View File

@ -30,6 +30,7 @@ import sys
# ones.
extensions = [
'sphinx.ext.doctest',
'reno.sphinxext',
]
# Add any paths that contain templates here, relative to this directory.
@ -45,8 +46,8 @@ source_suffix = '.rst'
master_doc = 'index'
# General information about the project.
project = u'Python Fix Imports'
copyright = u'2016, Gaetan Semet'
project = u'Guake 3'
copyright = u'2018, Gaetan Semet'
# The version info for the project you're documenting, acts as replacement for
# |version| and |release|, also used in various other places throughout the

View File

@ -1,234 +1,32 @@
.. Python Fix Imports documentation master file, created by
sphinx-quickstart on Fri Apr 1 14:41:17 2016.
You can adapt this file completely to your liking, but it should at least
contain the root `toctree` directive.
.. Guake User documentation
Welcome to Python Fix Imports's documentation
=============================================
Welcome to the official Guake User Documentation
================================================
Introduction
************
Python Fix Imports is a Python module that can automatically reorganize the ``import`` statements of
your Python script. Please read the "Rationale" section for more information.
Guake is a dropdown terminal made for the GNOME desktop environment. Guake's style of window is
based on an FPS game, and one of its goals is to be easy to reach.
This module originally from a script that has been written for the Buildbot project, in order to
help developers ensuring they properly organize their import statements in their Python files.
Release Notes
*************
.. toctree::
:maxdepth: 1
Rationale
*********
The beginning of each Python script is the part of the code that is likely to evolve the most over
the lifetime of the file. Imports statements gets added, removed, reorganized all over the time.
Thanks to distributed versioning systems such as Git, several persons can easily work on the same
time on the same file. And the management of the ``import`` statements is likely to cause conflict
when each developer adds his modifications.
We really started having the need for an automatic reorganization script when we have set up an
automatic merge of several branches alltogether. Most of the time, the conflicts were found to be on
the ``import`` lines.
Here are the rules this ``fiximports`` script enforces:
Rule 1
------
Each import statement only imports one method, class or module.
**Yes:**
.. code:: python
from abc import dce
from abc import fgh
**No:**
.. code:: python
from abc import dce, fgh
from abc import (dce,
fgh)
from abc import dce, \
fgh
``fiximports`` automatically splits ``import`` statements that use a comma. ``\`` and parenthesis
are not supported.
**Bonus**: let's say you want where and how an object "object_name" is imported. This rules ensures
you will always find the import occurences of the following search pattern: ``import object_name``.
No need to do regex, only ``import `` + what you are looking for.
Rule 2
------
Import statements are organized in blocks, separated by an empty line. Each block is alphabetically
sorted.
This removes any ambiguity in the placement of an import line in a given block. When two developers
on two different branches want to add the same import in the same file, the location of this line
will be the same and so the merge if any will be obvious.
**Yes:**
.. code:: python
from abc import aaaa
from abc import bbbb
from abc import cccc
**No:**
.. code:: python
from abc import bbbb
from abc import aaaa
from abc import cccc
Sorting only occurs on a given block, if for any reason an import statement needs to be placed after
another one, just add an empty line.
``fiximports`` can sort all ``import`` statements at once (preserving the 'group' splitting).
In some project, I tend to enforce the ordering of the groups themself:
- first the standard library imports:
.. code-block:: python
import json
import login
import os
- Standart libraries in the form ``from ... import``:
.. code-block:: python
from textwrap import dedent
from twisted.internet import defer
- Project modules with their complete name (always uses ``from __future__ import absolute_import``)
.. code-block:: python
from myproject.the.module.name import ClassName
from myproject.the.other.module.name import TheOtherClassName
Example
*******
Let's look at the following code:
.. code:: python
import datetime
import collections
from io import BytesIO, UnsupportedOperation
from .hooks import default_hooks
from .structures import CaseInsensitiveDict
from .auth import HTTPBasicAuth
from .cookies import cookiejar_from_dict, get_cookie_header
from .packages.urllib3.fields import RequestField
from .packages.urllib3.filepost import encode_multipart_formdata
from .packages.urllib3.util import parse_url
from .packages.urllib3.exceptions import DecodeError, ReadTimeoutError, ProtocolError, LocationParseError
from .exceptions import HTTPError, MissingSchema, InvalidURL, ChunkedEncodingError, ContentDecodingError, ConnectionError, StreamConsumedError
from .utils import guess_filename, get_auth_from_url, requote_uri, stream_decode_response_unicode, to_key_val_list, parse_header_links, iter_slices, guess_json_utf, super_len, to_native_string
from .compat import cookielib, urlunparse, urlsplit, urlencode, str, bytes, StringIO, is_py2, chardet, json, builtin_str, basestring
from .status_codes import codes
This automatically becomes with this plugin:
.. code:: python
import collections
import datetime
from .hooks import default_hooks
from .structures import CaseInsensitiveDict
from io import BytesIO
from io import UnsupportedOperation
from .auth import HTTPBasicAuth
from .compat import StringIO
from .compat import basestring
from .compat import builtin_str
from .compat import bytes
from .compat import chardet
from .compat import cookielib
from .compat import is_py2
from .compat import json
from .compat import str
from .compat import urlencode
from .compat import urlsplit
from .compat import urlunparse
from .cookies import cookiejar_from_dict
from .cookies import get_cookie_header
from .exceptions import ChunkedEncodingError
from .exceptions import ConnectionError
from .exceptions import ContentDecodingError
from .exceptions import HTTPError
from .exceptions import InvalidURL
from .exceptions import MissingSchema
from .exceptions import StreamConsumedError
from .packages.urllib3.exceptions import DecodeError
from .packages.urllib3.exceptions import LocationParseError
from .packages.urllib3.exceptions import ProtocolError
from .packages.urllib3.exceptions import ReadTimeoutError
from .packages.urllib3.fields import RequestField
from .packages.urllib3.filepost import encode_multipart_formdata
from .packages.urllib3.util import parse_url
from .status_codes import codes
from .utils import get_auth_from_url
from .utils import guess_filename
from .utils import guess_json_utf
from .utils import iter_slices
from .utils import parse_header_links
from .utils import requote_uri
from .utils import stream_decode_response_unicode
from .utils import super_len
from .utils import to_key_val_list
from .utils import to_native_string
Indeed, the beginning of the file is much more verbose, but merges will be easier (since when
we switched to this paradigm, we almost have not conflict on these lines).
Usage
*****
.. code-block:: bash
$ fiximports --help
usage: fiximports [-h] FILENAME
Fix Python Import Statements
positional arguments:
FILENAME Path or glob of Python files to fix
optional arguments:
-h, --help show this help message and exit
release_notes/unreleased
License
*******
Copyright 2015 Semet Gaetan <gaetan@xeberon.net>
GNU GENERAL PUBLIC LICENSE
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
Version 2, June 1991
http://www.apache.org/licenses/LICENSE-2.0
Copyright (C) 1989, 1991 Free Software Foundation, Inc.
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.

View File

@ -0,0 +1,5 @@
============================
Current Series Release Notes
============================
.. release-notes::

55
requirements-dev.txt Normal file
View File

@ -0,0 +1,55 @@
################################################################################
# This requirements files has been automatically generated from `Pipfile` with
# `pipenv-to-requirements`
#
## This has been done to maintain backward compatibility with tools and services
# that does not support `Pipfile` yet.
## Do NOT edit it directly, use `pipenv install [-d]` to modify `Pipfile` and
# `Pipfile.lock`
################################################################################
alabaster==0.7.10
astroid==1.6.0
attrs==17.4.0
autopep8==1.3.3
babel==2.5.1
certifi==2017.11.5
chardet==3.0.4
docutils==0.14
dulwich==0.18.6
fiximports==0.1.18
flake8==3.5.0
idna==2.6
imagesize==0.7.1
isort==4.2.15
jinja2==2.10
lazy-object-proxy==1.3.1
markupsafe==1.0
mccabe==0.6.1
mock==2.0.0
pbr==3.1.1
pep8==1.7.1
pew==1.1.2
pipenv-to-requirements==0.1.9
pipenv==9.0.1
pluggy==0.6.0
py==1.5.2
pycodestyle==2.3.1
pyflakes==1.6.0
pygments==2.2.0
pylint==1.8.1
pytest-mock==1.6.3
pytest==3.3.2
pytz==2017.3
pyyaml==3.12
reno==2.6.0
requests==2.18.4
six==1.11.0
snowballstemmer==1.2.1
sphinx==1.6.5
sphinxcontrib-websupport==1.0.1
urllib3==1.22
virtualenv-clone==0.2.6
virtualenv==15.1.0
wrapt==1.10.11
yapf==0.20.0

11
requirements.txt Normal file
View File

@ -0,0 +1,11 @@
################################################################################
# This requirements files has been automatically generated from `Pipfile` with
# `pipenv-to-requirements`
#
## This has been done to maintain backward compatibility with tools and services
# that does not support `Pipfile` yet.
## Do NOT edit it directly, use `pipenv install [-d]` to modify `Pipfile` and
# `Pipfile.lock`
################################################################################
pbr==3.1.1