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

Fixed Issue with macOS build using 'd:lto' flag + Added support for *.nim.cfg and *.nims files to specify compiler flags. + Amended the README see #52 #55

Merged
merged 45 commits into from
Nov 5, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
e1b3a0d
Fixed issue #51. Added check if not macOS before adding '-d:lto' to N…
SekouDiaoNlp Nov 1, 2021
df0deb3
Added python 3.9 and 3.10 to workflow matrix.
SekouDiaoNlp Nov 1, 2021
6ef2a47
Added dev workflow to test changes during development on multiple OS.
SekouDiaoNlp Nov 1, 2021
0ed39e0
nim-version: 'stable'.
SekouDiaoNlp Nov 1, 2021
f034e16
Specify dev branch of SekouDiaoNlp's repo.
SekouDiaoNlp Nov 1, 2021
5b704c3
Added nim version matrix.
SekouDiaoNlp Nov 1, 2021
8403447
fixed typo.
SekouDiaoNlp Nov 1, 2021
7a8665e
install from local source.
SekouDiaoNlp Nov 1, 2021
a46554f
install from local source.
SekouDiaoNlp Nov 1, 2021
3ef3c51
Corrections.
SekouDiaoNlp Nov 1, 2021
8e142bb
install from local source.
SekouDiaoNlp Nov 1, 2021
29f9940
fail-fast: false.
SekouDiaoNlp Nov 1, 2021
62d7ac2
Added nim-version '1.2.0', '1.3.0' to matrix.
SekouDiaoNlp Nov 1, 2021
887c265
Removed nim-version '1.2.0', '1.3.0' from matrix as they fail.
SekouDiaoNlp Nov 1, 2021
187ac0c
Added has_nim_config() method to check for the presence of '.nim.cfg'…
SekouDiaoNlp Nov 1, 2021
844d9ae
Construct nim_args depending on has_nim_config().
SekouDiaoNlp Nov 1, 2021
36e2775
Created test folder for testing nim config file detection.
SekouDiaoNlp Nov 2, 2021
3cce9e5
Added test for nim config file detection feature.
SekouDiaoNlp Nov 2, 2021
7ea88c1
Parametrized tests to mae sure both '.nim.cfg' and '.nims' files are …
SekouDiaoNlp Nov 2, 2021
bb5efc6
Parametrized tests to make sure both '.nim.cfg' and '.nims' files are…
SekouDiaoNlp Nov 2, 2021
97e539d
Removed switches.py functionality. Removed tests involving switches.py.
SekouDiaoNlp Nov 2, 2021
0f52eb6
Updated documentation to remove switches.py references and add instea…
SekouDiaoNlp Nov 2, 2021
fb5ea7a
Added deprecation notice.
SekouDiaoNlp Nov 2, 2021
6bea40a
Merge remote-tracking branch 'origin/dev' into dev
SekouDiaoNlp Nov 2, 2021
bd10648
Remoevd nim 1.5 from matrix for now as there is a bug with jiro4989/s…
SekouDiaoNlp Nov 2, 2021
7c28d32
Added master to pull requests.
SekouDiaoNlp Nov 2, 2021
4714280
Changed name of the workflow.
SekouDiaoNlp Nov 2, 2021
d7bc4bb
Added show warning if nimporter detects a 'switches.py' file.
SekouDiaoNlp Nov 2, 2021
3fc7645
Refactored NimCompiler.compile_nim_extension() and NimCompiler.compil…
SekouDiaoNlp Nov 3, 2021
9555ad9
Fixed documentation to clarify how to ensure chosenim_install is inst…
SekouDiaoNlp Nov 3, 2021
0ad75a5
Renamed requirements.txt to requirements_dev.txt to conform to naming…
SekouDiaoNlp Nov 3, 2021
f143675
Added '.rstrip()' to comparison to fix "AssertionError: assert 'Hello…
SekouDiaoNlp Nov 3, 2021
ee1948c
Added pyproject.toml with full PEP compliance.
SekouDiaoNlp Nov 3, 2021
bfff572
Added build and test workflow with poetry backend.
SekouDiaoNlp Nov 3, 2021
96a1064
Fixed copy-paste typo.
SekouDiaoNlp Nov 3, 2021
227653f
Renamed requirements.txt to requirements_dev.txt to conform to naming…
SekouDiaoNlp Nov 3, 2021
ad30f66
nim-version: 'stable'.
SekouDiaoNlp Nov 3, 2021
bd84f94
Added mypy dependency.
SekouDiaoNlp Nov 3, 2021
602aa25
Added Type annotations.
SekouDiaoNlp Nov 3, 2021
c77447a
Added # type: ignore[assignment, operator] to allow for reassignment …
SekouDiaoNlp Nov 3, 2021
cbe13c1
Added # type: ignore[attr-defined] to allow import of NimCompiler, Ni…
SekouDiaoNlp Nov 3, 2021
2f51cb4
Bumped to version 1.1.0.
SekouDiaoNlp Nov 3, 2021
5e25e85
Removed examples from source distribution.
SekouDiaoNlp Nov 3, 2021
b9680b2
Fix path to files to be analysed.
SekouDiaoNlp Nov 3, 2021
b1cabd8
Trimmed build matrix.
SekouDiaoNlp Nov 3, 2021
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
46 changes: 46 additions & 0 deletions .github/workflows/dev_workflow.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# This is a basic workflow to help you get started with Actions

