Skip to content

Commit

Permalink
Merge pull request #133 from Erotemic/dev/editable-install-fixes
Browse files Browse the repository at this point in the history
Bump to 1.1.0. Min Python Version is now 3.6. Fixes for editable installs, doctests with decorators.
  • Loading branch information
Erotemic committed Sep 5, 2022
2 parents 22467fd + 194f266 commit f27455b
Show file tree
Hide file tree
Showing 19 changed files with 645 additions and 197 deletions.
54 changes: 1 addition & 53 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,15 +44,6 @@ workflows:
- test_full/cp36-36m-linux:
filters:
<<: *__ignore_release__
- test_full/cp35-35m-linux:
filters:
<<: *__ignore_release__
#- test_full/cp34-34m-linux:
# filters:
# <<: *__ignore_release__
- test_full/cp27-27mu-linux:
filters:
<<: *__ignore_release__

- test_minimal/cp3_10-3_10-linux:
filters:
Expand All @@ -69,15 +60,6 @@ workflows:
- test_minimal/cp36-36m-linux:
filters:
<<: *__ignore_release__
- test_minimal/cp35-35m-linux:
filters:
<<: *__ignore_release__
#- test_minimal/cp34-34m-linux:
# filters:
# <<: *__ignore_release__
- test_minimal/cp27-27mu-linux:
filters:
<<: *__ignore_release__

- test_minimal/pypy3:
filters:
Expand Down Expand Up @@ -224,21 +206,6 @@ jobs:
docker:
- image: cimg/python:3.6

test_full/cp35-35m-linux:
<<: *test_full_template
docker:
- image: cimg/python:3.5

#test_full/cp34-34m-linux:
# <<: *test_full_template
# docker:
# - image: circleci/python:3.4

test_full/cp27-27mu-linux:
<<: *test_full_template
docker:
- image: cimg/python:2.7

# ------------
test_minimal/cp3_10-3_10-linux:
<<: *test_minimal_template
Expand All @@ -265,21 +232,6 @@ jobs:
docker:
- image: cimg/python:3.6

test_minimal/cp35-35m-linux:
<<: *test_minimal_template
docker:
- image: cimg/python:3.5

#test_minimal/cp34-34m-linux:
# <<: *test_minimal_template
# docker:
# - image: circleci/python:3.4

test_minimal/cp27-27mu-linux:
<<: *test_minimal_template
docker:
- image: cimg/python:2.7

# --- pypy ----

