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

Move package to a top-level "src" directory #293

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
3 changes: 1 addition & 2 deletions .github/workflows/lint_python.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jobs:
- uses: actions/setup-python@v2
- run: pip install --upgrade pip wheel
- run: pip install bandit black codespell flake8 flake8-bugbear
flake8-comprehensions isort mypy pytest pyupgrade safety
flake8-comprehensions isort mypy pyupgrade safety
- run: bandit --recursive --skip B311 .
- run: black --check . || true
- run: codespell # --ignore-words-list="" --skip="*.css,*.js,*.lock"
Expand All @@ -19,6 +19,5 @@ jobs:
- run: pip install -r requirements.txt
- run: mkdir --parents --verbose .mypy_cache
- run: mypy --ignore-missing-imports --install-types --non-interactive . || true
- run: pytest .
- run: shopt -s globstar && pyupgrade --py36-plus **/*.py || true
- run: safety check
1 change: 1 addition & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
include LICENSE.txt CHANGELOG.rst
recursive-include demos *.py *.bat *.sh
recursive-include tests *.py
Copy link
Owner

@tartley tartley Oct 7, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thinking out loud. Do we need to include the tests in the package? I think https://hynek.me/articles/testing-packaging/ suggests we do not.

Could the test runner just import the tests from something like PROJECTROOT/tests ? (which will contain an __init__.py).

I might try it out myself tomorrow, but feel free to try it yourself if this makes sense to you.

9 changes: 9 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,15 @@ them though. Let me know if it would be useful for you, via the Issues on
GitHub.


Demos
-----

Colorama ships with several demos that show its features. Run them the same as
any Python script::

$ python demos/demo01.py


Status & Known Problems
-----------------------

Expand Down
2 changes: 1 addition & 1 deletion demos/fixpath.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@
# the local source in preference to any installed version of colorama.
import sys
from os.path import normpath, dirname, join
local_colorama_module = normpath(join(dirname(__file__), '..'))
local_colorama_module = normpath(join(dirname(__file__), '..', 'src'))
sys.path.insert(0, local_colorama_module)
3 changes: 2 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def get_version(path):

setup(
name=NAME,
version=get_version(os.path.join('colorama', '__init__.py')),
version=get_version(os.path.join('src', 'colorama', '__init__.py')),
description='Cross-platform colored terminal text.',
long_description=read_file('README.rst'),
keywords='color colour terminal text ansi windows crossplatform xplatform',
Expand All @@ -43,6 +43,7 @@ def get_version(path):
url='https://github.com/tartley/colorama',
license='BSD',
packages=[NAME],
package_dir={"": "src"},
Copy link
Owner

@tartley tartley Oct 7, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

update Ignore this comment after all. See thoughts in the next comment:

Could I ask you to also fix line 43 for me, to resemble the one shown in Hynek's article? ie. from:

packages=[NAME],

to something like:

packages=find_packages(where='src')

where 'find_packages' should be imported from setuptools.

Yeesh. Look at that, we're alternatively trying to import distutils, too. We should perhaps drop that. You leave the distutils import alone, I'll go read about whether I can delete it. Sound good? Thoughts welcome.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe my suggestion is a bad idea after all. I'm terrified of breaking things for some project out there that is using distutils - if it turns out to be a high profile one, I'll get a tsunamic of issues, emails, tweets. Requires more thought. Ignore my suggestion above.

python_requires='>=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*',
# see classifiers https://pypi.org/pypi?%3Aaction=list_classifiers
classifiers=[
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions colorama/tests/ansi_test.py → tests/ansi_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
import sys
from unittest import TestCase, main

from ..ansi import Back, Fore, Style
from ..ansitowin32 import AnsiToWin32
from colorama.ansi import Back, Fore, Style
from colorama.ansitowin32 import AnsiToWin32

stdout_orig = sys.stdout
stderr_orig = sys.stderr
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
except ImportError:
from mock import MagicMock, Mock, patch

from ..ansitowin32 import AnsiToWin32, StreamWrapper
from colorama.ansitowin32 import AnsiToWin32, StreamWrapper
from .utils import osname


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
except ImportError:
from mock import patch

from ..ansitowin32 import StreamWrapper
from ..initialise import init
from colorama.ansitowin32 import StreamWrapper
from colorama.initialise import init
from .utils import osname, replace_by

orig_stdout = sys.stdout
Expand Down
2 changes: 1 addition & 1 deletion colorama/tests/isatty_test.py → tests/isatty_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import sys
from unittest import TestCase, main

from ..ansitowin32 import StreamWrapper, AnsiToWin32
from colorama.ansitowin32 import StreamWrapper, AnsiToWin32
from .utils import pycharm, replace_by, replace_original_by, StreamTTY, StreamNonTTY


Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion colorama/tests/winterm_test.py → tests/winterm_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
except ImportError:
from mock import Mock, patch

from ..winterm import WinColor, WinStyle, WinTerm
from colorama.winterm import WinColor, WinStyle, WinTerm


class WinTermTest(TestCase):
Expand Down
6 changes: 4 additions & 2 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,7 @@
envlist = py27, py35, py36, py37, py38, py39, py310, pypy, pypy3

[testenv]
deps = py27,pypy: mock
commands = python -m unittest discover -p *_test.py
deps =
pytest
py27,pypy: mock
commands = pytest