name: CI_DEV

# Controls when the action will run. Triggers the workflow on push or pull request
# events for the master and dev branches
on:
push:
branches: [ dev ]
pull_request:
branches: [ master, dev ]

jobs:

# ----------------------------------------------------------------------------
test-all:
runs-on: ${{ matrix.os }}

strategy:
fail-fast: false
matrix:
os: [windows-latest, macos-latest, ubuntu-latest]
python-version: ['3.10', 3.9, 3.8, 3.7, 3.6]
nim-version: [ '1.4.0', 'stable', 'devel' ]

steps:
- uses: actions/checkout@v2

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v1
with:
python-version: ${{ matrix.python-version }}

- uses: jiro4989/setup-nim-action@v1.3
with:
nim-version: ${{ matrix.nim-version }}

- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install setuptools wheel
python -m pip install .
python -m pip install -r requirements_dev.txt

- name: Test
run: pytest --cov=. tests
6 changes: 3 additions & 3 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
strategy:
matrix:
os: [windows-latest, macos-latest, ubuntu-latest]
python-version: [3.8, 3.7, 3.6]
python-version: ['3.10', 3.9, 3.8, 3.7, 3.6]

steps:
- uses: actions/checkout@v2
Expand All @@ -31,14 +31,14 @@ jobs:

- uses: jiro4989/setup-nim-action@v1.3
with:
nim-version: '1.0.6'
nim-version: 'stable'

- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install setuptools wheel
python -m pip install git+https://github.com/Pebaz/nimporter
python -m pip install -r requirements.txt
python -m pip install -r requirements_dev.txt

- name: Test
run: pytest --cov=. tests
64 changes: 64 additions & 0 deletions .github/workflows/poetry_build_and_test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
# This is a basic workflow to help you get started with Actions

name: CI_DEV_POETRY

# Controls when the action will run. Triggers the workflow on push or pull request
# events for the master and dev branches
on:
push:
branches: [ dev ]
pull_request:
branches: [ master ]

jobs:

# ----------------------------------------------------------------------------
test-all:
runs-on: ${{ matrix.os }}

strategy:
fail-fast: false
matrix:
os: [macos-latest, ubuntu-latest ]
python-version: ['3.10', 3.9 ]
nim-version: [ 'stable', 'devel' ]

steps:
- uses: actions/checkout@v2

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v1
with:
python-version: ${{ matrix.python-version }}

- uses: jiro4989/setup-nim-action@v1.3
with:
nim-version: ${{ matrix.nim-version }}

