Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Restructure the Project to Follow Best Python Packaging Practices #23

Merged
merged 29 commits into from
Oct 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
9acc09c
Initial restructuring
jmwright Oct 23, 2023
109f14f
Black formatting pass
jmwright Oct 23, 2023
db3c1ba
Trying to consolidate testing config into one file
jmwright Oct 23, 2023
7e2f15f
Added lint check to CI
jmwright Oct 23, 2023
3f8922c
Trying a newer version of setuptools that supports editable installs
jmwright Oct 23, 2023
6e6f222
Switching back to hatchling to try to fix editable installs
jmwright Oct 23, 2023
dc97648
Trying to simplify the test config using a matrix
jmwright Oct 23, 2023
e6c6b37
Fixed runs-on
jmwright Oct 23, 2023
c258c62
Forcing an upgrade of pip
jmwright Oct 23, 2023
c2a7b5e
Trying to get jobs to stop being cancelled by the system
jmwright Oct 23, 2023
357912b
Reworked PyInstaller spec file and added MacOS to matrix
jmwright Oct 23, 2023
1cf3e47
Trying to fix login bug on MacOS runner
jmwright Oct 23, 2023
ea5a94b
Disabling MacOS runner for now
jmwright Oct 23, 2023
eb5a2da
Trying again to fix MacOS runner
jmwright Oct 23, 2023
fdd8314
update badge url in README.md
justbuchanan Oct 24, 2023
0e407f0
tests: fix path to cq-cli.py and run black formatter
justbuchanan Oct 24, 2023
e7ddb5d
tests.yml: apt-get install install libgl1-mesa-glx
justbuchanan Oct 24, 2023
fe6a4fc
attempt to fix build failure on macOS
justbuchanan Oct 24, 2023
08066ed
Merge branch 'jbrestructure' into restructure
jmwright Oct 24, 2023
0b2f2a1
Disabled MacOS runner for tests
jmwright Oct 24, 2023
74cc929
Added a new PyInstaller CI config
jmwright Oct 24, 2023
87e604e
Fixed pyproject.toml to install correctly for all use cases
jmwright Oct 24, 2023
5c76236
adjust import paths and fix entrypoint in pyproject.toml
justbuchanan Oct 25, 2023
b540ec8
rename cq_cli.py->main.py and resolve import issues
justbuchanan Oct 25, 2023
c964820
Fixed PyInstaller spec for new module naming scheme
jmwright Oct 25, 2023
e19e7c2
Added CadQuery dependencies to make sure they get installed even when…
jmwright Oct 25, 2023
aec0be6
Re-enabled glTF test
jmwright Oct 25, 2023
addae49
Trying without explicit CadQuery dependencies
jmwright Oct 26, 2023
4eff749
Reverting removal of explicit CQ dependencies
jmwright Oct 26, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
68 changes: 0 additions & 68 deletions .github/workflows/check-commit-actions.yml

This file was deleted.

69 changes: 0 additions & 69 deletions .github/workflows/check-pr-actions.yml

This file was deleted.

27 changes: 27 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: lint
on:
push:
branches:
- main
pull_request:
branches:
- main
jobs:
run-black-lint:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: ["3.10"]
steps:
- uses: actions/checkout@v2
- name: Install CadQuery and pytest
shell: bash --login {0}
run: |
pip install --upgrade pip
pip install -e .
pip install -e .[dev]
- name: Run tests
shell: bash --login {0}
run: |
black --diff --check .
36 changes: 36 additions & 0 deletions .github/workflows/pyinstaller.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: pyinstaller-build
on:
workflow_dispatch:
inputs:
type:
description: 'Whether to build a single file (onefile) or directory (dir) dist'
required: true
default: 'dir'
jobs:
build-linux:
runs-on: ubuntu-18.04
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v4
with:
python-version: '3.10'
# - uses: conda-incubator/setup-miniconda@v2
# with:
# miniconda-version: "latest"
# auto-update-conda: true
# python-version: 3.8
# activate-environment: test
- name: Install dependencies
run: |
pip install --upgrade pip
pip --version
pip install -e .
pip install pyinstaller
pip install path
- name: Run PyInstaller build
run: |
pyinstaller pyinstaller.spec ${{ github.event.inputs.type }}
- uses: actions/upload-artifact@v2
with:
name: cq-cli-Linux-x86_64
path: dist
29 changes: 29 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: tests
on:
push:
branches:
- main
pull_request:
branches:
- main
jobs:
run-pytest:
strategy:
fail-fast: false
matrix:
python-version: ["3.10"]
os: [ubuntu-latest, windows-latest] # , macos-latest
runs-on: ${{ matrix.os }}
steps:
- name: Install Dependencies (Linux)
run: sudo apt-get update && sudo apt install -y libgl1-mesa-glx
if: matrix.os == 'ubuntu-latest'
- uses: actions/checkout@v2
- name: Install CadQuery and pytest
run: |
pip3 install --upgrade pip
pip3 install -e .
pip3 install -e .[dev]
- name: Run tests
run: |
python3 -m pytest -v
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# cq-cli

