Skip to content

Commit ba25ff9

Browse files
author
Carl Sverre
authored
Devenv (#25)
* moving to devcontainer * attempt at github actions
1 parent 9f5a64c commit ba25ff9

File tree

13 files changed

+168
-77
lines changed

13 files changed

+168
-77
lines changed

.devcontainer/Dockerfile

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# [Choice] Python version (use -bullseye variants on local arm64/Apple Silicon): 3, 3.10, 3.9, 3.8, 3.7, 3.6, 3-bullseye, 3.10-bullseye, 3.9-bullseye, 3.8-bullseye, 3.7-bullseye, 3.6-bullseye, 3-buster, 3.10-buster, 3.9-buster, 3.8-buster, 3.7-buster, 3.6-buster
2+
ARG VARIANT=3-bullseye
3+
FROM mcr.microsoft.com/vscode/devcontainers/python:0-${VARIANT}
4+
5+
ENV PYTHONUNBUFFERED 1
6+
7+
# [Choice] Node.js version: none, lts/*, 16, 14, 12, 10
8+
ARG NODE_VERSION="none"
9+
RUN if [ "${NODE_VERSION}" != "none" ]; then su vscode -c "umask 0002 && . /usr/local/share/nvm/nvm.sh && nvm install ${NODE_VERSION} 2>&1"; fi
10+
11+
# [Optional] If your requirements rarely change, uncomment this section to add them to the image.
12+
# COPY requirements.txt /tmp/pip-tmp/
13+
# RUN pip3 --disable-pip-version-check --no-cache-dir install -r /tmp/pip-tmp/requirements.txt \
14+
# && rm -rf /tmp/pip-tmp
15+
16+
# [Optional] Uncomment this section to install additional OS packages.
17+
RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
18+
&& apt-get -y install --no-install-recommends mariadb-client
19+

.devcontainer/devcontainer.json

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
// For format details, see https://aka.ms/devcontainer.json. For config options, see the README at:
2+
// https://github.com/microsoft/vscode-dev-containers/tree/v0.224.3/containers/python-3-postgres
3+
// Update the VARIANT arg in docker-compose.yml to pick a Python version
4+
{
5+
"name": "Python 3 & PostgreSQL",
6+
"dockerComposeFile": "docker-compose.yml",
7+
"service": "app",
8+
"workspaceFolder": "/workspace",
9+
10+
// Set *default* container specific settings.json values on container create.
11+
"settings": {
12+
"python.defaultInterpreterPath": "/usr/local/bin/python",
13+
"python.linting.enabled": true,
14+
"python.linting.flake8Enabled": true,
15+
"python.formatting.autopep8Path": "/usr/local/py-utils/bin/autopep8",
16+
"python.formatting.blackPath": "/usr/local/py-utils/bin/black",
17+
"python.formatting.yapfPath": "/usr/local/py-utils/bin/yapf",
18+
"python.linting.banditPath": "/usr/local/py-utils/bin/bandit",
19+
"python.linting.flake8Path": "/usr/local/py-utils/bin/flake8",
20+
"python.linting.mypyPath": "/usr/local/py-utils/bin/mypy",
21+
"python.linting.pycodestylePath": "/usr/local/py-utils/bin/pycodestyle",
22+
"python.linting.pydocstylePath": "/usr/local/py-utils/bin/pydocstyle",
23+
"python.linting.pylintPath": "/usr/local/py-utils/bin/pylint",
24+
"python.testing.pytestPath": "/usr/local/py-utils/bin/pytest"
25+
},
26+
27+
// Add the IDs of extensions you want installed when the container is created.
28+
"extensions": ["ms-python.python", "ms-python.vscode-pylance"],
29+
30+
// Use 'forwardPorts' to make a list of ports inside the container available locally.
31+
// This can be used to network with other containers or the host.
32+
// "forwardPorts": [5000, 5432],
33+
34+
// Use 'postCreateCommand' to run commands after the container is created.
35+
"postCreateCommand": "pip install . && pip install twine pytest",
36+
37+
// Comment out to connect as root instead. More info: https://aka.ms/vscode-remote/containers/non-root.
38+
"remoteUser": "vscode"
39+
}

.devcontainer/docker-compose.yml

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
version: "3.8"
2+
3+
services:
4+
app:
5+
build:
6+
context: ..
7+
dockerfile: .devcontainer/Dockerfile
8+
args:
9+
# Update 'VARIANT' to pick a version of Python: 3, 3.10, 3.9, 3.8, 3.7, 3.6
10+
# Append -bullseye or -buster to pin to an OS version.
11+
# Use -bullseye variants on local arm64/Apple Silicon.
12+
VARIANT: 3.6-buster
13+
# Optional Node.js version to install
14+
NODE_VERSION: "none"
15+
16+
volumes:
17+
- ..:/workspace:cached
18+
19+
# Overrides default command so things don't shut down after the process ends.
20+
command: sleep infinity
21+
22+
environment:
23+
- MEMSQL_PYTHON_TEST_HOST=db
24+
25+
# Runs app on the same network as the database container, allows "forwardPorts" in devcontainer.json function.
26+
network_mode: service:db
27+
# Uncomment the next line to use a non-root user for all processes.
28+
# user: vscode
29+
30+
db:
31+
image: mysql:5.7.37
32+
restart: unless-stopped
33+
environment:
34+
MYSQL_ROOT_PASSWORD: mysql
35+
36+
volumes:
37+
postgres-data: null

.flake8

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
[flake8]
2-
exclude: .git,__pycache__,*.pyc,venv,venv2.7,venv3.4,distribution
2+
exclude: .git,__pycache__,*.pyc,venv,venv2.7,venv3.4,distribution,.eggs
33
ignore: E121,E128,E201,E202,E221,E222,E241,E302,E4,E5,E305

.github/workflows/all.yml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
name: Test
2+
3+
on: [push, pull_request]
4+
jobs:
5+
test:
6+
runs-on: ubuntu-latest
7+
8+
services:
9+
mysql:
10+
image: mysql:5.7.37
11+
env:
12+
MYSQL_ROOT_PASSWORD: mysql
13+
14+
steps:
15+
- uses: actions/checkout@v2
16+
- name: Set up Python
17+
uses: actions/setup-python@v2
18+
with:
19+
python-version: 3.6
20+
- name: Install dependencies
21+
run: |
22+
python -m pip install --upgrade pip
23+
python -m pip install flake8 pytest
24+
pip install .
25+
- name: Run tests
26+
env:
27+
MEMSQL_PYTHON_TEST_HOST: mysql
28+
run: |
29+
make test

.travis.yml

Lines changed: 0 additions & 10 deletions
This file was deleted.

MANIFEST.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
include *.txt
2-
include *.rst
2+
include *.md

Makefile

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,4 @@ test-watch:
1919

2020
.PHONY: flake8
2121
flake8:
22-
flake8 --config=.flake8 .
23-
24-
.PHONY: shell
25-
shell:
26-
nix-shell -A memsqlPython
22+
flake8 --config=.flake8 .

README.md

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# MemSQL Python Libraries
2+
3+
This library contains various plugins and wrappers designed by MemSQL
4+
engineers for a couple of important python libraries.
5+
6+
## Install
7+
8+
```bash
9+
pip install memsql
10+
```
11+
12+
Copy and paste the following steps to get started quickly on Ubuntu:
13+
14+
```bash
15+
sudo apt-get update
16+
sudo apt-get install -y mysql-client python-dev libmysqlclient-dev python-pip
17+
sudo pip install memsql
18+
```
19+
20+
Copy and paste the following to get
21+
started with RHEL based distributions such as Amazon Linux or Centos:
22+
23+
```bash
24+
sudo yum update
25+
sudo yum install -y gcc mysql-devel
26+
sudo pip install memsql
27+
```
28+
29+
## Testing
30+
31+
Run tests by executing `make test`.

README.rst

Lines changed: 0 additions & 38 deletions
This file was deleted.

default.nix

Lines changed: 0 additions & 17 deletions
This file was deleted.

memsql/common/test/conftest.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1+
import os
12
import pytest
23
from memsql.common import database
3-
import os
44

55
host = os.environ.get('MEMSQL_PYTHON_TEST_HOST', '127.0.0.1')
66

@@ -14,7 +14,7 @@ def test_db_args():
1414
"host": host,
1515
"port": 3306,
1616
"user": 'root',
17-
"password": ''
17+
"password": 'mysql'
1818
}
1919

2020
@pytest.fixture

setup.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,17 @@
66
# get version
77
from memsql import __version__
88

9-
import sys
9+
from pathlib import Path
10+
11+
this_directory = Path(__file__).parent
12+
long_description = (this_directory / "README.md").read_text()
13+
1014

1115
REQUIREMENTS = [
1216
'wraptor',
1317
'simplejson',
1418
'python-dateutil<3.0',
15-
'mysqlclient>=1.4',
19+
'mysqlclient<2.0',
1620
]
1721

1822
class PyTest(TestCommand):
@@ -86,7 +90,8 @@ def run_tests(self):
8690
url='http://github.com/memsql/memsql-python',
8791
license='LICENSE.txt',
8892
description='Useful utilities and plugins for MemSQL integration.',
89-
long_description=open('README.rst').read(),
93+
long_description=long_description,
94+
long_description_content_type="text/markdown",
9095
classifiers=[
9196
'License :: OSI Approved :: MIT License',
9297
'Programming Language :: Python :: 3.4',

0 commit comments

Comments
 (0)