Skip to content

Commit

Permalink
Remove Python 2.7 leftovers
Browse files Browse the repository at this point in the history
  • Loading branch information
DimitriPapadopoulos committed Jan 26, 2025
1 parent 0c5037d commit 7f41aaa
Show file tree
Hide file tree
Showing 8 changed files with 23 additions and 27 deletions.
2 changes: 1 addition & 1 deletion doc/source/dev/building_extension.rst
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ repository or use the upstream repository to get the source code::

git clone https://github.com/holgern/pyedflib.git pyedflib

Install Microsoft Visual C++ Compiler for Python 2.7 from https://www.microsoft.com/en-us/download/details.aspx?id=44266
Install Microsoft Visual C++ Compiler from https://visualstudio.microsoft.com/fr/downloads/

Activate your Python virtual environment, go to the cloned source directory
and type the following commands to build and install the package::
Expand Down
2 changes: 1 addition & 1 deletion doc/source/dev/how_to_release.rst
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ Register all files with

and upload with

```twine upload dist\filename_which_should_uploaded.whl```
```twine upload dist\filename_which_should_uploaded.whl```

Prepare for continued development
---------------------------------
Expand Down
4 changes: 2 additions & 2 deletions doc/source/dev/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,6 @@ Something not working?
----------------------

If these instructions are not clear or you need help setting up your
development environment, go ahead and open a ticket on GitHub_.
development environment, go ahead and open a ticket on GitHub_.

.. _GitHub: https://github.com/holgern/pyedflib
.. _GitHub: https://github.com/holgern/pyedflib
10 changes: 5 additions & 5 deletions doc/source/dev/preparing_windows_build_environment.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,16 @@ Preparing Windows build environment
To start developing pyedflib code on Windows you will have to install
a C compiler and prepare the build environment.

Installing Microsoft Visual C++ Compiler for Python 2.7
-------------------------------------------------------
Installing Microsoft Visual C++ Compiler
----------------------------------------

Downloading Microsoft Visual C++ Compiler for Python 2.7 from https://www.microsoft.com/en-us/download/details.aspx?id=44266.
Downloading Microsoft Visual C++ Compiler from https://visualstudio.microsoft.com/fr/downloads/.


After installing the Compiler and before compiling the extension you have
to configure some environment variables.

For build execute the ``util/setenv_win.bat`` script in the cmd
For build execute the ``util/setenv_win.bat`` script in the cmd
window:

.. sourcecode:: bat
Expand All @@ -39,4 +39,4 @@ After completing these steps continue with
.. _numpy: https://numpy.org/
.. _Cython: https://cython.org/
.. _Sphinx: https://www.sphinx-doc.org/
.. _Microsoft Visual C++ Compiler for Python 2.7: https://www.microsoft.com/en-us/download/details.aspx?id=44266
.. _Microsoft Visual C++ Compiler: https://visualstudio.microsoft.com/fr/downloads/
2 changes: 1 addition & 1 deletion doc/source/resources.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ The `GitHub repository`_ is now the main
code repository.

If you are using the Mercurial repository at Bitbucket, please switch
to Git/GitHub and follow for development updates.
to Git/GitHub and follow for development updates.


Questions and bug reports
Expand Down
2 changes: 1 addition & 1 deletion pyedflib/highlevel.py
Original file line number Diff line number Diff line change
Expand Up @@ -753,7 +753,7 @@ def drop_channels(
if isinstance(ch,str):
ch_idx = ch_names.index(ch.lower())
to_keep[i] = ch_idx
load_channels = list(to_keep) # copy list compatible with py2.7
load_channels = to_keep.copy()
elif to_drop is not None:
for i,ch in enumerate(to_drop):
if isinstance(ch,str):
Expand Down
8 changes: 2 additions & 6 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,8 @@ def get_numpy_include():
# versions.
# setuptools forgets to unset numpy's setup flag and we get a crippled
# version of it unless we do it ourselves.
try:
import __builtin__ # py2
__builtin__.__NUMPY_SETUP__ = False
except:
import builtins # py3
builtins.__NUMPY_SETUP__ = False
import builtins
builtins.__NUMPY_SETUP__ = False
import numpy as np
except ImportError as e:
try:
Expand Down
20 changes: 10 additions & 10 deletions util/authors.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def main():
authors = collections.Counter()

def analyze_line(line, names, disp=False):
line = line.strip().decode('utf-8')
line = line.strip().decode()

# Check the commit author name
m = re.match(u'^@@@([^@]*)@@@', line)
Expand All @@ -58,7 +58,7 @@ def analyze_line(line, names, disp=False):
name = NAME_MAP.get(name, name)
if disp:
if name not in names:
stdout_b.write((" - Author: %s\n" % name).encode('utf-8'))
stdout_b.write((" - Author: %s\n" % name).encode())
names.update((name,))

# Look for "thanks to" messages in the commit log
Expand All @@ -67,13 +67,13 @@ def analyze_line(line, names, disp=False):
name = m.group(2)
if name not in (u'this',):
if disp:
stdout_b.write(" - Log : %s\n" % line.strip().encode('utf-8'))
stdout_b.write(" - Log : %s\n" % line.strip().encode())
name = NAME_MAP.get(name, name)
names.update((name,))

line = line[m.end():].strip()
line = re.sub(r'^(and|, and|, ) ', u'Thanks to ', line)
analyze_line(line.encode('utf-8'), names)
analyze_line(line.encode(), names)

# Find all authors before the named range
for line in git.pipe('log', '--pretty=@@@%an@@@%n@@@%cn@@@%n%b',
Expand Down Expand Up @@ -108,9 +108,9 @@ def name_key(fullname):
n_authors = list(new_authors)
n_authors.sort(key=name_key)
# Print some empty lines to separate
stdout_b.write(("\n\n").encode('utf-8'))
stdout_b.write(("\n\n").encode())
for author in n_authors:
stdout_b.write(("- %s\n" % author).encode('utf-8'))
stdout_b.write(("- %s\n" % author).encode())
# return for early exit so we only print new authors
return

Expand All @@ -133,19 +133,19 @@ def name_key(fullname):
author_clean = author.strip('@')

if author in all_authors:
stdout_b.write((f"* {author_clean} ({count})\n").encode('utf-8'))
stdout_b.write((f"* {author_clean} ({count})\n").encode())
else:
stdout_b.write((f"* {author_clean} ({count}) +\n").encode('utf-8'))
stdout_b.write((f"* {author_clean} ({count}) +\n").encode())

stdout_b.write(("""
A total of %(count)d people contributed to this release.
People with a "+" by their names contributed a patch for the first time.
This list of names is automatically generated, and may not be fully complete.
""" % dict(count=len(authors))).encode('utf-8'))
""" % dict(count=len(authors))).encode())

stdout_b.write(("\nNOTE: Check this list manually! It is automatically generated "
"and some names\n may be missing.\n").encode('utf-8'))
"and some names\n may be missing.\n").encode())


def load_name_map(filename):
Expand Down

0 comments on commit 7f41aaa

Please sign in to comment.