-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #396 from phenobarbital/new_pyproject_support
New pyproject support
- Loading branch information
Showing
34 changed files
with
659 additions
and
655 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,98 @@ | ||
name: Build and Publish Python 🐍 distributions 📦 to PyPI and TestPyPI | ||
name: Python package build and publish | ||
|
||
on: | ||
release: | ||
types: [created] | ||
|
||
jobs: | ||
build: | ||
runs-on: ${{ matrix.os }} | ||
strategy: | ||
matrix: | ||
os: [ubuntu-latest, windows-latest] | ||
python-version: ["3.9", "3.10", "3.11", "3.12"] | ||
steps: | ||
- uses: actions/checkout@v2 | ||
|
||
- name: Set up Python | ||
uses: actions/setup-python@v1 | ||
with: | ||
python-version: ${{ matrix.python-version }} | ||
|
||
- name: Install dependencies | ||
run: | | ||
python -m pip install --upgrade pip | ||
pip install twine | ||
- name: Build wheels on Ubuntu | ||
if: matrix.os == 'ubuntu-latest' | ||
uses: RalfG/python-wheels-manylinux-build@v0.5.0-manylinux2014_x86_64 | ||
with: | ||
python-versions: 'cp39-cp39 cp310-cp310 cp311-cp311 cp312-cp312' | ||
build-requirements: 'cython numpy' | ||
|
||
- name: Build wheels on Windows | ||
if: matrix.os == 'windows-latest' | ||
run: | | ||
pip install cibuildwheel | ||
cibuildwheel --output-dir dist | ||
# You may need to adjust the above command based on your package's specific requirements | ||
- name: Upload wheel artifacts | ||
uses: actions/upload-artifact@v2 | ||
with: | ||
name: wheels-${{ matrix.os }}-py${{ matrix.python-version }} | ||
path: dist/*.whl | ||
|
||
deploy: | ||
needs: build | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- name: Set up Python | ||
uses: actions/setup-python@v1 | ||
with: | ||
python-version: 3.9 | ||
- name: Install dependencies | ||
run: | | ||
python -m pip install --upgrade pip | ||
pip install twine | ||
- name: Build manylinux Python wheels | ||
uses: RalfG/python-wheels-manylinux-build@v0.5.0-manylinux2014_x86_64 | ||
with: | ||
python-versions: 'cp39-cp39 cp310-cp310 cp311-cp311' | ||
build-requirements: 'cython numpy' | ||
- name: Publish wheels to Test PyPI | ||
env: | ||
TWINE_USERNAME: __token__ | ||
TWINE_PASSWORD: ${{ secrets.NAVCONFIG_TEST_PYPI_API_TOKEN }} | ||
run: | | ||
twine upload -r testpypi dist/*-manylinux*.whl | ||
- name: Publish wheels to Production PyPI | ||
env: | ||
TWINE_USERNAME: __token__ | ||
TWINE_PASSWORD: ${{ secrets.NAVCONFIG_PYPI_API_TOKEN }} | ||
run: | | ||
twine upload dist/*-manylinux*.whl | ||
- uses: actions/checkout@v2 | ||
|
||
- name: Download all artifacts | ||
uses: actions/download-artifact@v2 | ||
with: | ||
path: dist | ||
|
||
- name: Move wheel files to 'dist' directory | ||
run: | | ||
find dist -name '*.whl' -exec mv {} dist \; | ||
- name: Check for wheel types | ||
id: check_wheels | ||
run: | | ||
echo "Checking for wheel types..." | ||
if ls dist/*-manylinux*.whl 1> /dev/null 2>&1; then | ||
echo "Found manylinux wheels." | ||
echo "HAS_MANYLINUX_WHEELS=true" >> $GITHUB_ENV | ||
fi | ||
if ls dist/*-win_*.whl 1> /dev/null 2>&1; then | ||
echo "Found Windows wheels." | ||
echo "HAS_WINDOWS_WHEELS=true" >> $GITHUB_ENV | ||
fi | ||
- name: List files in dist | ||
run: ls -l dist | ||
|
||
- name: Set up Python | ||
uses: actions/setup-python@v1 | ||
with: | ||
python-version: '3.x' | ||
|
||
- name: Install twine | ||
run: pip install twine | ||
|
||
- name: Publish manylinux wheels to Production PyPI | ||
if: env.HAS_MANYLINUX_WHEELS == 'true' | ||
env: | ||
TWINE_USERNAME: __token__ | ||
TWINE_PASSWORD: ${{ secrets.NAVCONFIG_PYPI_API_TOKEN }} | ||
run: twine upload dist/*-manylinux*.whl | ||
|
||
- name: Publish Windows wheels to Production PyPI | ||
if: env.HAS_WINDOWS_WHEELS == 'true' | ||
env: | ||
TWINE_USERNAME: __token__ | ||
TWINE_PASSWORD: ${{ secrets.NAVCONFIG_PYPI_API_TOKEN }} | ||
run: twine upload dist/*-win_*.whl |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import sys | ||
from pathlib import Path | ||
from navconfig import config | ||
|
||
|
||
def process_config_file(file_path): | ||
# Check if the file exists | ||
if not Path(file_path).is_file(): | ||
print(f"File not found: {file_path}") | ||
return | ||
|
||
with open(file_path, 'r') as file: | ||
for line in file: | ||
# Strip whitespace from the beginning and end of the line | ||
line = line.strip() | ||
|
||
# Skip blank lines and lines that start with '[' | ||
if not line or line.startswith('['): | ||
continue | ||
|
||
# Split the line into key and value at the first '=' | ||
parts = line.split('=', 1) | ||
if len(parts) == 2: | ||
key, value = parts | ||
key = key.strip() | ||
value = value.strip() | ||
vault = config.source('vault') | ||
if vault: | ||
try: | ||
vault.set(key, value) | ||
print(f"Saved Key: {key}, Value: {value}") | ||
except Exception as e: | ||
print( | ||
f"Error saving Key: {key}={value} on Vault: {e}" | ||
) | ||
|
||
if __name__ == "__main__": | ||
if len(sys.argv) != 2: | ||
print("Usage: python script.py <path_to_config_file>") | ||
sys.exit(1) | ||
|
||
config_file_path = sys.argv[1] | ||
process_config_file(config_file_path) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,31 @@ | ||
import os | ||
import logging | ||
from navconfig import ( | ||
BASE_DIR | ||
) | ||
from navconfig import BASE_DIR | ||
|
||
os.chdir(str(BASE_DIR)) | ||
|
||
### Global-Settings. | ||
try: | ||
from settings.settings import * # pylint: disable=W0401,W0614 | ||
from settings.settings import * # pylint: disable=W0401,W0614 | ||
except ImportError as err: | ||
try: | ||
from settings import settings | ||
logging.error(f'Cannot loaded a settings Module {err}, module: {settings}') | ||
|
||
logging.error(f"Cannot loaded a settings Module {err}, module: {settings}") | ||
print( | ||
'Settings.py File is missing.' | ||
'Hint: Its recommended to use a settings/settings.py module to customize ' | ||
' NAV Configuration.' | ||
"Settings.py File is missing." | ||
"Hint: Its recommended to use a settings/settings.py module to customize " | ||
" NAV Configuration." | ||
) | ||
except ImportError as ex: | ||
logging.error("There is no *settings/* module in project.") | ||
print( | ||
'Settings.py module is missing.' | ||
'Hint: Its recommended to use a settings/settings.py module to customize ' | ||
' NAV Configuration.' | ||
"Settings.py module is missing." | ||
"Hint: Its recommended to use a settings/settings.py module to customize " | ||
" NAV Configuration." | ||
) | ||
### User Local Settings | ||
try: | ||
from settings.local_settings import * # pylint: disable=W0401,W0614 | ||
except (ImportError) as err: | ||
from settings.local_settings import * # pylint: disable=W0401,W0614 | ||
except ImportError as err: | ||
pass |
Oops, something went wrong.