Skip to content

Commit b75b72a

Browse files
committed
Merge pull request #46 from ODM2/setup_clean
Setup clean
2 parents 2e85eba + c9e51aa commit b75b72a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

56 files changed

+46717
-251
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
*.py[cod]
22
*~
3+
.ipynb_checkpoints
34

45
# C extensions
56
*.so
@@ -42,4 +43,3 @@ log
4243
.idea
4344

4445
.DS_Store
45-
.ipynb_checkpoints

.travis.yml

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
language: python
2+
sudo: required
3+
# if the https://travis-ci.org/ODM2/ODM2PythonAPI/requests ever says: missing config
4+
# validate at: http://lint.travis-ci.org/
5+
python:
6+
# - "2.6"
7+
- "2.7"
8+
# - "3.2"
9+
# - "3.3"
10+
# - "3.4"
11+
# - "3.5"
12+
# - "3.5-dev" # 3.5 development branch
13+
# - "nightly" # currently points to 3.6-dev
14+
# command to install dependencies
15+
cache:
16+
directories:
17+
- $HOME/.cache/pip/wheels
18+
- $HOME/virtualenv/python2.7.9
19+
services:
20+
- mysql
21+
- postgresql
22+
addons:
23+
apt:
24+
packages:
25+
- cmake
26+
- unixodbc
27+
- unixodbc-dev
28+
- odbcinst1debian2
29+
- odbcinst
30+
- freetds-dev
31+
- freetds-bin
32+
- tdsodbc
33+
- libc6
34+
- e2fsprogs
35+
- mysql-client
36+
- libproj-dev
37+
- libgeos-dev
38+
- libspatialite-dev
39+
# mariadb: '10.1'
40+
before_script:
41+
- ./scripts/mysql_setup.sh
42+
- ./scripts/postgres_setup.sh
43+
- ./scripts/freetds.sh
44+
45+
before_install:
46+
# python -m pip makes the install go into the virtualenv
47+
- python -m pip install pandas
48+
- export PYMSSQL_BUILD_WITH_BUNDLED_FREETDS=1;python -m pip install pymssql
49+
- python -m pip install mysql-python
50+
install: # now just our code
51+
- pip install git+https://github.com/ODM2/geoalchemy.git@odm2#egg=geoalchemy-0.7.3
52+
- pip install .
53+
- pip install -r requirements_tests.txt --allow-external pyodbc --allow-unverified pyodbc
54+
# pysqlite
55+
- pip install pysqlite
56+
- pip list
57+
58+
# don't forget to open up the azure mssql server to these addreses
59+
# https://docs.travis-ci.com/user/ip-addresses/
60+
61+
# command to run tests
62+
script:
63+
64+
- py.test
65+

appveyor.yml

