diff --git a/.gitignore b/.gitignore index ae2fab65c..89113c0af 100644 --- a/.gitignore +++ b/.gitignore @@ -4,11 +4,17 @@ /README # Python distribution/packaging. +*.pyc /*.egg-info/ /build/ /dist/ +__pycache__ # Tests. *.tmp tmp.* *.tmp.* + +# For stupid packaging systems that require subdirectories. +/china_dictatorship/README.adoc +/china_dictatorship/README.html diff --git a/README.adoc b/README.adoc index 99edd0df4..b2a6a22e6 100644 --- a/README.adoc +++ b/README.adoc @@ -4914,7 +4914,7 @@ This would force China to also block package managers to block this repo. We managed to upload a Python PyPi package at: https://pypi.org/project/china-dictatorship/ but TODO needs implementing now. Usage will be as: .... -python -m pip install --user --upgrade china-dictatorship +python3 -m pip install --user --upgrade china-dictatorship china-dictatorship.py > README.html .... diff --git a/china-dictatorship.py b/china-dictatorship.py index 0a30b6d78..4519d27a1 100755 --- a/china-dictatorship.py +++ b/china-dictatorship.py @@ -1,8 +1,7 @@ -#!/usr/bin/env python +#!/usr/bin/python3 import pkg_resources -readme_html_path = pkg_resources.resource_string(__name__, 'README.html') -print(readme_html_path) +readme_html_path = pkg_resources.resource_filename('china_dictatorship', 'README.html') with open(readme_html_path) as f: print(f.read()) diff --git a/package.json b/package.json index 96da33c1c..65077e543 100644 --- a/package.json +++ b/package.json @@ -21,5 +21,5 @@ "scripts": { "prepublishOnly": "cp README.adoc README;make" }, - "version": "0.0.8" + "version": "0.0.17" } diff --git a/push-mirrors b/push-mirrors index 4291cd32e..90a2e3113 100755 --- a/push-mirrors +++ b/push-mirrors @@ -9,18 +9,23 @@ make # NPM package. # Updates package.json version, which other systems read if possible. ./push-mirrors-bump-package-json-version -git add package.json -git commit -m 'bump package.json' -git push -npm publish +#npm publish +#git add package.json # Python package. # Initial one time setup. #python -m pip install --user setuptools wheel twine +./push-mirrors-bump-setup-py-version +cp README.adoc README.html china_dictatorship python setup.py sdist bdist_wheel -# Asks for password every time. +# Asks for username and password every time, unless you setup ~/.pypirc. twine upload dist/* rm -rf build dist *.egg-info +#git add setup.py + +# Bump package versions +#git commit -m 'bump package version' +#git push git push git@gitlab.com:cirosantilli/china-dictatorship.git git push git@bitbucket.org:cirosantilli/china-dictatorship.git diff --git a/push-mirrors-bump-setup-py-version b/push-mirrors-bump-setup-py-version new file mode 100755 index 000000000..6fde99fbe --- /dev/null +++ b/push-mirrors-bump-setup-py-version @@ -0,0 +1,28 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- + +''' +https://github.com/cirosantilli/china-dictatorship#mirrors +''' + +import json +import re +import sys + +with open('package.json') as f: + package_json = json.load(f) +version_string = package_json['version'] +version_re = re.compile(" version='0.0.\d+'") +with open('setup.py', 'r') as f: + setup_py_lines = f.readlines() +setup_py_new_lines = [] +for line in setup_py_lines: + line = line.rstrip() + match = version_re.match(line) + if match: + setup_py_new_lines.append(" version='{}',".format(version_string)) + else: + setup_py_new_lines.append(line) +setup_py_new_string = '\n'.join(setup_py_new_lines) + '\n' +with open('setup.py', 'w') as f: + f.write(setup_py_new_string) diff --git a/setup.py b/setup.py index d75078561..d4c266369 100644 --- a/setup.py +++ b/setup.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 # -*- coding: utf-8 -*- ''' @@ -9,13 +9,9 @@ import json from setuptools import setup, find_packages -with open('package.json') as f: - package_json = json.load(f) -version = package_json['version'] - setup( name='china-dictatorship', - version=version, + version='0.0.17', description='2018新疆改造中心,1989六四事件,1999法轮功 ,2019 996.ICU, 2018包子露宪,2015 710律师劫,2015巴拿马文件 邓家贵,2017低端人口,2008西藏骚乱', # Fails with: "The description failed to render in the default format of reStructuredText." #long_description=readme(), @@ -26,8 +22,6 @@ setup( packages=find_packages(), include_package_data=True, scripts=['china-dictatorship.py'], - data_files=[ - 'README.adoc', - 'README.html', - ], + # data_files=['README.adoc', 'README.html'], + package_data={'china_dictatorship': ['README.adoc', 'README.html']}, )