Skip to content

Commit

Permalink
Remove Cython dependency when installing from PyPI. (#118)
Browse files Browse the repository at this point in the history
* Remove cython dependency for PyPI install.

* Version bump and cleaner publish.

* Add comments to the publish process.

* Update changelog.

* Update travis.

* Update getting started guide.
  • Loading branch information
seba-1511 authored Mar 2, 2020
1 parent 83e8bc6 commit 9622558
Show file tree
Hide file tree
Showing 7 changed files with 40 additions and 18 deletions.
3 changes: 1 addition & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,7 @@ before_install: |
install:
- pip install -U pip && pip install --install-option="--no-cython-compile" cython
- pip install --progress-bar off -r requirements.txt && pip install pycodestyle
- python setup.py develop
- pip install --progress-bar off -e . && pip install pycodestyle
# - python -c 'import torch, torchvision; print(torch.__version__, torchvision.__version__)'

script:
Expand Down
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Fixed


## v0.1.0.1

### Fixed

* Remove Cython dependency when installing from PyPI and clean up package distribution.


## v0.1.0

### Added
Expand Down
1 change: 1 addition & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
global-include *.pyx
global-include *.pxd
global-include *.c
include learn2learn/**/*
7 changes: 5 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -56,5 +56,8 @@ release:
git push origin --tags

publish:
python setup.py sdist
twine upload --repository-url https://upload.pypi.org/legacy/ dist/*
pip install -e . # Full build
rm -f learn2learn/*.so # Remove .so files but leave .c files
rm -f learn2learn/**/*.so
python setup.py sdist # Create package
twine upload --repository-url https://upload.pypi.org/legacy/ dist/* # Push to PyPI
2 changes: 2 additions & 0 deletions docs/source/tutorials/getting_started.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ For the most update-to-date version clone the [repository](https://github.com/le

```pip install -e .```

When installing from sources, make sure that Cython is installed: `pip install cython`.

!!! info
While learn2learn is actively used in current research projects, it is still in development.
Breaking changes might occur.
Expand Down
2 changes: 1 addition & 1 deletion learn2learn/_version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = '0.1.0'
__version__ = '0.1.0.1'
36 changes: 23 additions & 13 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#!/usr/bin/env python3

import sys
import re

from distutils.core import setup
Expand All @@ -8,8 +9,6 @@
find_packages,
Extension
)
from Cython.Build import cythonize
from Cython.Distutils import build_ext

# Parses version number: https://stackoverflow.com/a/7071358
VERSIONFILE = 'learn2learn/_version.py'
Expand All @@ -24,27 +23,38 @@
# Compile with Cython
# https://cython.readthedocs.io/en/latest/src/userguide/source_files_and_compilation.html
# https://github.com/FedericoStra/cython-package-example/blob/master/setup.py
include_dirs = []
compiler_directives = {'language_level': 3,
'embedsignature': True,
# 'profile': True,
# 'binding': True,
}
extension_type = '.c'
cmd_class = {}
use_cython = 'develop' in sys.argv
if use_cython:
from Cython.Build import cythonize
from Cython.Distutils import build_ext
extension_type = '.pyx'
cmd_class = {'build_ext': build_ext}

extensions = [
Extension(name='learn2learn.data.meta_dataset',
sources=['learn2learn/data/meta_dataset.pyx']),
sources=['learn2learn/data/meta_dataset' + extension_type]),
Extension(name='learn2learn.data.task_dataset',
sources=['learn2learn/data/task_dataset.pyx']),
sources=['learn2learn/data/task_dataset' + extension_type]),
Extension(name='learn2learn.data.transforms',
sources=['learn2learn/data/transforms.pyx']),
sources=['learn2learn/data/transforms' + extension_type]),
]

if use_cython:
compiler_directives = {'language_level': 3,
'embedsignature': True,
# 'profile': True,
# 'binding': True,
}
extensions = cythonize(extensions, compiler_directives=compiler_directives)

# Installs the package
install(
name='learn2learn',
packages=find_packages(),
ext_modules=cythonize(extensions, compiler_directives=compiler_directives),
cmdclass={'build_ext': build_ext},
ext_modules=extensions,
cmdclass=cmd_class,
zip_safe=False, # as per Cython docs
version=VERSION,
description='PyTorch Meta-Learning Framework for Researchers',
Expand Down

0 comments on commit 9622558

Please sign in to comment.