Lines changed: 171 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,171 @@
1+
environment:
2+
# patterned after: https://github.com/ogrisel/python-appveyor-demo/blob/master/appveyor.yml
3+
global:
4+
# SDK v7.0 MSVC Express 2008's SetEnv.cmd script will fail if the
5+
# /E:ON and /V:ON options are not enabled in the batch script intepreter
6+
# See: http://stackoverflow.com/a/13751649/163740
7+
CMD_IN_ENV: "cmd /E:ON /V:ON /C .\\appveyor\\run_with_env.cmd"
8+
# postgres
9+
POSTGRES_PORT: tcp://localhost:5432
10+
POSTGRES_ENV_POSTGRES_USER: postgres
11+
POSTGRES_ENV_POSTGRES_PASSWORD: Password12!
12+
POSTGRES_ENV_POSTGRES_DB: odm2
13+
POSTGRES_PATH: C:\Program Files\PostgreSQL\9.4
14+
PGUSER: postgres
15+
PGPASSWORD: Password12!
16+
# mysql
17+
MYSQL_PORT: tcp://localhost:3306
18+
MYSQL_ENV_MYSQL_USER: root
19+
MYSQL_ENV_MYSQL_PASSWORD: Password12!
20+
MYSQL_ENV_MYSQL_DATABASE: odm2
21+
MYSQL_PATH: C:\Program Files\MySql\MySQL Server 5.6
22+
MYSQL_PWD: Password12!
23+
# sql server
24+
SQLSERVER_ENV_SQLSERVER_HOST: localhost
25+
SQLSERVER_ENV_SQLSERVER_PORT: 1433
26+
SQLSERVER_ENV_SQLSERVER_USER: sa
27+
SQLSERVER_ENV_SQLSERVER_PASSWORD: Password12!
28+
SQLSERVER_ENV_SQLSERVER_DATABASE: odm2
29+
matrix:
30+
31+
32+
# Pre-installed Python versions, which Appveyor may upgrade to
33+
# a later point release.
34+
# See: http://www.appveyor.com/docs/installed-software#python
35+
36+
37+
matrix:
38+
- PYTHON: "C:\\Python27-conda32"
39+
PYTHON_VERSION: "2.7"
40+
PYTHON_ARCH: "32"
41+
42+
- PYTHON: "C:\\Python34-conda64"
43+
PYTHON_VERSION: "3.4"
44+
PYTHON_ARCH: "64"
45+
46+
services:
47+
- mssql2008r2sp2
48+
- mysql
49+
- postgresql
50+
51+
install:
52+
# If there is a newer build queued for the same PR, cancel this one.
53+
# The AppVeyor 'rollout builds' option is supposed to serve the same
54+
# purpose but it is problematic because it tends to cancel builds pushed
55+
# directly to master instead of just PR builds (or the converse).
56+
# credits: JuliaLang developers.
57+
- ps: if ($env:APPVEYOR_PULL_REQUEST_NUMBER -and $env:APPVEYOR_BUILD_NUMBER -ne ((Invoke-RestMethod `
58+
https://ci.appveyor.com/api/projects/$env:APPVEYOR_ACCOUNT_NAME/$env:APPVEYOR_PROJECT_SLUG/history?recordsNumber=50).builds | `
59+
Where-Object pullRequestId -eq $env:APPVEYOR_PULL_REQUEST_NUMBER)[0].buildNumber) { `
60+
throw "There are newer queued builds for this pull request, failing early." }
61+
- ECHO "Filesystem root:"
62+
- ps: "ls \"C:/\""
63+
64+
- ECHO "Installed SDKs:"
65+
- ps: "ls \"C:/Program Files/Microsoft SDKs/Windows\""
66+
67+
# Install Python (from the official .msi of http://python.org) and pip when
68+
# not already installed.
69+
- ps: if (-not(Test-Path($env:PYTHON))) { & appveyor\install.ps1 }
70+
71+
# Prepend newly installed Python to the PATH of this build (this cannot be
72+
# done from inside the powershell script as it would require to restart
73+
# the parent CMD process).
74+
- "SET PATH=%PYTHON%;%PYTHON%\\Scripts;%PATH%"
75+
# add databases
76+
- "SET PATH=%POSTGRES_PATH%\bin;%MYSQL_PATH%\bin;%PATH%"
77+
78+
# Check that we have the expected version and architecture for Python
79+
- "python --version"
80+
- "python -c \"import struct; print(struct.calcsize('P') * 8)\""
81+
82+
# Upgrade to the latest version of pip to avoid it displaying warnings
83+
# about it being out of date.
84+
- "pip install --disable-pip-version-check --user --upgrade pip"
85+
86+
# Install the build dependencies of the project. If some dependencies contain
87+
# compiled extensions and are not provided as pre-built wheel packages,
88+
# pip will build them from source using the MSVC compiler matching the
89+
# target Python version and architecture
90+
- "%CMD_IN_ENV% pip install -r dev-requirements.txt"
91+
92+
build_script:
93+
# Build the compiled extension
94+
- "%CMD_IN_ENV% python setup.py build"
95+
build_script:
96+
# Build the compiled extension
97+
- "%CMD_IN_ENV% python setup.py build"
98+
build_script:
99+
# postgres
100+
- createdb odm2
101+
- psql -d odm2 -a -f spec/databases/postgresql/schema/schema.sql
102+
# mysql
103+
- mysql -e "drop database test; create database odm2;" --user=root
104+
- mysql sqlectron < spec/databases/mysql/schema/schema.sql --user=root
105+
# sqlserver
106+
- ps: ./appveyor-sqlserver.ps1 SQL2008R2SP2
107+
- sqlcmd -S localhost,1433 -U sa -P Password12! -Q "CREATE DATABASE odm2" -d "master"
108+
- sqlcmd -S localhost,1433 -U sa -P Password12! -i spec/databases/sqlserver/schema/schema.sql -d "odm2"
109+
- sqlcmd -S localhost,1433 -U sa -P Password12! -Q "select table_name from information_schema.tables" -d "odm2"
110+
111+
test_script:
112+
# Run the project tests
113+
- "%CMD_IN_ENV% python setup.py nosetests"
114+
115+
language: python
116+
python:
117+
# - "2.6"
118+
- "2.7"
119+
# - "3.2"
120+
# - "3.3"
121+
# - "3.4"
122+
# - "3.5"
123+
# - "3.5-dev" # 3.5 development branch
124+
# - "nightly" # currently points to 3.6-dev
125+
# command to install dependencies
126+
127+
before_install:
128+
#https://github.com/sqlectron/sqlectron-core/blob/master/appveyor.yml
129+
- mysql -e "CREATE USER 'ODM'@'localhost' IDENTIFIED BY 'odm';GRANT ALL PRIVILEGES ON *.* TO 'ODM'@'localhost';" -uroot
130+
- mysql -e "create database IF NOT EXISTS odm2;" -uroot
131+
- mysql -e "create database IF NOT EXISTS odm2test;" -uroot
132+
- psql -U postgres -c "create extension postgis"
133+
- psql -c 'DROP DATABASE IF EXISTS odm2test;' -U postgres;
134+
- psql -c 'create database odm2test;' -U postgres;
135+
# - psql -U postgres -d odm2test -a -f ./tests/schemas/postgresql/ODM2_for_PostgreSQL.sql
136+
- psql -c 'DROP DATABASE IF EXISTS odm2;' -U postgres;
137+
- psql -c 'create database odm2;' -U postgres;
138+
# patterned after: https://github.com/ptrv/gpx2spatialite/blob/master/.travis.yml
139+
# - sudo apt-get install -y python-software-properties
140+
# - sudo apt-add-repository -y ppa:git-core/ppa
141+
# - sudo apt-add-repository -y ppa:ubuntugis/ppa
142+
# - sudo apt-get update -qq
143+
# - sudo apt-get install unixodbc unixodbc-dev tdsodbc
144+
# - sudo apt-get install freetds-dev freetds-bin
145+
# - sudo apt-get install libc6 e2fsprogs # mssql driver
146+
# Spatialiate
147+
# - sudo apt-get install -y libproj-dev libgeos-dev libspatialite-dev
148+
# - sudo ln -s /usr/lib/x86_64-linux-gnu/libspatialite.so /usr/lib/libspatialite.so
149+
# - sudo apt-get install python-scipy python-matplotlib python-pandas python-sympy python-nose
150+
# - sudo apt-get install python-matplotlib python-pandas python-nose
151+
- pip install pandas
152+
install: # now just our code
153+
- pip install git+https://github.com/ODM2/geoalchemy.git@odm2#egg=geoalchemy-0.7.3
154+
- pip install .
155+
- pip install -r requirements_tests.txt --allow-external pyodbc --allow-unverified pyodbc
156+
# pysqlite
157+
- pip install pysqlite
158+
- dir .\tests\usecasesql\littlebearriver\sampledatabases\odm2_mysql\LBR_MySQL_SmallExample.sql .\tests\usecasesql\marchantariats\marchantariats.sql
159+
- mysql --user root --verbose odm2 < .\tests\usecasesql\littlebearriver\sampledatabases\odm2_mysql\LBR_MySQL_SmallExample.sql
160+
# add -a to psql to see full log
161+
- psql -U postgres -f ./tests/usecasesql/marchantariats/marchantariats.sql
162+
163+
# don't forget to open up the azure mssql server to these addreses
164+
# https://docs.travis-ci.com/user/ip-addresses/
165+
166+
# command to run tests
167+
script:
168+
# just the connection part
169+
- py.test tests/test_connection.py
170+
- py.test
171+

distribution_notes.txt

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
2+
Testing a package
3+
* upload to pyptest: https://wiki.python.org/moin/TestPyPI
4+
https://testpypi.python.org/pypi
5+
6+
python setup.py sdist upload -r https://testpypi.python.org/pypi
7+
8+
=== testing
9+
cd dev_odm
10+
virtualenv --system-site-packages v_odmtest
11+
cd ODM2PythonAPI
12+
python setup.py install
13+
# above failed on windows... need to be able to compile code
14+
15+
=== CONDA == WINDOWS
16+
Start anaconda console
17+
conda search "^python$"
18+
conda create -n v_odm2test python=2.7.11 anaconda panadas sqlalchemy six geos pyodbc
19+
activate v_odm2test
20+
conda install -c SciTools shapely # to get binary versions
21+
22+
23+
conda remove --name v_odm2test --all
24+
# note issue solved by editing (anacona)\Scripts\activate.bat
25+
http://stackoverflow.com/questions/34818282/anaconda-prompt-loading-error-the-input-line-is-too-long
26+
===
27+
note for packaging yodatools
28+
https://gehrcke.de/2014/02/distributing-a-python-command-line-application/
29+
30+
creating the databases:
31+
connection string for spatiallite
32+
sqlite+pysqlite:///../../../ODM2PythonAPI/tests/spatialite/odm2_test.sqlite

doc/DatabaseNotes.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
Database Notes
2+
==============
3+
4+
Supported Databases:
5+
* sqlite/Spatialite
6+
* Postgres
7+
* MySql
8+
* MsSql
9+
10+
Generic Instructions:
11+
=====================
12+
# create database from Schema in ODM2 https://github.com/ODM2/ODM2/tree/master/src
13+
# determine appropriate connection string
14+
# populate database using the load_cv.py toolkit
15+
# Use YODA Tools.

doc/MySql.md

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
MySql Notes:
2+
=========
3+
On Linux, you are required to use { lower_case_table_names=1 }. It is suggested that databases should use this setting.
4+
5+
Connection String
6+
=================
7+
8+
Create DB
9+
=========
10+
11+
Populate with CV
12+
===============
13+
14+
15+
Linux Troubleshooting Notes
16+
===========================
17+
On Linux, you are required to use { lower_case_table_names=1 }.
18+
to see if this is set type:
19+
mysql --verbose -e "show variables like 'lower%';" --user=root
20+
--------------
21+
show variables like 'lower%'
22+
--------------
23+
+------------------------+-------+
24+
| Variable_name | Value |
25+
+------------------------+-------+
26+
| lower_case_file_system | OFF |
27+
| lower_case_table_names | 1 |
28+
+------------------------+-------+
29+
30+
If not you can install this line in $HOME/.my.cnf, /etc/my.cnf, or /etc/mysql/my.cnf
31+
32+
[mysqld]
33+
lower-case-table-names = 1
34+
35+
to see what files are being used by mysql:
36+
> strace mysql 2>&1 | grep cnf
37+
38+
stat("/etc/my.cnf", 0x7ffef7c8dca0) = -1 ENOENT (No such file or directory)
39+
stat("/etc/mysql/my.cnf", {st_mode=S_IFREG|0644, st_size=5232, ...}) = 0
40+
open("/etc/mysql/my.cnf", O_RDONLY|O_CLOEXEC) = 3
41+
stat("/etc/mysql/conf.d/mariadb.cnf", {st_mode=S_IFREG|0644, st_size=435, ...}) = 0
42+
open("/etc/mysql/conf.d/mariadb.cnf", O_RDONLY|O_CLOEXEC) = 4
43+
stat("/etc/mysql/conf.d/mysqld_safe_syslog.cnf", {st_mode=S_IFREG|0644, st_size=36, ...}) = 0
44+
open("/etc/mysql/conf.d/mysqld_safe_syslog.cnf", O_RDONLY|O_CLOEXEC) = 4
45+
stat("/etc/mysql/conf.d/tokudb.cnf", {st_mode=S_IFREG|0644, st_size=285, ...}) = 0
46+
open("/etc/mysql/conf.d/tokudb.cnf", O_RDONLY|O_CLOEXEC) = 4
47+
stat("/home/travis/.my.cnf", 0x7ffef7c8dca0) = -1 ENOENT (No such file or directory)

notes_sqlacodegen.txt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
2+
https://pypi.python.org/pypi/sqlacodegen
3+
4+
pip install sqlacodegen
5+
6+
sqlacodegen "mssql+pyodbc://user:password@localhost/ODM2?driver=SQL+Server+Native+Client+10.0"
7+
8+
sqlacodegen "mssql+pyodbc://user:password@localhost/ODM2_201512?driver=SQL+Server+Native+Client+10.0" --schema ODM2 --outfile generated_schema_201512.py

0 commit comments

Comments
 (0)