- name: Install Poetry
uses: snok/install-poetry@v1
with:
virtualenvs-create: true
virtualenvs-in-project: true
# - name: Clear corrupted cache
# run: poetry cache clear pypi --all --no-interaction
# if: ${{ matrix.os == 'ubuntu-latest' }} # Clear Linux cache
- name: Load cached venv
id: cached-pip-wheels
uses: actions/cache@v2
# if: ${{ matrix.os != 'ubuntu-latest' }} # Linux cache seems to be corrupted
with:
path: ~/.cache
key: venv-${{ runner.os }}-${{ matrix.python-version }}-${{ hashFiles('**/poetry.lock') }}
- name: Install dependencies
run: poetry install --no-interaction --no-root
- name: Install Package
run: poetry install --no-interaction
- name: Build Package
run: poetry build
- name: Run Type Checker
run: |
poetry run pip install types-setuptools
poetry run mypy
- name: Run Pytest with coverage
run: poetry run pytest --cov=.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -109,3 +109,6 @@ venv.bak/

# mypy
.mypy_cache/

# Pycharm settings
.idea/
30 changes: 21 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,8 @@ treat an entire Nim project as a single module. The project must contain a
and still be imported and compiled at runtime.

Have a complex build requirement that would normally entail tweaking Nim
compiler switches for each supported platform? Nimporter fully supports adding a
`switches.py` file for libraries that need to customize the CLI flags for any
compiler switches for each supported platform? Nimporter fully supports adding
`*.nim.cfg` or `*.nims` files for libraries that need to customize the CLI flags for any
platform seamlessly for both developing and bundling extensions.

Since Nimporter relies on [Nimpy](https://github.com/yglukhov/nimpy) for Nim <->
Expand Down Expand Up @@ -172,7 +172,7 @@ Project/
something2.py
# some_nim_library is used as a single Python module
# Can be directly imported but supports dependencies and custom switches
some_nim_library/ # Allows the use of `switches.py` and .nimble
some_nim_library/ # Allows the use of .nim.cfg, .nims and .nimble
some_nim_library.nimble # Dependency info
some_nim_file1.nim
some_nim_file2.nim
Expand Down Expand Up @@ -204,20 +204,30 @@ Project/
# Must be named the same as the folder
nim_ext_requiring_dependencies.nim
# Can be used to customize Nim compiler switches per platform
switches.py
nim_ext_requiring_dependencies.nim.cfg
# You can have `nim_ext_requiring_dependencies.nim` import other
# Nim code as well
other_necessary_nim_files.nim
```

For several examples of how to structure a project, look in the `tests/` folder.

## Compiler Switches using `switches.py`
## Compiler Switches using `*.nim.cfg` or `*.nims`

---
**DEPRECATION NOTICE**

The use of the file `switches.py` for specifying compiler flags has been deprecated in favour of
`*.nim.cfg` or `*.nims` configuration files.

---

For Nim extension libraries only (a folder, nimble file, and Nim file of the
same name), you can place a file called `switches.py` that Nimporter will use to
same name), you can place a file called `*.nim.cfg` or `*.nims` to
customize what flags get passed to the Nim compiler when it compiles that
extension. For examples on how to do this, please look in the `tests/` folder.
For documentation on the Nim compiler configuration files,
please look [here](https://nim-lang.org/docs/nimc.html#compiler-usage-configuration-files).

### Increasing Speed by using the `-d:danger` flag

Expand Down Expand Up @@ -296,10 +306,12 @@ setup(
..., # Keep your existing arguments
package_data={'': ['*.nim*']}, # Distribute *.nim & *.nim.cfg source files
# include_package_data=True, # <- This line cannot work with package_data
setup_requires = [
"choosenim_install", # Optional. Auto-installs Nim compiler
],
install_requires=[
'nimporter', # Must depend on Nimporter
'choosenim_install' # Optional. Auto-installs Nim compiler
]
]
)
```

Expand Down Expand Up @@ -430,7 +442,7 @@ This example will assume you are cloning the GitHub reposotory.
```bash
$ git clone https://github.com/Pebaz/Nimporter
$ cd Nimporter
$ pip install -r requirements.txt
$ pip install -r requirements_dev.txt
$ pip install . # Nimporter is needed for the integration tests
$ pytest --cov=. --cov-report=html tests
```
Expand Down
48 changes: 0 additions & 48 deletions examples/myfoo/switches.py

This file was deleted.

49 changes: 0 additions & 49 deletions examples/setup_test/nimext/custom/switches.py

This file was deleted.

Loading