From 40bf20f341f71fb11b238e719544af2979163ce7 Mon Sep 17 00:00:00 2001 From: zp Date: Thu, 9 Feb 2023 18:56:00 +0800 Subject: [PATCH] v0.0.12-pre --- .github/workflows/Build.yml | 58 +++++++++++++++++++++++++++++++++++ .github/workflows/Publish.yml | 8 +++-- README.md | 2 +- appveyor.yml | 35 --------------------- mpkg/__init__.py | 2 +- mpkg/commands/cmd_doctor.py | 8 +++-- mpkg/lnktools.py | 2 +- scripts/bootstrap.py | 3 ++ scripts/edit_version.py | 7 +++++ setup.py | 8 ++--- 10 files changed, 86 insertions(+), 47 deletions(-) create mode 100644 .github/workflows/Build.yml delete mode 100644 appveyor.yml create mode 100644 scripts/bootstrap.py create mode 100644 scripts/edit_version.py diff --git a/.github/workflows/Build.yml b/.github/workflows/Build.yml new file mode 100644 index 0000000..77c8bad --- /dev/null +++ b/.github/workflows/Build.yml @@ -0,0 +1,58 @@ +name: Windows Builds + +on: + push: + branches: + - master + +permissions: + contents: write + +jobs: + build: + runs-on: windows-2022 + strategy: + matrix: + include: + - ARCH: "x86" + FILENAME: "mpkg-win32.zip" + - ARCH: "x64" + FILENAME: "mpkg-win64.zip" + steps: + - name: Checkout code + uses: actions/checkout@v3 + - name: Set up Python + uses: actions/setup-python@v4 + with: + python-version: "3.7" + architecture: ${{ matrix.ARCH }} + - name: Install dependencies + run: | + pip install . + pip install pywin32 pyinstaller + pip install setuptools --upgrade + - name: Edit version + if: startsWith(github.ref, 'refs/tags/') + run: | + python scripts\edit_version.py + - name: Build + run: | + copy scripts\bootstrap.py . + pyinstaller bootstrap.py -n mpkg --hidden-import=lxml.etree --hidden-import=bs4 --hidden-import=mpkg.parse + 7z a ${{ matrix.FILENAME }} .\dist\mpkg + - name: Upload files to AutoBuild + uses: softprops/action-gh-release@v1 + with: + tag_name: AutoBuild + files: | + ${{ matrix.FILENAME }} + - uses: actions/upload-artifact@v3 + with: + name: ${{ matrix.FILENAME }} + path: ${{ matrix.FILENAME }} + - name: Release mpkg + uses: softprops/action-gh-release@v1 + if: startsWith(github.ref, 'refs/tags/') + with: + files: | + ${{ matrix.FILENAME }} diff --git a/.github/workflows/Publish.yml b/.github/workflows/Publish.yml index 2aeff30..b6cbb1d 100644 --- a/.github/workflows/Publish.yml +++ b/.github/workflows/Publish.yml @@ -5,14 +5,17 @@ on: tags: - "v*" +permissions: + contents: write + jobs: build: runs-on: ubuntu-latest steps: - name: Checkout code - uses: actions/checkout@v2 + uses: actions/checkout@v3 - name: Set up Python - uses: actions/setup-python@v2 + uses: actions/setup-python@v4 with: python-version: "3.x" - name: Install dependencies @@ -24,5 +27,6 @@ jobs: TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }} TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }} run: | + python scripts/edit_version.py python setup.py sdist bdist_wheel python -m twine upload dist/* diff --git a/README.md b/README.md index 5b3432d..2d1cb09 100644 --- a/README.md +++ b/README.md @@ -43,7 +43,7 @@ mpkg download mpkg.download --root . 如果已安装 python3.7(或更高版本),执行 `pip install mpkg` 即可安装。[Releases](https://github.com/mpkg-project/mpkg/releases) 页面提供了用 pyinstaller 打包好的程序,但可能有未知 bug。 -如果想尝试最新版本,可通过 `pip install git+https://github.com/mpkg-project/mpkg.git` 安装 git 仓库中的版本,且对应的已打包程序可在 [此处](https://ci.appveyor.com/project/zpcc/mpkg/) 找到。 +如果想尝试最新版本,可通过 `pip install --upgrade https://github.com/mpkg-project/mpkg/archive/master.zip` 安装 git 仓库中的版本(可能需要先运行 `pip uninstall mpkg` 卸载旧版本),且对应的已打包程序可在 [此处](https://ci.appveyor.com/project/zpcc/mpkg/) 找到。 ## 配置 diff --git a/appveyor.yml b/appveyor.yml deleted file mode 100644 index a870e7b..0000000 --- a/appveyor.yml +++ /dev/null @@ -1,35 +0,0 @@ -version: 1.0.{build} -environment: - matrix: - - PYTHON: C:\Python37-x64 - FILENAME: mpkg-win64.zip - - PYTHON: C:\Python37 - FILENAME: mpkg-win32.zip -install: -- cmd: >- - %PYTHON%\python.exe -m pip install . - - %PYTHON%\python.exe -m pip install pywin32 pyinstaller - - %PYTHON%\python.exe -m pip install setuptools --upgrade - - echo from mpkg.cli import cli>installer.py - - echo cli() >> installer.py -build_script: -- cmd: >- - %PYTHON%\Scripts\pyinstaller.exe installer.py -n mpkg --hidden-import=lxml.etree --hidden-import=bs4 --hidden-import=mpkg.parse - - 7z a %FILENAME% .\dist\mpkg -artifacts: -- path: $(FILENAME) -deploy: -- provider: GitHub - tag: $(APPVEYOR_REPO_TAG_NAME) - release: Release $(APPVEYOR_REPO_TAG_NAME) - auth_token: - secure: 1EE9vIUDC17B1aAo6s/PgGCcc2njTYQHwe4EBghfR+pFCSN+NutehShpQPcHYrna - artifact: /$(FILENAME)/ - draft: false - on: - APPVEYOR_REPO_TAG: true \ No newline at end of file diff --git a/mpkg/__init__.py b/mpkg/__init__.py index ad3cf1d..17802a8 100644 --- a/mpkg/__init__.py +++ b/mpkg/__init__.py @@ -1 +1 @@ -__version__ = '0.0.11' +__version__ = '0.0.12-dev' diff --git a/mpkg/commands/cmd_doctor.py b/mpkg/commands/cmd_doctor.py index db7cc72..74c940c 100644 --- a/mpkg/commands/cmd_doctor.py +++ b/mpkg/commands/cmd_doctor.py @@ -104,7 +104,7 @@ def print_data(): print(f'SYS, MACHINE, ARCH: {SYS}, {MACHINE}, {ARCH}') print(f'\nbin_dir in PATH: {bin_available}') if not bin_available: - print(' - try: touch ~/.profile ~/.bashrc && mpkg doctor --fix-bin-env') + print(' - try: mpkg doctor --fix-bin-env') print(f"\n7z_command: {sevenzip_cmd}") if sevenzip_cmd.lstrip('"').startswith('7z_not_found'): print( @@ -125,7 +125,8 @@ def print_data(): @click.option('--fix-bin-env', is_flag=True) @click.option('--fix-7z-path', is_flag=True) def doctor(repo, fix_bin_env, fix_7z_path, new_winpath, new_test_winpath): - PreInstall() + if not GetConfig('sources'): + PreInstall() if repo: add_repo(repo) elif fix_bin_env: @@ -133,6 +134,9 @@ def doctor(repo, fix_bin_env, fix_7z_path, new_winpath, new_test_winpath): if SYS == 'Windows': add_to_hkcu_path(bin_dir) elif SYS == 'Linux': + for filepath in [Path.home()/fn for fn in ['.profile', '.bashrc']]: + if not filepath.exists(): + filepath.touch() for filepath in [Path.home()/fn for fn in ['.profile', '.bash_profile', '.bash_login', '.bashrc']]: if filepath.exists(): add_to_bash_startup(bin_dir, filepath) diff --git a/mpkg/lnktools.py b/mpkg/lnktools.py index 629f7a4..1c74ff4 100644 --- a/mpkg/lnktools.py +++ b/mpkg/lnktools.py @@ -68,7 +68,7 @@ def __init__(self): self.END_OF_STRING = '00' - self.cp = locale.getdefaultlocale()[1] + self.cp = locale.getlocale()[1] def bytes2hex(self, b): return b.hex() diff --git a/scripts/bootstrap.py b/scripts/bootstrap.py new file mode 100644 index 0000000..57851b5 --- /dev/null +++ b/scripts/bootstrap.py @@ -0,0 +1,3 @@ +from mpkg.cli import cli + +cli() diff --git a/scripts/edit_version.py b/scripts/edit_version.py new file mode 100644 index 0000000..088819a --- /dev/null +++ b/scripts/edit_version.py @@ -0,0 +1,7 @@ +with open('mpkg/__init__.py', 'r', encoding='utf-8') as f: + text = f.read() + +text = text.replace("-dev'", "'") +print(text) +with open('mpkg/__init__.py', 'w', encoding='utf-8') as f: + f.write(text) diff --git a/setup.py b/setup.py index 4e8c3ae..12e2658 100644 --- a/setup.py +++ b/setup.py @@ -1,13 +1,10 @@ import os -import re from setuptools import setup -here = os.path.abspath(os.path.dirname(__file__)) +from mpkg import __version__ -with open(os.path.join(here, 'mpkg', '__init__.py'), 'rb') as f: - __version__ = re.search( - "__version__.*'([\\d.]+)'", f.read().decode('utf-8')).groups()[0] +here = os.path.abspath(os.path.dirname(__file__)) with open(os.path.join(here, 'README.md'), 'rb') as f: readme = f.read().decode('utf-8') @@ -46,6 +43,7 @@ "Programming Language :: Python :: 3.8", "Programming Language :: Python :: 3.9", "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", 'License :: OSI Approved :: Apache Software License', ], )