Skip to content

Commit

Permalink
try to install file
Browse files Browse the repository at this point in the history
  • Loading branch information
3nids committed Jul 16, 2019
1 parent 612e31e commit da6d58f
Show file tree
Hide file tree
Showing 8 changed files with 58 additions and 25 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
# Sphinx documentation
docs/_build/
docs/_autosummary/
build/
dist/
*.egg-info

__pycache__/
*.pyc
Expand Down
4 changes: 3 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ env:
# github_token
- secure: "Rotw5IvMPKugnm+Ohvrt2RZNGZK2beQIg2IEfvVK+2f37QeySehs/JoekI7xMPdKtlp2TX9ZT3WY29y6E192GmarCsFjuCbJWZ0PFvOIJSb5zmjO1L3HSTbNMTCU8Kewiv0LODM9k/KoXraizOQYewnD52bjgO3BupfYcRtODuyQDYFThZ9a5S6cvEGr4iV34Uviwlm0rLvWrwncfsoKH/2WAzDdChXhNoawtJugF2OHhZcXm1gXdHPfhWiNIzpZVO01wdt4PPSOBj/cGCVXTaWN/yus8qoF3xaPzB85dsox2H34IBsllJCV+/AFjbpwJD6LZbD7tgLDknmj7ILTFG7/B/ddSuEycxcO9+C4njRVxZFxg9/Lu3No1iDA5tMpiFUbAbXPzZL013tXo4DTbth2EnaaDPtY0pwvq9yZX/Or7Z3EFsYGyKPnN3cOiT4UWrZ04fqTyeMtW7jBR+6vOKkM9rw0dJ1yAqQbNgFZ428ktB9oknHxAkKuBieXceaeC3jaT9NSOybzwvPWDh3J5OD0InsaaQF7mK8DA7F15YbrU46vEL5H5TTcz57w+TMbo/VsxVWR8rhTCR3DvzmgwAwqU0pU95m/Uj8QoZTLIaf+qCCeX/Vj0q1k/b2aWAKV7IJm3vWOPalk+TYo5FByp9RCCN8dSHcBBZfSxrALslA="

install: pip install -r requirements.txt
install:
- pip install -r requirements.txt
- python setup.py install

script:
- nose2 -v
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
<update_date>__RELEASE_DATE__</update_date>
<experimental>__EXPERIMENTAL__</experimental>
<deprecated>__DEPRECATED__</deprecated>
<tracker>https://github.com/__ORG__/__REPO__/issues</tracker>
<repository>https://github.com/__ORG__/__REPO__</repository>
<tracker>__ISSUE_TRACKER__</tracker>
<repository>__REPO__</repository>
<tags>__TAGS__</tags>
</pyqgis_plugin>
</plugins>
19 changes: 17 additions & 2 deletions qgispluginci/release.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,18 @@
from github import Github, GithubException
import xmlrpc.client
import re
import pkg_resources

from qgispluginci.parameters import Parameters
from qgispluginci.translation import Translation
from qgispluginci.utils import replace_in_file
from qgispluginci.utils import replace_in_file, configure_file
from qgispluginci.exceptions import GithubReleaseNotFound, GithubReleaseCouldNotUploadAsset


