Skip to content

Commit

Permalink
Merge pull request #257 from s-scherrer/master
Browse files Browse the repository at this point in the history
Fix PyPI upload in CI
  • Loading branch information
s-scherrer committed Dec 17, 2021
2 parents 379f160 + 2b72bfc commit 4768fab
Show file tree
Hide file tree
Showing 6 changed files with 566 additions and 533 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/ci.yml
Expand Up @@ -37,6 +37,7 @@ jobs:
- name: Print Infos
shell: bash -l {0}
run: |
git status
conda info -a
conda list
pip list
Expand Down Expand Up @@ -68,6 +69,7 @@ jobs:
- name: Create wheel and dist package
shell: bash -l {0}
run: |
git status
pip install setuptools_scm
if [ ${{ matrix.os }} == "windows-latest" ]
then
Expand Down
17 changes: 10 additions & 7 deletions DEVELOPERS_GUIDE.md
Expand Up @@ -11,7 +11,7 @@ Setup
conda env create -f environment.yml
conda activate pytesmo
```

3) Install pytesmo for development:
```
pip install -e .
Expand All @@ -27,8 +27,8 @@ Setup
```
This runs a few checks before you commit your code to make sure it's nicely
formatted.


Now you should be ready to go.


Expand All @@ -52,7 +52,7 @@ Create a local branch:
```
git checkout -b my_feature_branch
```

Now add your feature. Please add some tests in the test directory. See below for
how to run them. Once you are done, you can add and commit your changes (`git
add <changed files>` and `git commit`) and push them to your fork. The first
Expand All @@ -76,7 +76,7 @@ Working with Cython

In case you change something in the cython extensions, make sure to run:

python setup.py build_ext --inplace
python setup.py build_ext --inplace --cythonize

after you applied your changes. There will be some warnings like this:

Expand All @@ -87,6 +87,9 @@ Ignore the warnings about unused entries, e.g. 'dtype_signed', 'itemsize',
than unused entry, or if one of the unused entries looks like a variable name
you used, you should probably investigate them.

Remember to check in the generated C-files, because the built binary packages
uploaded to PyPI will be based on those.


Setup.py commands
-----------------
Expand All @@ -113,7 +116,7 @@ Creating a release
------------------

To release a new version of this package, make sure all tests are passing
on the master branch and the `CHANGELOG.rst` is up-to-date, with changes for
on the master branch and the `CHANGELOG.rst` is up-to-date, with changes for
the new version at the top.

Then draft a new release on [GitHub](https://github.com/TUW-GEO/pytesmo/releases).
Expand All @@ -124,5 +127,5 @@ all tests have passed.
If this does not work (tests pass but upload fails) you can download the
``whl`` and ``dist`` packages for each workflow run from
https://github.com/TUW-GEO/pytesmo/actions (Artifacts) and push them manually to
https://pypi.org/project/pytesmo/ e.g. using [twine](https://pypi.org/project/twine/)
https://pypi.org/project/pytesmo/ e.g. using [twine](https://pypi.org/project/twine/)
(you need to be a package maintainer on pypi for that).
31 changes: 19 additions & 12 deletions setup.py
Expand Up @@ -51,25 +51,32 @@ def cythonize_extensions():
)


# We want to cythonize the .pyx modules (that is, regenerate the .c files)
# whenever we run sdist, so we always ship up to date .c files.
# Additionally, we want build_ext to have an additional option `--cythonize`
# with which we can also recythonize.
# Therefore we subclass the setuptools versions of those and tell them to use
# Cython
class sdist(_sdist):
def run(self):
cythonize_extensions()
super().run()
class CythonizeMixin(object):

user_options = [
("cythonize", None, "recreate the c extionsions with cython")
]

class build_ext(_build_ext):
def initialize_options(self):
super().initialize_options()
self.cythonize = False

def run(self):
cythonize_extensions()
if self.cythonize:
cythonize_extensions()
super().run()


class sdist(CythonizeMixin, _sdist):
user_options = getattr(_sdist, 'user_options', [])\
+ CythonizeMixin.user_options


class build_ext(CythonizeMixin, _build_ext):
user_options = getattr(_build_ext, 'user_options', [])\
+ CythonizeMixin.user_options


if __name__ == "__main__":
cmdclass = {}
cmdclass["sdist"] = sdist
Expand Down

0 comments on commit 4768fab

Please sign in to comment.