Skip to content

Commit

Permalink
[Madoshakalaka#76] prettier formatting
Browse files Browse the repository at this point in the history
Signed-off-by: Bryant Finney <finneybp@gmail.com>
  • Loading branch information
bryant-finney committed Nov 8, 2021
1 parent b2c1ba0 commit f59e6fd
Show file tree
Hide file tree
Showing 33 changed files with 322 additions and 333 deletions.
13 changes: 13 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"overrides": [
{
"files": "Pipfile",
"options": { "parser": "toml" }
},
{
"files": "Pipfile.lock",
"options": { "parser": "json", "tabWidth": 4 }
}
],
"tabWidth": 2
}
256 changes: 127 additions & 129 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,142 +13,140 @@ before_cache:

jobs:
include:
# linux
- python: '3.8'
script: python3 -m tox -e py38 -- --cov-report=xml
- python: '3.7'
script: python3 -m tox -e py37 -- --cov-report=xml
- python: '3.6.9'
script: python3 -m tox -e py36 -- --cov-report=xml
- python: '3.5'
script: python3 -m tox -e py35 -- --cov-report=xml
- python: '2.7.17'
install: python -m pip install .[dev] codecov
script: python -m tox -e py27 -- --cov-report=xml
# linux
- python: "3.8"
script: python3 -m tox -e py38 -- --cov-report=xml
- python: "3.7"
script: python3 -m tox -e py37 -- --cov-report=xml
- python: "3.6.9"
script: python3 -m tox -e py36 -- --cov-report=xml
- python: "3.5"
script: python3 -m tox -e py35 -- --cov-report=xml
- python: "2.7.17"
install: python -m pip install .[dev] codecov
script: python -m tox -e py27 -- --cov-report=xml

# osx python 3.8
- name: "Python: 3.8"
os: osx
osx_image: xcode11
language: shell
cache:
directories:
- $HOME/Library/Caches/Homebrew
- /usr/local/Homebrew
# switch to python 3.8
addons:
homebrew:
update: true
before_install:
- pyenv install 3.8-dev
- pyenv global 3.8-dev
- export PATH="/Users/travis/.pyenv/shims:${PATH}"
# end switch
install: python3 -m pip install --user .[dev] codecov
script: python3 -m tox -e py38 -- --cov-report=xml
after_success: python3 -m codecov
# osx python 3.8
- name: "Python: 3.8"
os: osx
osx_image: xcode11
language: shell
cache:
directories:
- $HOME/Library/Caches/Homebrew
- /usr/local/Homebrew
# switch to python 3.8
addons:
homebrew:
update: true
before_install:
- pyenv install 3.8-dev
- pyenv global 3.8-dev
- export PATH="/Users/travis/.pyenv/shims:${PATH}"
# end switch
install: python3 -m pip install --user .[dev] codecov
script: python3 -m tox -e py38 -- --cov-report=xml
after_success: python3 -m codecov

# osx python 3.7
- name: "Python: 3.7"
os: osx
# xcode 11 image comes with python 3.7
osx_image: xcode11
# language: python will error
language: shell
install: python3 -m pip install --user .[dev] codecov
script: python3 -m tox -e py37 -- --cov-report=xml
after_success: python3 -m codecov
# osx python 3.7
- name: "Python: 3.7"
os: osx
# xcode 11 image comes with python 3.7
osx_image: xcode11
# language: python will error
language: shell
install: python3 -m pip install --user .[dev] codecov
script: python3 -m tox -e py37 -- --cov-report=xml
after_success: python3 -m codecov

# osx python 3.6.5
- name: "Python: 3.6.5"
os: osx
osx_image: xcode9.4 # Python 3.6.5 running on macOS 10.13
before_script: python3 --version
language: shell
install: python3 -m pip install --user .[dev] codecov
script: python3 -m tox -e py36 -- --cov-report=xml
after_success: python3 -m codecov
# osx python 3.6.5
- name: "Python: 3.6.5"
os: osx
osx_image: xcode9.4 # Python 3.6.5 running on macOS 10.13
before_script: python3 --version
language: shell
install: python3 -m pip install --user .[dev] codecov
script: python3 -m tox -e py36 -- --cov-report=xml
after_success: python3 -m codecov

