From 91ec74124f5eb87fff2cc2eaf6b98b039f17379d Mon Sep 17 00:00:00 2001 From: Yusuf Khan Date: Fri, 8 Sep 2023 09:58:59 -0700 Subject: [PATCH] reverting --- .github/workflows/build-apple-silicon.yml | 84 +++++++++++------------ .github/workflows/build-linux.yml | 76 -------------------- .github/workflows/build-win-mac.yml | 72 ------------------- .github/workflows/build.yml | 53 +++++++------- setup.py | 5 +- setup/post_install.py | 71 ++----------------- 6 files changed, 81 insertions(+), 280 deletions(-) delete mode 100644 .github/workflows/build-linux.yml delete mode 100644 .github/workflows/build-win-mac.yml diff --git a/.github/workflows/build-apple-silicon.yml b/.github/workflows/build-apple-silicon.yml index d5f4275..75f5c8f 100644 --- a/.github/workflows/build-apple-silicon.yml +++ b/.github/workflows/build-apple-silicon.yml @@ -1,50 +1,50 @@ -# name: Build and Publish for Apple Silicon +name: Build and Publish for Apple Silicon -# on: -# push: -# branches: -# - main -# pull_request: -# types: -# - closed +on: + push: + branches: + - main + pull_request: + types: + - closed -# jobs: -# build_wheels_macos: -# name: Build wheels on macos-11 -# runs-on: macos-11 -# steps: -# - uses: actions/checkout@v3 +jobs: + build_wheels_macos: + name: Build wheels on macos-11 + runs-on: macos-11 + steps: + - uses: actions/checkout@v3 -# - name: Build wheels -# uses: pypa/cibuildwheel@v2.13.0 -# env: -# CIBW_ARCHS_MACOS: x86_64 arm64 + - name: Build wheels + uses: pypa/cibuildwheel@v2.13.0 + env: + CIBW_ARCHS_MACOS: x86_64 arm64 -# - uses: actions/upload-artifact@v3 -# with: -# path: ./wheelhouse/*.whl + - uses: actions/upload-artifact@v3 + with: + path: ./wheelhouse/*.whl -# upload_pypi: -# needs: build_wheels_macos -# runs-on: ubuntu-latest -# if: github.event_name == 'push' && github.ref == 'refs/heads/main' -# steps: -# - name: Download wheels -# uses: actions/download-artifact@v2 -# with: -# name: artifact -# path: dist/ + upload_pypi: + needs: build_wheels_macos + runs-on: ubuntu-latest + if: github.event_name == 'push' && github.ref == 'refs/heads/main' + steps: + - name: Download wheels + uses: actions/download-artifact@v2 + with: + name: artifact + path: dist/ -# - name: Set up Python -# uses: actions/setup-python@v2 -# with: -# python-version: 3.9 + - name: Set up Python + uses: actions/setup-python@v2 + with: + python-version: 3.9 -# - name: Install twine -# run: python -m pip install twine + - name: Install twine + run: python -m pip install twine -# - name: Publish wheels to PyPI -# run: twine upload --skip-existing --repository-url https://upload.pypi.org/legacy/ dist/*.whl -# env: -# TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }} -# TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }} + - name: Publish wheels to PyPI + run: twine upload --skip-existing --repository-url https://upload.pypi.org/legacy/ dist/*.whl + env: + TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }} + TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }} diff --git a/.github/workflows/build-linux.yml b/.github/workflows/build-linux.yml deleted file mode 100644 index 2d11460..0000000 --- a/.github/workflows/build-linux.yml +++ /dev/null @@ -1,76 +0,0 @@ -# name: Build and Publish Linux - -# on: -# push: -# branches: -# - main -# pull_request: -# types: -# - closed - -# jobs: -# build_wheels: -# runs-on: ubuntu-latest - -# steps: -# - uses: actions/checkout@v2 - -# - name: Set up Python -# uses: actions/setup-python@v2 -# with: -# python-version: 3.8 - -# - name: Install build dependencies -# run: python -m pip install build - -# - name: Build wheel -# run: python -m build --wheel - -# - name: Upload artifact -# uses: actions/upload-artifact@v2 -# with: -# name: wheels-linux -# path: dist/*.whl - -# build_sdist: -# runs-on: ubuntu-latest - -# steps: -# - uses: actions/checkout@v2 - -# - name: Set up Python -# uses: actions/setup-python@v2 -# with: -# python-version: 3.8 - -# - name: Install build dependencies -# run: python -m pip install build - -# - name: Build sdist -# run: python -m build --sdist - -# - uses: actions/upload-artifact@v2 -# with: -# name: sdist -# path: dist/*.tar.gz - -# upload_pypi: -# needs: [build_wheels, build_sdist] -# runs-on: ubuntu-latest -# if: github.event.pull_request.merged == true || github.ref == 'refs/heads/main' - -# steps: -# - uses: actions/download-artifact@v2 -# with: -# name: wheels-linux -# path: dist - -# - uses: actions/download-artifact@v2 -# with: -# name: sdist -# path: dist - -# - uses: pypa/gh-action-pypi-publish@v1.5.0 -# with: -# user: ${{ secrets.PYPI_USERNAME }} -# password: ${{ secrets.PYPI_PASSWORD }} \ No newline at end of file diff --git a/.github/workflows/build-win-mac.yml b/.github/workflows/build-win-mac.yml deleted file mode 100644 index 43c43b2..0000000 --- a/.github/workflows/build-win-mac.yml +++ /dev/null @@ -1,72 +0,0 @@ -name: Build and Publish Mac and Windows - -on: - push: - branches: - - main - pull_request: - types: - - closed - -jobs: - build_wheels: - name: Build wheels on ${{ matrix.os }} - runs-on: ${{ matrix.os }} - strategy: - matrix: - os: [windows-latest, macos-latest] - - steps: - - name: Checkout code - uses: actions/checkout@v2 - - - name: Set up Python - uses: actions/setup-python@v2 - with: - python-version: 3.8 - - - name: Install cibuildwheel - run: | - python -m pip install cibuildwheel - - name: Build wheel - run: | - python -m cibuildwheel --output-dir wheelhouse - env: - CIBW_BUILD: cp38-* - - - name: Upload artifact - uses: actions/upload-artifact@v2 - with: - name: wheels-${{ matrix.os }} - path: ./wheelhouse/*.whl - - upload_wheels: - needs: build_wheels - runs-on: ubuntu-latest - if: github.event.pull_request.merged == true || github.ref == 'refs/heads/main' - steps: - - name: Download wheels - uses: actions/download-artifact@v2 - with: - name: wheels-windows-latest - path: dist/ - - name: Download wheels - uses: actions/download-artifact@v2 - with: - name: wheels-macos-latest - path: dist/ - - - name: Set up Python 3.8 - uses: actions/setup-python@v2 - with: - python-version: 3.8 - - - name: Install twine - run: python -m pip install twine - - - name: Publish wheels to PyPI - run: | - twine upload --skip-existing --repository-url https://upload.pypi.org/legacy/ dist/*.whl - env: - TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }} - TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }} \ No newline at end of file diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index dba58ad..43c43b2 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,18 +1,20 @@ -name: Build and Publish Source Distribution +name: Build and Publish Mac and Windows on: push: branches: - main - - develop pull_request: types: - closed jobs: - build_sdist: - name: Build source distribution - runs-on: ubuntu-latest + build_wheels: + name: Build wheels on ${{ matrix.os }} + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [windows-latest, macos-latest] steps: - name: Checkout code @@ -23,28 +25,35 @@ jobs: with: python-version: 3.8 - - name: Build sdist + - name: Install cibuildwheel + run: | + python -m pip install cibuildwheel + - name: Build wheel run: | - pip install wheel - python setup.py sdist - mkdir -p dists - mv dist/*.tar.gz dists/ + python -m cibuildwheel --output-dir wheelhouse + env: + CIBW_BUILD: cp38-* - name: Upload artifact uses: actions/upload-artifact@v2 with: - name: sdist - path: ./dists/*.tar.gz + name: wheels-${{ matrix.os }} + path: ./wheelhouse/*.whl - upload_sdist: - needs: build_sdist + upload_wheels: + needs: build_wheels runs-on: ubuntu-latest - if: github.event.pull_request.merged == true || github.ref == 'refs/heads/main' || github.ref == 'refs/heads/develop' + if: github.event.pull_request.merged == true || github.ref == 'refs/heads/main' steps: - - name: Download sdist + - name: Download wheels + uses: actions/download-artifact@v2 + with: + name: wheels-windows-latest + path: dist/ + - name: Download wheels uses: actions/download-artifact@v2 with: - name: sdist + name: wheels-macos-latest path: dist/ - name: Set up Python 3.8 @@ -55,13 +64,9 @@ jobs: - name: Install twine run: python -m pip install twine - - name: Publish sdist to PyPI + - name: Publish wheels to PyPI run: | - if [ "${{ github.ref }}" = "refs/heads/develop" ]; then - twine upload --skip-existing --repository-url https://test.pypi.org/legacy/ dist/*.tar.gz - else - twine upload --skip-existing --repository-url https://upload.pypi.org/legacy/ dist/*.tar.gz - fi + twine upload --skip-existing --repository-url https://upload.pypi.org/legacy/ dist/*.whl env: TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }} - TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }} + TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }} \ No newline at end of file diff --git a/setup.py b/setup.py index 73611c2..671fbc1 100644 --- a/setup.py +++ b/setup.py @@ -7,10 +7,12 @@ class bdist_wheel(_bdist_wheel): def finalize_options(self): _bdist_wheel.finalize_options(self) + # Mark us as not a pure python package self.root_is_pure = False def get_tag(self): python, abi, plat = _bdist_wheel.get_tag(self) + # We don't contain any python source python, abi = 'py2.py3', 'none' return python, abi, plat @@ -19,6 +21,7 @@ class PostInstallCommand(install): """Post-installation for installation mode.""" def run(self): install.run(self) + # RUN CUSTOM POST-INSTALL SCRIPT HERE setup_dir = os.path.dirname(os.path.realpath(__file__)) post_install_script = os.path.join(setup_dir, 'setup', 'post_install.py') os.system(f"python {post_install_script}") @@ -28,7 +31,7 @@ def run(self): setup( name="azpype", - version="0.3.8", + version="0.3.9", description="A native Python interface wrapping AzCopy for bulk data transfer to and from Azure Blob Storage.", long_description=open('README.md', encoding="UTF-8").read(), long_description_content_type='text/markdown', diff --git a/setup/post_install.py b/setup/post_install.py index 226dc06..3b2a479 100644 --- a/setup/post_install.py +++ b/setup/post_install.py @@ -1,82 +1,25 @@ -# import requests -# from pathlib import Path -# import platform -# import traceback -# import urllib3 -# urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning) - - -# def download_file(url, target_path): -# response = requests.get(url, stream=True, verify=False) -# response.raise_for_status() -# with open(target_path, 'wb') as file: -# for chunk in response.iter_content(chunk_size=8192): -# file.write(chunk) - -# # def main(): -# print("Post-install Script Starting ...") -# try: -# home = Path.home() -# dir = home / '.azpype' -# dir.mkdir(parents=True, exist_ok=True) -# print("Azpype directory created at: ", dir) - -# config_template_base_url = "https://github.com/yusuf-jkhan1/azpype/blob/main/setup/assets/config_templates" -# config_template_files = ["copy_config.yaml"] # Add more when/if needed - -# for config_file in config_template_files: -# download_file(f"{config_template_base_url}/{config_file}?raw=true", dir / config_file) - -# binary_base_url = "https://github.com/yusuf-jkhan1/azpype/blob/main/setup/assets/bin" -# binary_name = None - -# if platform.system() == 'Darwin': -# binary_name = 'azcopy_darwin_amd64_10.18.1/azcopy' -# elif platform.system() == 'Windows': -# binary_name = 'azcopy_windows_amd64_10.18.1/azcopy.exe' -# elif platform.system() == 'Linux': -# if platform.machine() == 'x86_64': -# binary_name = 'azcopy_linux_amd64_10.18.1/azcopy' -# elif platform.machine() == 'aarch64': -# binary_name = 'azcopy_linux_arm64_10.18.1/azcopy' - -# print("Detected Platform: ", platform.system()) -# if binary_name: -# print(f"Downloading AzCopy binary: {binary_name}") -# download_file(f"{binary_base_url}/{binary_name}?raw=true", dir / binary_name.split('/')[-1]) - -# except Exception as e: -# print(f"An error occurred: {e}") -# traceback.print_exc() - -# if __name__ == "__main__": -# main() - import os from pathlib import Path import shutil import platform - -print("Post-install Script Starting ...") - +# Get the home directory in a platform independent way home = Path.home() dir = home / '.azpype' +# Make the directory if it does not exist dir.mkdir(parents=True, exist_ok=True) -print("Azpype directory created at: ", dir) - +# Get the location of the setup.py (current script directory) setup_dir = Path(os.path.dirname(os.path.realpath(__file__))) +# Copy all files from setup/assets/config_templates to the directory src_dir = setup_dir / 'assets' / 'config_templates' for file_path in src_dir.glob('*'): if file_path.is_file(): shutil.copy(file_path, dir) - -print("Detected Platform: ", platform.system()) - +# Copy the azcopy file to the directory src_file = None if platform.system() == 'Darwin': src_file = setup_dir / 'assets' / 'bin' / 'azcopy_darwin_amd64_10.18.1' / 'azcopy' @@ -89,6 +32,4 @@ src_file = setup_dir / 'assets' / 'bin' / 'azcopy_linux_arm64_10.18.1' / 'azcopy' if src_file is not None: - shutil.copy(src_file, dir) - -print("Post-install Script Complete!") \ No newline at end of file + shutil.copy(src_file, dir) \ No newline at end of file