Browse Source

python getting closer

pull/99/head
Ciro Santilli 1 year ago
parent
commit
3be31eccb4
7 changed files with 52 additions and 20 deletions
  1. +6
    -0
      .gitignore
  2. +1
    -1
      README.adoc
  3. +2
    -3
      china-dictatorship.py
  4. +1
    -1
      package.json
  5. +10
    -5
      push-mirrors
  6. +28
    -0
      push-mirrors-bump-setup-py-version
  7. +4
    -10
      setup.py

+ 6
- 0
.gitignore View File

@ -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

+ 1
- 1
README.adoc View File

@ -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
....


+ 2
- 3
china-dictatorship.py View File

@ -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())

+ 1
- 1
package.json View File

@ -21,5 +21,5 @@
"scripts": {
"prepublishOnly": "cp README.adoc README;make"
},
"version": "0.0.8"
"version": "0.0.17"
}

+ 10
- 5
push-mirrors View File

@ -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

+ 28
- 0
push-mirrors-bump-setup-py-version View File

@ -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)

+ 4
- 10
setup.py View File

@ -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']},
)

Loading…
Cancel
Save