test_minimal/pypy3:
Expand Down Expand Up @@ -317,10 +269,6 @@ jobs:
docker run -v $HOME/code/xdoctest:/io -it $IMAGE_NAME bash
IMAGE_NAME=cimg/python:2.7
docker run -v $HOME/code/xdoctest:/io -it $IMAGE_NAME bash
IMAGE_NAME=circleci/python:3.4
docker run -v $HOME/code/xdoctest:/io -it $IMAGE_NAME bash
git clone /io $HOME/repo
Expand Down Expand Up @@ -413,6 +361,6 @@ jobs:
$HOME/.local/bin/circleci config validate
$HOME/.local/bin/circleci local execute --job test_minimal/3.9
$HOME/.local/bin/circleci local execute --job test_minimal/pypy3
$HOME/.local/bin/circleci local execute --job test_full/2.7
$HOME/.local/bin/circleci local execute --job test_full/3.6
$HOME/.local/bin/circleci local execute --config .circleci/config.yml --job test_full/cp38-38-linux
$HOME/.local/bin/circleci local execute --config .circleci/config.yml
14 changes: 6 additions & 8 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,6 @@ jobs:
- ubuntu-latest
- macOS-latest
python-version:
- '2.7'
- '3.5'
- '3.6'
- '3.7'
- '3.8'
Expand All @@ -114,37 +112,37 @@ jobs:
arch:
- auto
include:
- python-version: '2.7'
- python-version: '3.6'
os: windows-latest
install-extras: tests-strict,runtime-strict
- python-version: '3.10'
os: windows-latest
install-extras: tests-strict,runtime-strict
- python-version: '2.7'
- python-version: '3.6'
os: windows-latest
install-extras: tests-strict,runtime-strict,optional-strict
- python-version: '3.10'
os: windows-latest
install-extras: tests-strict,runtime-strict,optional-strict
- python-version: '2.7'
- python-version: '3.6'
os: ubuntu-latest
install-extras: tests-strict,runtime-strict
- python-version: '3.10'
os: ubuntu-latest
install-extras: tests-strict,runtime-strict
- python-version: '2.7'
- python-version: '3.6'
os: ubuntu-latest
install-extras: tests-strict,runtime-strict,optional-strict
- python-version: '3.10'
os: ubuntu-latest
install-extras: tests-strict,runtime-strict,optional-strict
- python-version: '2.7'
- python-version: '3.6'
os: macOS-latest
install-extras: tests-strict,runtime-strict
- python-version: '3.10'
os: macOS-latest
install-extras: tests-strict,runtime-strict
- python-version: '2.7'
- python-version: '3.6'
os: macOS-latest
install-extras: tests-strict,runtime-strict,optional-strict
- python-version: '3.10'
Expand Down
17 changes: 17 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,23 @@ We are currently working on porting this changelog to the specifications in
[Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## Version 1.1.0 - Released 2022-08-19

### Fixed
* Can now handle basic versions of the new `__editable__` package finder mechanism.
* Parsing bug where directives were incorrectly flagged as inline if they were
directly followed by a function with a decorator.


### Removed
* Dropped 2.7 and 3.5 support. Now supporting 3.6+ Use xdoctest<=1.0.2 for 2.7
or 3.5 support.


### Changed
* Improved the "dump" functionality of converting doctests to unit tests.


## Version 1.0.2 - Released 2022-08-19


Expand Down
4 changes: 2 additions & 2 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,8 @@ Installation: from pypi
^^^^^^^^^^^^^^^^^^^^^^^

Xdoctest is distributed on pypi as a universal wheel and can be pip installed on
Python 2.7, Python 3.4+. Installations are tested on CPython and PyPy
implementations.
Python 3.6+ (Python 2.7 and 3.4 / 3.5 support was removed in Version 1.1.0).
Installations are tested on CPython and PyPy implementations.

::

Expand Down
19 changes: 0 additions & 19 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,26 +19,7 @@ environment:

- PYTHON: "C:/Python36-x64"
ARCH_BITS: "64"

- PYTHON: "C:/Python35-x64"
ARCH_BITS: "64"

- PYTHON: "C:\\Python34-x64"
ARCH_BITS: "64"
DISTUTILS_USE_SDK: "1"

- PYTHON: "C:\\Python27-x64"
ARCH_BITS: "64"

- PYTHON: "C:\\Python27"
ARCH_BITS: "32"

- PYTHON: "C:\\Python34"
ARCH_BITS: "32"

- PYTHON: "C:\\Python35"
ARCH_BITS: "32"

- PYTHON: "C:\\Python36"
ARCH_BITS: "32"

Expand Down
1 change: 1 addition & 0 deletions clean.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
echo "start clean"

rm -rf _skbuild
rm -rf coverage.xml
rm -rf -- *.so
rm -rf build
rm -rf xdoctest.egg-info
Expand Down
25 changes: 15 additions & 10 deletions dev/port_ubelt_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,23 @@ def _autogen_xdoctest_utils():
text = lib.current_sourcecode()
print(text)

import redbaron
new_baron = redbaron.RedBaron(text)
new_names = [n.name for n in new_baron.node_list if n.type in ['class', 'def']]
"""
pip install rope
pip install parso
"""

import xdoctest
old_baron = redbaron.RedBaron(open(xdoctest.utils.util_import.__file__, 'r').read())
# target_fpath = ub.Path('~/code/xdoctest/src/xdoctest/utils/util_import.py').expand()
target_fpath = ub.Path(xdoctest.utils.util_import.__file__)

old_names = [n.name for n in old_baron.node_list if n.type in ['class', 'def']]
import parso
import xdoctest
new_module = parso.parse(text)
old_module = parso.parse(target_fpath.read_text())
new_names = [child.name.value for child in new_module.children if child.type in {'funcdef', 'classdef'}]
old_names = [child.name.value for child in old_module.children if child.type in {'funcdef', 'classdef'}]

set(old_names) - set(new_names)
set(new_names) - set(old_names)
print(set(old_names) - set(new_names))
print(set(new_names) - set(old_names))

prefix = ub.codeblock(
'''
Expand All @@ -43,5 +49,4 @@ def _autogen_xdoctest_utils():
from __future__ import print_function, division, absolute_import, unicode_literals
''')

fpath = ub.expandpath('~/code/xdoctest/xdoctest/utils/util_import.py')
open(fpath, 'w').write(prefix + '\n' + text + '\n')
target_fpath.write_text(prefix + '\n' + text + '\n')
134 changes: 134 additions & 0 deletions dev/torch_exposed_issues.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@


# We should be able to handle these:


def issue1():
# ISSUE: DOES NOT SKIP CORRECTLY

def foo1():
"""
>>> # xdoctest: +SKIP("Undefined variables")
>>> @custom_sharded_op_impl(torch.nn.functional.linear)
>>> def my_custom_sharded_linear(types, args, kwargs, process_group):
>>> ...
>>> input = torch.rand(10, 32)
>>> weight = sharded_tensor.rand(32, 16)
>>> bias = torch.rand(16)
>>> # This will call 'my_custom_sharded_linear'
>>> torch.nn.functional.linear(input, weight, bias)
"""

# DOES SKIP CORRECTLY, WHY?
def foo2():
"""
>>> @custom_sharded_op_impl(torch.nn.functional.linear)
>>> def my_custom_sharded_linear(types, args, kwargs, process_group):
>>> ...
>>> # xdoctest: +SKIP("Undefined variables")
>>> input = torch.rand(10, 32)
>>> weight = sharded_tensor.rand(32, 16)
>>> bias = torch.rand(16)
>>> # This will call 'my_custom_sharded_linear'
>>> torch.nn.functional.linear(input, weight, bias)
"""


def issue2():
# Should be able to parse that setup
def CppExtension(name, sources, *args, **kwargs):
r'''
Creates a :class:`setuptools.Extension` for C++.
Convenience method that creates a :class:`setuptools.Extension` with the
bare minimum (but often sufficient) arguments to build a C++ extension.
All arguments are forwarded to the :class:`setuptools.Extension`
constructor.
Example:
>>> from setuptools import setup
>>> from torch.utils.cpp_extension import BuildExtension, CppExtension
>>> setup(
name='extension',
ext_modules=[
CppExtension(
name='extension',
sources=['extension.cpp'],
extra_compile_args=['-g']),
],
cmdclass={
'build_ext': BuildExtension
})
'''
include_dirs = kwargs.get('include_dirs', [])
include_dirs += include_paths()
kwargs['include_dirs'] = include_dirs

library_dirs = kwargs.get('library_dirs', [])
library_dirs += library_paths()
kwargs['library_dirs'] = library_dirs

libraries = kwargs.get('libraries', [])
libraries.append('c10')
libraries.append('torch')
libraries.append('torch_cpu')
libraries.append('torch_python')
kwargs['libraries'] = libraries

kwargs['language'] = 'c++'
return setuptools.Extension(name, sources, *args, **kwargs)

class LSTMCell(torch.nn.Module):
r"""A quantizable long short-term memory (LSTM) cell.
For the description and the argument types, please, refer to :class:`~torch.nn.LSTMCell`
Examples::
>>> import torch.nn.quantizable as nnqa
>>> rnn = nnqa.LSTMCell(10, 20)
>>> input = torch.randn(3, 10)
>>> hx = torch.randn(3, 20)
>>> cx = torch.randn(3, 20)
>>> output = []
>>> for i in range(6):
hx, cx = rnn(input[i], (hx, cx))
output.append(hx)
"""
_FLOAT_MODULE = torch.nn.LSTMCell


def non_doctests():
"""
~/code/pytorch/torch/distributed/launch.py
1. Single-Node multi-process distributed training
::
>>> python -m torch.distributed.launch --nproc_per_node=NUM_GPUS_YOU_HAVE
YOUR_TRAINING_SCRIPT.py (--arg1 --arg2 --arg3 and all other
arguments of your training script)
2. Multi-Node multi-process distributed training: (e.g. two nodes)
Node 1: *(IP: 192.168.1.1, and has a free port: 1234)*
::
>>> python -m torch.distributed.launch --nproc_per_node=NUM_GPUS_YOU_HAVE
--nnodes=2 --node_rank=0 --master_addr="192.168.1.1"
--master_port=1234 YOUR_TRAINING_SCRIPT.py (--arg1 --arg2 --arg3
and all other arguments of your training script)
Node 2:
::
>>> python -m torch.distributed.launch --nproc_per_node=NUM_GPUS_YOU_HAVE
--nnodes=2 --node_rank=1 --master_addr="192.168.1.1"
--master_port=1234 YOUR_TRAINING_SCRIPT.py (--arg1 --arg2 --arg3
and all other arguments of your training script)
"""

0 comments on commit f27455b

Please sign in to comment.