Skip to content

Commit

Permalink
[FEATURE] Introduce PyPI setup to distribute python package (#117)
Browse files Browse the repository at this point in the history
* [FIX] Adjust documentation from #115 and #119 (#120)

* replace occurences of old values to wahoo_mc

- "common_"...
- "wahoo_maps_creator"

* adjust docs to the user directory

* introduce config files for pypi
- gitignore build-files

* adjust conda .yml files according to PyPI setup

- gdal-user.yml according to setup.cfg
- gdal-dev.yml for publish packages

* Bump to version v2.0.0a2

* align the package folder to the package name

- rename wahoo_mc to wahoo-mc

* Bump to version v2.0.0a3

* Revert "align the package folder to the package name"

This reverts commit 95a32cd.

* rename to mahoomc

* Bump to version v2.0.0a4

* temp documentation

* Bump to version v2.0.0a5

* add upgrading wahoomc via pip

* add commands to publish the release to PyPI

BREAKING CHANGE:
The GUI and CLI of wahooMapsCreator will now be called differently than
before:
- `python wahoomc gui` and
- `python wahoomc cli -co malta`
  • Loading branch information
treee111 committed May 8, 2022
1 parent 32f7235 commit a947b9f
Show file tree
Hide file tree
Showing 424 changed files with 202 additions and 101 deletions.
21 changes: 20 additions & 1 deletion .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,11 @@
- [Squash Commit Summary](#squash-commit-summary)
- [Release](#release)
- [Automatic CHANGELOG creation](#automatic-changelog-creation)
- [PyPI commands](#pypi-commands)
- [Structure of the repository](#structure-of-the-repository)
- [User directory](#user-directory)
- [Anaconda environment](#anaconda-environment)
- [Other command](#other-command)

## How to Contribute
1. Create a branch by forking the repository and apply your change.
Expand Down Expand Up @@ -74,6 +76,17 @@ To generate the CHANGELOG.md for a upcoming release (no tag exists yet), the fol
git-chglog -o CHANGELOG.md --next-tag v0.10.0
```

### PyPI commands
1. Change the version in setup.cfg and gdal-user.yml
2. Build a new release to publish to PyPI:
```
py -m build
```
3. Publish these files to PyPI:
```
twine upload dist\*
```

## Structure of the repository
There is one python coding base for both Windows and for macOS.
Differences between the different OS are the used programs.
Expand Down Expand Up @@ -105,4 +118,10 @@ conda env export > environment.yml

The installation of Anaconda envirionments is described [here](docs/QUICKSTART_ANACONDA.md)

more information on [documentation for sharing Anaconda environments](https://conda.io/projects/conda/en/latest/user-guide/tasks/manage-environments.html#exporting-an-environment-file-across-platforms)
more information on [documentation for sharing Anaconda environments](https://conda.io/projects/conda/en/latest/user-guide/tasks/manage-environments.html#exporting-an-environment-file-across-platforms)

## Other command
Run pylint for all relevant directories/files
```
pylint -j 0 ./wahoomc ./tests
```
30 changes: 15 additions & 15 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,18 @@ jobs:
matrix:
python-version: ["3.9", "3.10"]
steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v3
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install pylint
pip install mock
pip install requests
- name: Analysing the code with pylint
run: |
pylint -j 0 ./wahoo_mc ./tests
continue-on-error: false
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v3
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install pylint
pip install mock
pip install requests
- name: Analysing the code with pylint
run: |
pylint -j 0 ./wahoomc ./tests
continue-on-error: false
11 changes: 8 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
/!.vscode/settings.json

# top level
/dist
/envs
osmconvert_tempfile.*

# in all folders
Expand All @@ -17,4 +15,11 @@ osmconvert_tempfile.*
# mac/unix

#windows
/wahoo_mc/tooling_win/osmconvert_tempfile.*
/wahoomc/tooling_win/osmconvert_tempfile.*

# build artefacts
*.pyc
.eggs/
/wahoomc.egg-info/
/dist/
/build/
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,11 @@ conda activate gdal-user
```
Run wahooMapsCreator via GUI
```
python -m wahoo_mc gui
python -m wahoomc gui
```
Or run wahooMapsCreator via CLI
```
python -m wahoo_mc cli -co malta
python -m wahoomc cli -co malta
```

A detailled description of the usage is documented [:computer: here](docs/USAGE.md#usage-of-wahoomapscreator)
Expand Down
5 changes: 5 additions & 0 deletions conda_env/gdal-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,8 @@ dependencies:
- geojson=2.5.*
- shapely=1.8.*
- autopep8=1.6.*
- mock
- twine
- pip
- pip:
- build
5 changes: 3 additions & 2 deletions conda_env/gdal-user.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,6 @@ dependencies:
- python=3.7
- geojson=2.5.*
- gdal=3.4.*
- requests=2.27.*
- shapely=1.8.*
- pip
- pip:
- wahoomc==2.0.0a5
16 changes: 8 additions & 8 deletions copyFilesToDist.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,19 +20,19 @@ cd ../..
cd dist/${FOLDER_NAME_MAC}

# create empty sub-folders
mkdir -p ./wahoo_mc
mkdir -p ./wahoo_mc/resources
mkdir -p ./wahoomc
mkdir -p ./wahoomc/resources
mkdir -p ./conda_env
mkdir -p ./tooling
mkdir -p ./docs

# copy files into dist-folder
cp -a ../../wahoo_mc/*.py ./wahoo_mc/
cp -a ../../wahoo_mc/resources/*.xml ./wahoo_mc/resources/
cp -a ../../wahoo_mc/resources/*.osm ../../wahoo_mc/resources/*.py ./wahoo_mc/resources/
cp -a ../../wahoo_mc/resources/json/ ./wahoo_mc/resources/json
cp -a ../../wahoo_mc/resources/tag_wahoo_adjusted/ ./wahoo_mc/resources/tag_wahoo_adjusted
cp -a ../../wahoo_mc/resources/tag_wahoo_initial/ ./wahoo_mc/resources/tag_wahoo_initial
cp -a ../../wahoomc/*.py ./wahoomc/
cp -a ../../wahoomc/resources/*.xml ./wahoomc/resources/
cp -a ../../wahoomc/resources/*.osm ../../wahoomc/resources/*.py ./wahoomc/resources/
cp -a ../../wahoomc/resources/json/ ./wahoomc/resources/json
cp -a ../../wahoomc/resources/tag_wahoo_adjusted/ ./wahoomc/resources/tag_wahoo_adjusted
cp -a ../../wahoomc/resources/tag_wahoo_initial/ ./wahoomc/resources/tag_wahoo_initial

cp -a ../../docs/*.md ./docs/
cp -a ../../CHANGELOG.md ../../README.md ./
Expand Down
48 changes: 43 additions & 5 deletions docs/QUICKSTART_ANACONDA.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,13 @@
- [homebrew](#homebrew)
- [OSM-tools](#osm-tools)
- [wahooMapsCreator](#wahoomapscreator)
- [Create Anaconda Environment](#create-anaconda-environment)
- [Create Anaconda Environment](#create-anaconda-environment)
- [Install wahooMapsCreator into Anaconda environment](#install-wahoomapscreator-into-anaconda-environment)
- [Update wahooMapsCreator](#update-wahoomapscreator)
- [Run wahooMapsCreator](#run-wahoomapscreator)
- [Archive](#archive)
- [old but still valid way to get wahooMapsCreator](#old-but-still-valid-way-to-get-wahoomapscreator)
- [Create Anaconda Environment](#create-anaconda-environment-1)

# Download and Install required programs

Expand Down Expand Up @@ -54,11 +59,45 @@ brew install osmosis
* more information: https://github.com/mapsforge/mapsforge/blob/master/docs/Getting-Started-Map-Writer.md#plugin-installation

# wahooMapsCreator
Download the latest .zip file from the [Releases](https://github.com/treee111/wahooMapsCreator/releases) page for your OS and save the folder on your drive. Extract the folder.
## Create Anaconda Environment
1. Open terminal (macOS/Linux) or **Anaconda Prompt** (Windows, via Startmenu)
2. Create a new Anaconda environment with needed packages
```
conda create -n gdal-user python=3.7 geojson=2.5.* gdal=3.4.* pip --channel conda-forge
```
3. activate Anaconda environment with the command printed out (this needs to be done each time you want to use wahooMapsCreator maps)
```
conda activate gdal-user
```

## Install wahooMapsCreator into Anaconda environment
```
pip install wahoomc
```

### Update wahooMapsCreator
If you have wahooMapsCreator already installed via pip and you want to install a newer version this can be done via:
```
pip install wahoomc --upgrade
```

If you want to upgrade to a version other than the release actual one, use this command:
```
pip install wahoomc==2.0.0a5 --upgrade
```

# Run wahooMapsCreator
Run wahooMapsCreater as described in the [README](../README.md/#Run-wahooMapsCreator)


# Archive
## old but still valid way to get wahooMapsCreator
This was the way to install wahooMapsCreator until release v1.1.1

Download the latest .zip file from the [Releases](https://github.com/treee111/wahooMapsCreator/releases) page for your OS and save the folder on your drive. Extract the folder.
You can also clone the repository to have the latest coding.

# Create Anaconda Environment
### Create Anaconda Environment
1. Open (or change to) the root of the extracted wahooMapsCreator folder in terminal (macOS/Linux) or **Anaconda Prompt** (Windows, via Startmenu)
2. Create a new Anaconda environment via

Expand All @@ -77,5 +116,4 @@ conda activate gdal-user

Additional informations: https://opensourceoptions.com/blog/how-to-install-gdal-with-anaconda/

# Run wahooMapsCreator
Run wahooMapsCreater as described in the [README](../README.md/#Run-wahooMapsCreator)
continue with [Run wahooMapsCreator](#run-wahoomapscreator) to use wahooMapsCreator
24 changes: 13 additions & 11 deletions docs/USAGE.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,16 @@ wahooMapsCreator can be used in two different ways:

Both ways support the same arguments to be used for the map-creation process. You can choose the arguments via GUI or as [CLI-arguments](#advanced-cli-usage).

### Always activate environment first

## Run wahooMapsCreator for your country
It might be a good idea to run wahooMapsCreator first for a small country e.g. Malta to check if everything is running fine.
In a next step you can run it for your own country.

## GUI (Graphical User Interface)

From the `root` folder of wahooMapsCreator, run:
- `python -m wahoo_mc gui`
- `python -m wahoomc gui`

Set your arguments as required via the window:

Expand All @@ -21,34 +23,34 @@ Set your arguments as required via the window:
## CLI (Command Line Interface)

From the `root` folder of wahooMapsCreator, run:
- `python -m wahoo_mc cli -co <country_name>`
- `python -m wahoomc cli -co <country_name>`

Examples:
- for Malta: `python -m wahoo_mc cli -co malta`
- for Ireland: `python -m wahoo_mc cli -co ireland`
- for Malta: `python -m wahoomc cli -co malta`
- for Ireland: `python -m wahoomc cli -co ireland`

## Advanced CLI-Usage
The script supports many arguments via command line.
For a list of all supported arguments, run:
- `python -m wahoo_mc cli -h`
- `python -m wahoomc cli -h`

### Main arguments
**Create maps for a country**
- `python -m wahoo_mc cli -co <country>`
- `python -m wahoomc cli -co <country>`

**Create maps for X/Y coordinates**

In particular for testing adjustments in configuration-files or coding it is helpful to create maps for only one tile or a handful of tiles!

To create maps for only one tile and not a whole country, one can use the X/Y coordinates of that tile. X/Y coordinates can be retrieved from this in zoom-level 8: [link](http://tools.geofabrik.de/map/#8/50.3079/8.8026&type=Geofabrik_Standard&grid=1).
- `python -m wahoo_mc cli -xy <xy_coordinate,xy_coordinate>`
- `python -m wahoomc cli -xy <xy_coordinate,xy_coordinate>`

### Examples
- for Malta, download new maps if existing maps are older than 100 days and process files even if files exist
- `python -m wahoo_mc cli -co malta -md 100 -fp`
- `python -m wahoomc cli -co malta -md 100 -fp`
- for Germany, download and process whole tiles which involves other countries than the given
- `python -m wahoo_mc cli -co germany -bc`
- `python -m wahoomc cli -co germany -bc`
- to create maps for only one tile
- `python -m wahoo_mc cli -xy 134/88`
- `python -m wahoomc cli -xy 134/88`
- for multiple tiles
- `python -m wahoo_mc cli -xy 134/88,133/88`
- `python -m wahoomc cli -xy 134/88,133/88`
6 changes: 6 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[build-system]
requires = [
"setuptools>=42",
"wheel"
]
build-backend = "setuptools.build_meta"
25 changes: 25 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
[metadata]
name = wahoomc
version = 2.0.0a5
author = Benjamin Kreuscher
author_email = [email protected]
description = Create maps for your Wahoo bike computer based on latest OSM maps
long_description = file: README.md
long_description_content_type = text/markdown
url = https://github.com/treee111/wahooMapsCreator
project_urls =
Bug Tracker = https://github.com/treee111/wahooMapsCreator/issues
classifiers =
Programming Language :: Python :: 3
License :: OSI Approved :: MIT License
Operating System :: OS Independent

[options]
packages = wahoomc
python_requires = >=3.7
install_requires =
requests==2.27.*
shapely==1.8.*

[options.package_data]
wahoomc = resources/*.*, resources/**/*.*, resources/*/*/*.*, resources/*/*/*/*.*
6 changes: 3 additions & 3 deletions tests/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def test_top_parser_help(self):
tests, if help of top parser can be called
"""

result = os.system("python -h wahoo_mc -h")
result = os.system("python -h wahoomc -h")

self.assertEqual(result, 0)

Expand All @@ -26,7 +26,7 @@ def test_cli_help(self):
tests, if CLI help can be called
"""

result = os.system("python -h wahoo_mc cli -h")
result = os.system("python -h wahoomc cli -h")

self.assertEqual(result, 0)

Expand All @@ -35,7 +35,7 @@ def test_gui_help(self):
tests, if GUI help can be called
"""

result = os.system("python -h wahoo_mc gui -h")
result = os.system("python -h wahoomc gui -h")

self.assertEqual(result, 0)

Expand Down
Loading

0 comments on commit a947b9f

Please sign in to comment.