[![tests](https://github.com/CadQuery/cq-cli/actions/workflows/check-commit-actions.yml/badge.svg)](https://github.com/CadQuery/cq-cli/actions)
[![tests](https://github.com/CadQuery/cq-cli/actions/workflows/tests.yml/badge.svg)](https://github.com/CadQuery/cq-cli/actions)

## Contents

Expand Down
106 changes: 106 additions & 0 deletions pyinstaller.spec
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
# -*- mode: python ; coding: utf-8 -*-
import sys, site, os
import glob
from path import Path
from PyInstaller.utils.hooks import collect_submodules

# Whether we are running in onefile or dir mode
onefile_mode = True
if len(sys.argv) == 3:
if sys.argv[2] == 'onefile':
onefile_mode = True
elif sys.argv[2] == 'dir':
onefile_mode = False

block_cipher = None
# if sys.platform == 'linux':
# occt_dir = os.path.join(Path(sys.prefix), 'share', 'opencascade')
# ocp_path = (os.path.join(HOMEPATH, 'OCP.cpython-38-x86_64-linux-gnu.so'), '.')
# elif sys.platform == 'darwin':
# occt_dir = os.path.join(Path(sys.prefix), 'Library', 'share', 'opencascade')
# ocp_path = (os.path.join(HOMEPATH, 'OCP.cpython-38-darwin.so'), '.')
# elif sys.platform == 'win32':
# occt_dir = os.path.join(Path(sys.prefix), 'Library', 'share', 'opencascade')
# ocp_path = (os.path.join(HOMEPATH, 'OCP.cp38-win_amd64.pyd'), '.')

# Dynamically find all the modules in the cqcodecs directory
hidden_imports = []
file_list = glob.glob('.' + os.path.sep + "src" + os.path.sep + "cq_cli" + os.path.sep + 'cqcodecs' + os.path.sep + 'cq_codec_*.py')
for file_path in file_list:
file_name = file_path.split(os.path.sep)[-1]
module_name = file_name.replace(".py", "")
hidden_imports.append("cqcodecs." + module_name)
hidden_imports.append('OCP')
hidden_imports.append('typing_extensions')
hidden_imports.append('pyparsing')
hidden_imports.append('ezdxf')
hidden_imports.append('nptyping')
hidden_imports.append('typish')
hidden_imports.append('numpy.core.dtype')
hidden_imports.append('numpy.core._dtype')
hidden_imports.append('vtkmodules')
hidden_imports.append('vtkmodules.all')

# numpy hidden imports
hidden_imports_numpy = collect_submodules('numpy')
hidden_imports = hidden_imports + hidden_imports_numpy

a = Analysis(['src/cq_cli/main.py'],
pathex=['.'],
#binaries=[
# ocp_path
#],
datas=[
(os.path.join(os.path.dirname(os.path.realpath('__file__')), 'src', 'cq_cli', 'cqcodecs'), 'cqcodecs')
],
hiddenimports=hidden_imports,
hookspath=[],
runtime_hooks=[],
excludes=[],
win_no_prefer_redirects=False,
win_private_assemblies=False,
cipher=block_cipher,
noarchive=False)
pyz = PYZ(a.pure, a.zipped_data,
cipher=block_cipher)

# Select between onefile and dir mode executables
if onefile_mode:
exe = EXE(pyz,
a.scripts,
a.binaries,
a.zipfiles,
a.datas,
[],
name='cq-cli',
debug=False,
bootloader_ignore_signals=False,
strip=False,
upx=False,
upx_exclude=[],
runtime_tmpdir=None,
console=True )
else:
exe = EXE(pyz,
a.scripts,
[],
exclude_binaries=True,
name='cq-cli',
debug=False,
bootloader_ignore_signals=False,
strip=False,
upx=False,
console=True )

exclude = ('libGL','libEGL','libbsd')
a.binaries = TOC([x for x in a.binaries if not x[0].startswith(exclude)])

if not onefile_mode:
coll = COLLECT(exe,
a.binaries,
a.zipfiles,
a.datas,
strip=False,
upx=False,
upx_exclude=[],
name='cq-cli')
32 changes: 28 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ requires = ["hatchling"]
build-backend = "hatchling.build"

[project]
name = "cq-cli"
version = "2.1.0"
license = "Apache-2.0"
name = "cq_cli"
version = "2.3.0"
license = {file = "LICENSE"}
authors = [
{ name="Jeremy Wright" },
]
Expand All @@ -17,9 +17,33 @@ classifiers = [
"Operating System :: OS Independent",
]
dependencies = [
'cadquery >= 2.3.1',
"cadquery @ git+https://github.com/CadQuery/cadquery.git",
"cadquery-ocp>=7.7.0a0,<7.8",
"ezdxf",
"multimethod>=1.7,<2.0",
"nlopt",
"nptyping==2.0.1",
"typish",
"casadi",
"path",
]

[project.scripts]
cq-cli = "cq_cli.main:main"

[project.optional-dependencies]
dev = [
"pytest",
"black==19.10b0",
"click==8.0.4"
]

[project.urls]
"Homepage" = "https://github.com/CadQuery/cq-cli"
"Bug Tracker" = "https://github.com/CadQuery/cq-cli/issues"

[tool.hatch.metadata]
allow-direct-references = true

[tool.hatch.build.targets.wheel]
packages = ["src/cq_cli"]
File renamed without changes.
File renamed without changes.
Loading
Loading