# osx python 3.5
- name: "Python: 3.5.7"
os: osx
osx_image: xcode11
cache:
directories:
- $HOME/Library/Caches/Homebrew
- /usr/local/Homebrew
language: shell
# switch to python 3.5
addons:
homebrew:
update: true
before_install:
- pyenv install 3.5.7
- pyenv global 3.5.7
- export PATH="/Users/travis/.pyenv/shims:${PATH}"
- python3 -m pip install --user --upgrade pip
- python3 -m pip install --user --upgrade setuptools
# end switch
install: python3 -m pip install --user .[dev] codecov
# for some reason tox cannot find python3.5. we have to use py instead of py35
script: python3 -m tox -e py35 -- --cov-report=xml
after_success: python3 -m codecov
# osx python 3.5
- name: "Python: 3.5.7"
os: osx
osx_image: xcode11
cache:
directories:
- $HOME/Library/Caches/Homebrew
- /usr/local/Homebrew
language: shell
# switch to python 3.5
addons:
homebrew:
update: true
before_install:
- pyenv install 3.5.7
- pyenv global 3.5.7
- export PATH="/Users/travis/.pyenv/shims:${PATH}"
- python3 -m pip install --user --upgrade pip
- python3 -m pip install --user --upgrade setuptools
# end switch
install: python3 -m pip install --user .[dev] codecov
# for some reason tox cannot find python3.5. we have to use py instead of py35
script: python3 -m tox -e py35 -- --cov-report=xml
after_success: python3 -m codecov

# osx python 2.7.14
- name: "Python: 2.7.14"
os: osx
osx_image: xcode9.3 # Python 2.7.14_2 running on macOS 10.13
language: shell
before_install:
- python -m pip install --user --upgrade pip
- python -m pip install --user --upgrade setuptools
install: python -m pip install --user .[dev] codecov
script: python -m tox -e py27 -- --cov-report=xml
after_success: python -m codecov

# osx python 2.7.14
- name: "Python: 2.7.14"
os: osx
osx_image: xcode9.3 # Python 2.7.14_2 running on macOS 10.13
language: shell
before_install:
- python -m pip install --user --upgrade pip
- python -m pip install --user --upgrade setuptools
install: python -m pip install --user .[dev] codecov
script: python -m tox -e py27 -- --cov-report=xml
after_success: python -m codecov
# windows python 3.8
- name: "Python: 3.8"
os: windows
# language: python will error
language: shell
# install python 3.8
before_install:
- choco install python --version 3.8.0
- python -m pip install --upgrade pip
install: python -m pip install --user .[dev] codecov
# On Windows, python3 does not exist
script: python -m tox -e py38 -- --cov-report=xml
env: PATH=/c/Python38:/c/Python38/Scripts:$PATH
after_success: python -m codecov

# windows python 3.8
- name: "Python: 3.8"
os: windows
# language: python will error
language: shell
# install python 3.8
before_install:
- choco install python --version 3.8.0
- python -m pip install --upgrade pip
install: python -m pip install --user .[dev] codecov
# On Windows, python3 does not exist
script: python -m tox -e py38 -- --cov-report=xml
env: PATH=/c/Python38:/c/Python38/Scripts:$PATH
after_success: python -m codecov

# windows python 3.7
- name: "Python: 3.7"
os: windows
# language: python will error
language: shell
# install python 3.7
before_install:
- choco install python --version 3.7.4
- python -m pip install --upgrade pip
install: python -m pip install --user .[dev] codecov
# On Windows, python3 does not exist
script: python -m tox -e py37 -- --cov-report=xml
env: PATH=/c/Python37:/c/Python37/Scripts:$PATH
after_success: python -m codecov

# windows python 3.6
- name: "Python: 3.6"
os: windows
language: shell
before_install:
- choco install python --version 3.6.8
- python -m pip install --upgrade pip
install: python -m pip install --user .[dev] codecov
script: python -m tox -e py36 -- --cov-report=xml
env: PATH=/c/Python36:/c/Python36/Scripts:$PATH
after_success: python -m codecov
# windows python 3.7
- name: "Python: 3.7"
os: windows
# language: python will error
language: shell
# install python 3.7
before_install:
- choco install python --version 3.7.4
- python -m pip install --upgrade pip
install: python -m pip install --user .[dev] codecov
# On Windows, python3 does not exist
script: python -m tox -e py37 -- --cov-report=xml
env: PATH=/c/Python37:/c/Python37/Scripts:$PATH
after_success: python -m codecov