def release(parameters: Parameters,
release_version: str,
github_token: str = None,
upload_plugin_repo_github: str = False,
transifex_token: str = None,
osgeo_username: str = None,
osgeo_password: str = None):
Expand All @@ -42,8 +44,11 @@ def release(parameters: Parameters,
output = '{project_slug}-{release_version}.zip'.format(project_slug=parameters.project_slug,
release_version=release_version)
create_archive(parameters, output=output, add_translations=transifex_token is not None)
if github_token:
if github_token is not None:
upload_asset_to_github_release(parameters, archive=output, release_tag=release_version, github_token=github_token)
if upload_plugin_repo_github:
xml_repo = create_plugin_repo()

if osgeo_username is not None:
assert osgeo_password is not None
upload_plugin_to_osgeo(username=osgeo_username, password=osgeo_password, archive=output)
Expand Down Expand Up @@ -133,6 +138,16 @@ def upload_asset_to_github_release(parameters: Parameters,
raise GithubReleaseCouldNotUploadAsset('Could not upload asset for release {}.'.format(release_tag))


def create_plugin_repo() -> str:
"""
Creates the plugin repo as an XML file
"""
xml_template = pkg_resources.resource_filename('qgispluginci', 'plugins.xml.template')
_, xml_repo = mkstemp(suffix='.xml')
configure_file(xml_template, xml_repo, {})
return xml_repo


def upload_plugin_to_osgeo(username: str, password: str, archive: str):
"""
Upload the plugin to QGIS repository
Expand Down
9 changes: 9 additions & 0 deletions qgispluginci/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,15 @@ def replace_in_file(file_path: str, pattern: str, new: str, encoding = "utf8"):
f.write(content)


def configure_file(source_file: str, dest_file: str, replace: dict):
with open(source_file, 'r') as f:
content = f.read()
for pattern, new in replace.items():
content = re.sub(pattern, new, content, flags=re.M)
with open(dest_file, 'w') as f:
f.write(content)


def touch_file(path, update_time: bool = False, create_dir: bool = True):
basedir = os.path.dirname(path)
if create_dir and not os.path.exists(basedir):
Expand Down
13 changes: 7 additions & 6 deletions scripts/qgis-plugin-ci
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ if __name__ == "__main__":
release_parser.add_argument('--github-token', help='The Github API token. '
'If specified, the archive will be pushed to an already '
'existing release.')
release_parser.add_argument('--create-plugin-repo', action='store_true',
help='Will create a XML repo as a Github release asset. Github token is required.')


# pull-translation
Expand Down Expand Up @@ -56,19 +58,18 @@ if __name__ == "__main__":
success = release(parameters,
release_version=args.release_version,
transifex_token=args.transifex_token,
github_token=args.github_token)
github_token=args.github_token,
upload_plugin_repo_github=args.create_plugin_repo)
if not success:
exit_val = 1
elif args.command == 'pull-translation':
success = Translation(parameters, args.transifex_token).pull()
if not success:
exit_val = 1
success = Translation(parameters, args.transifex_token).pull()
if not success:
exit_val = 1
elif args.command == 'push-translation':
t = Translation(parameters, args.transifex_token)
t.update_strings()
t.push()
if not success:
exit_val = 1

exit(exit_val)

28 changes: 15 additions & 13 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from setuptools import setup
import sys

python_min_version = (3, 7)
python_min_version=(3, 7)

if sys.version_info < python_min_version:
sys.exit('qgis-plugin-ci requires at least Python version {vmaj}.{vmin}.\n'
Expand All @@ -11,28 +11,30 @@
curver=sys.version))

setup(
name = 'qgis-plugin-ci',
packages = [
name='qgis-plugin-ci',
packages=[
'qgispluginci'
],
scripts = [
scripts=[
'scripts/qgis-plugin-ci'
],
version = '[VERSION]',
description = 'Let QGIS-plugin-ci package and release your QGIS plugins for you.',
author = 'Denis Rouzaud',
author_email = 'denis.rouzaud@gmail.com',
url = 'https://github.com/opengisch/qgis-plugin-ci',
download_url = 'https://github.com/opengisch/qgis-plugin-ci/archive/[VERSION].tar.gz', # I'll explain this in a second
keywords = ['QGIS'],
classifiers = [
package_data={'': ['plugins.xml.template']},
include_package_data=True, # required for files in MANIFEST.in
version='[VERSION]',
description='Let QGIS-plugin-ci package and release your QGIS plugins for you. Have a tea or go skiing meanwhile.',
author='Denis Rouzaud',
author_email='denis.rouzaud@gmail.com',
url='https://github.com/opengisch/qgis-plugin-ci',
download_url='https://github.com/opengisch/qgis-plugin-ci/archive/[VERSION].tar.gz',
keywords=['QGIS'],
classifiers=[
'Topic :: Scientific/Engineering :: GIS',
'License :: OSI Approved :: GNU General Public License v3 or later (GPLv3+)',
'Intended Audience :: System Administrators',
'Intended Audience :: Information Technology',
'Development Status :: 3 - Alpha'
],
install_requires = [
install_requires=[
'python-slugify',
'pyyaml',
'pytransifex',
Expand Down
3 changes: 2 additions & 1 deletion test/test_release.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def test_release_with_transifex(self):
release(self.parameters, RELEASE_VERSION_TEST, transifex_token=self.transifex_token)

def test_release_upload_github(self):
release(self.parameters, RELEASE_VERSION_TEST, github_token=self.github_token)
release(self.parameters, RELEASE_VERSION_TEST, github_token=self.github_token, upload_plugin_repo_github=True)

gh_release = self.repo.get_release(id=RELEASE_VERSION_TEST)
archive_name = 'qgis-plugin-ci-{}.zip'.format(RELEASE_VERSION_TEST)
Expand All @@ -63,5 +63,6 @@ def test_release_upload_github(self):
self.assertTrue(False, 'asset not found')



if __name__ == '__main__':
unittest.main()

0 comments on commit da6d58f

Please sign in to comment.