# windows python 3.6
- name: "Python: 3.6"
os: windows
language: shell
before_install:
- choco install python --version 3.6.8
- python -m pip install --upgrade pip
install: python -m pip install --user .[dev] codecov
script: python -m tox -e py36 -- --cov-report=xml
env: PATH=/c/Python36:/c/Python36/Scripts:$PATH
after_success: python -m codecov
# 3.5 and 2.7 on Windows are temporally disabled
# cuz a timeout issue on travis builds
# see this issue: https://github.com/Madoshakalaka/pipenv-setup/issues/31
Expand Down Expand Up @@ -176,4 +174,4 @@ jobs:
# install: python -m pip install --user .[dev] codecov
# script: python -m tox -e py27 -- --cov-report=xml
# env: PATH=/c/Python27:/c/Python27/Scripts:$PATH
# after_success: python -m codecov
# after_success: python -m codecov
34 changes: 16 additions & 18 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,15 @@ is all you need
> different version may result in different dependencies.
# To Introduce New Dependencies

- write compatible setup.py and code

This project aims to run on most compatible python versions.

If you want to introduce your favorite python package to this project, please note, Pipfile is synced to setup.py
If you want to introduce your favorite python package to this project, please note, Pipfile is synced to setup.py
in this project and setup.py will be published to everyone.
This means you have the responsibility to specify markers

This means you have the responsibility to specify markers
(python version requirements, os requirements) when you `pipenv install ` a not so compatible package.

e.g. you can do a `$ pipenv install "advanced_tech~=x.x; python_versions>='3.6'"` and write python version dependent code for
Expand All @@ -28,14 +29,14 @@ lower python versions. (or you can do a simple `$ pipenv install advanced_tech`,
An example in our project:

When we update user's `setup.py`, `black` is used to format the file. However `black` does not support python versions below
3.6. So we have `autopep8` as an alternative
3.6. So we have `autopep8` as an alternative

```
# pipfile
black = {markers = "python_version>='3.6'",version = ">=19.3b0"}
autopep8 = {markers = "python_version<'3.6'",version = "~=1.4"}
```
```

And in the code:

Expand All @@ -57,21 +58,18 @@ def format_file(file):
...
```



# Pull Request

Upon pull request, travis will run tox tests on python 2.7/3.5/3.6/3.7/3.8 across 3 Operating Systems.
(yep, at most 15 tests in total, some of them may be disabled now and then because of configuration issues)

Tox also tests packaging from `setup.py`. Before any pull request, be sure to sync changed dependencies to `setup.py`.

A caveat is that when you have changed dependencies, command entry `$ pipenv-setup sync` may not be able to start,
A caveat is that when you have changed dependencies, command entry `$ pipenv-setup sync` may not be able to start,
as the shortcut command is provided by `setup.py` and `setup.py` detects mismatched dependencies and throw up.

Please use package entry instead: `python3 -m pipenv_setup sync --dev --pipfile`. Or use the shortcut in Pipfile:
`$ pipenv run sync-deps`

`$ pipenv run sync-deps`

# Tests

Expand All @@ -81,27 +79,27 @@ Optionally, if you have some of python 2.7/3.5/3.6/3.7/3.8 installed

`$ tox` will run tests on at most 6 python versions depending how many versions you installed on your machine

Specify `$ tox -e pyXX` to run tests with specific python version. It's worth noting `py37` is the major test environment
Specify `$ tox -e pyXX` to run tests with specific python version. It's worth noting `py37` is the major test environment
and has extra `mypy` tests for static type checking (if type hints are used in code). For lightweight tests, it's a good
choice is to at least have python3.7 and use `$ tox -e py37` instead of `$ pytest`
choice is to at least have python3.7 and use `$ tox -e py37` instead of `$ pytest`

In this project, dev dependencies in Pipfile should be synced to `setup.py` in `extras_require`, as tox installs
In this project, dev dependencies in Pipfile should be synced to `setup.py` in `extras_require`, as tox installs
`pipenv-setup[dev]` before running tests.

As mentioned, if you made changes to dependencies in pipfile, before running tox tests, use `$ pipenv run sync-deps` to
update them to `setup.py`
As mentioned, if you made changes to dependencies in pipfile, before running tox tests, use `$ pipenv run sync-deps` to
update them to `setup.py`

# Test Data Creation

The majority of `pipenv-setup`'s function requires the presence of pipfile, lockfile, and setup.py

If you'd like to come up with test cases. Create one like this [generic test folder](tests/data/generic_nice_0).

If you manipulate test data with `pipenv`, be sure to do it in a different environment to
avoid editing Pipfile of this project.
If you manipulate test data with `pipenv`, be sure to do it in a different environment to
avoid editing Pipfile of this project.

> `gitdir` and `xml-subsetter` in generic test data are light-weight example packages
# Others

If you are working on something. It's appreciated to have an issue about it first so that we know it's being worked on :)
If you are working on something. It's appreciated to have an issue about it first so that we know it's being worked on :)

0 comments on commit f59e6fd

Please sign in to comment.